浏览代码

:bug: fixing the exhibition meta key | #140

tags/0.9.0
J 4 年前
父节点
当前提交
289a799a02
共有 1 个文件被更改,包括 11 次插入4 次删除
  1. 11
    4
      plugins/cia-endpoints/includes/formats.php

+ 11
- 4
plugins/cia-endpoints/includes/formats.php 查看文件

@@ -43,7 +43,7 @@ function default_post_format( $item, $include_content ) {
43 43
     $filtered[hero] = get_post_meta( $item->ID, 'hero_header', true );
44 44
 
45 45
     // Materials + type endpoints
46
-    $posts_with_type = ['artist', 'exhbition', 'event'];
46
+    $posts_with_type = ['artist', 'exhibition', 'event'];
47 47
     if( in_array($item->post_type, $posts_with_type) ) {
48 48
         $filtered[materials] = make_taxonomy_endpoint_for(get_the_terms( $item, 'material'));
49 49
         $filtered[subtypes] = make_taxonomy_endpoint_for(get_the_terms( $item, $item->post_type . '_type' ));
@@ -54,10 +54,17 @@ function default_post_format( $item, $include_content ) {
54 54
 
55 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 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 68
         $filtered[current] = time() <= (int)$filtered[end] && time() >= (int)$filtered[start];
62 69
     }
63 70
 

正在加载...
取消
保存