Parcourir la source

:bug: fixing the exhibition meta key | #140

tags/0.9.0
J il y a 4 ans
Parent
révision
289a799a02
1 fichiers modifiés avec 11 ajouts et 4 suppressions
  1. 11
    4
      plugins/cia-endpoints/includes/formats.php

+ 11
- 4
plugins/cia-endpoints/includes/formats.php Voir le fichier

43
     $filtered[hero] = get_post_meta( $item->ID, 'hero_header', true );
43
     $filtered[hero] = get_post_meta( $item->ID, 'hero_header', true );
44
 
44
 
45
     // Materials + type endpoints
45
     // Materials + type endpoints
46
-    $posts_with_type = ['artist', 'exhbition', 'event'];
46
+    $posts_with_type = ['artist', 'exhibition', 'event'];
47
     if( in_array($item->post_type, $posts_with_type) ) {
47
     if( in_array($item->post_type, $posts_with_type) ) {
48
         $filtered[materials] = make_taxonomy_endpoint_for(get_the_terms( $item, 'material'));
48
         $filtered[materials] = make_taxonomy_endpoint_for(get_the_terms( $item, 'material'));
49
         $filtered[subtypes] = make_taxonomy_endpoint_for(get_the_terms( $item, $item->post_type . '_type' ));
49
         $filtered[subtypes] = make_taxonomy_endpoint_for(get_the_terms( $item, $item->post_type . '_type' ));
54
 
54
 
55
     if($item->post_type === 'artist') $filtered[sortname] = get_post_meta( $item->ID, 'artist-sort-name', true );
55
     if($item->post_type === 'artist') $filtered[sortname] = get_post_meta( $item->ID, 'artist-sort-name', true );
56
 
56
 
57
-    $posts_with_date = ['exhbition', 'event'];
57
+    $posts_with_date = ['exhibition', 'event'];
58
     if( in_array($item->post_type, $posts_with_date) ) {
58
     if( in_array($item->post_type, $posts_with_date) ) {
59
-        $filtered[start] = get_post_meta($item->ID, $item->post_type . '-start-time', true);
60
-        $filtered[end] = get_post_meta($item->ID, $item->post_type . '-end-time', true);
59
+        $key_prefix = $item->post_type;
60
+        $key_suffix = 'time';
61
+        // Exhibition meta key is very old so we change it back to exhibit
62
+        if($item->post_type == 'exhibition') { 
63
+            $key_prefix = 'exhibit';
64
+            $key_suffix = 'date';
65
+        }
66
+        $filtered[start] = get_post_meta($item->ID, $key_prefix . '-start-' . $key_suffix, true);
67
+        $filtered[end] = get_post_meta($item->ID, $key_prefix . '-end-' . $key_suffix, true);
61
         $filtered[current] = time() <= (int)$filtered[end] && time() >= (int)$filtered[start];
68
         $filtered[current] = time() <= (int)$filtered[end] && time() >= (int)$filtered[start];
62
     }
69
     }
63
 
70
 

Chargement…
Annuler
Enregistrer