c00419c7 by Jeremy Groot

update to forms and manuals upload dates

1 parent cf63e3fd
...@@ -89,18 +89,49 @@ function resources_list($atts){ ...@@ -89,18 +89,49 @@ function resources_list($atts){
89 'posts_per_page' => -1, 89 'posts_per_page' => -1,
90 'paged' => 1, 90 'paged' => 1,
91 'post_status' => 'any', 91 'post_status' => 'any',
92 'order' => 'DESC', 92 // 'order' => 'DESC',
93 'orderby' => 'rand', 93 // 'orderby' => 'rand',
94 'tax_query' => ['relation' => 'OR', $tax_queries], 94 'tax_query' => ['relation' => 'OR', $tax_queries],
95 ); 95 );
96 96
97 $custom_query = new \WP_Query($custom_args); 97 $custom_query = get_posts($custom_args);
98
99 usort($custom_query, function($a, $b) {
100
101 $adate = strtotime(get_post_meta($a->ID, 'searchwp_content_pdf_metadata', true)['CreationDate']);
102 $bdate = strtotime(get_post_meta($b->ID, 'searchwp_content_pdf_metadata', true)['CreationDate']);
103
104 if(empty($adate)) {
105 $adate = strtotime($a->post_date);
106 }
107
108 if(empty($bdate)) {
109 $bdate = strtotime($b->post_date);
110 }
111
112 // if($a->ID == 69064) {
113 // var_dump($adate);exit;
114 // }
115
116
117
118 if($adate < $bdate) {
119 return 1;
120 } else if($adate > $bdate) {
121 return -1;
122 }
123
124
125 });
126
127
128
98 129
99 $favs = get_user_meta(get_current_user_id(),'fav_resources',true); 130 $favs = get_user_meta(get_current_user_id(),'fav_resources',true);
100 131
101 ob_start(); 132 ob_start();
102 133
103 if ($custom_query->have_posts()): 134 if (!empty($custom_query)):
104 ?> 135 ?>
105 <div class="course-list resources hidden"> 136 <div class="course-list resources hidden">
106 <div class='quicksearch-wrapper'> 137 <div class='quicksearch-wrapper'>
...@@ -151,15 +182,16 @@ function resources_list($atts){ ...@@ -151,15 +182,16 @@ function resources_list($atts){
151 <table id="resources" class='hidden'> 182 <table id="resources" class='hidden'>
152 <thead><tr><th class="hidden"></th><th></th><th class="hidden"></th></tr></thead> 183 <thead><tr><th class="hidden"></th><th></th><th class="hidden"></th></tr></thead>
153 <tbody> 184 <tbody>
154 <?php while ($custom_query->have_posts()): 185 <?php foreach ($custom_query as $post):
155 $custom_query->the_post(); 186
156 if(is_array($favs)) { 187 if(is_array($favs)) {
157 $is_fav = in_array(get_the_ID(), $favs); 188 $is_fav = in_array($post->ID, $favs);
158 } else { 189 } else {
159 $is_fav = false; 190 $is_fav = false;
160 } 191 }
161 echo resources(get_the_ID(), $organized_term_filter, $is_fav); 192
162 endwhile; ?> 193 echo resources($post->ID, $organized_term_filter, $is_fav);
194 endforeach; ?>
163 </tbody> 195 </tbody>
164 </table> 196 </table>
165 197
...@@ -242,6 +274,11 @@ function resources($id, $taxes, $is_fav = false){ ...@@ -242,6 +274,11 @@ function resources($id, $taxes, $is_fav = false){
242 $updated_at = get_field('updated_at', $post->ID); 274 $updated_at = get_field('updated_at', $post->ID);
243 $is_new = get_field('is_new', $post->ID); 275 $is_new = get_field('is_new', $post->ID);
244 276
277 $post_date = strtotime(get_post_meta($id, 'searchwp_content_pdf_metadata', true)['CreationDate']);
278 if(empty($post_date)) {
279 $post_date = strtotime($post->post_date);
280 }
281
245 $categories = []; 282 $categories = [];
246 foreach($taxes as $tax => $val) { 283 foreach($taxes as $tax => $val) {
247 $terms = get_the_terms( $id, $tax ); 284 $terms = get_the_terms( $id, $tax );
...@@ -281,7 +318,7 @@ function resources($id, $taxes, $is_fav = false){ ...@@ -281,7 +318,7 @@ function resources($id, $taxes, $is_fav = false){
281 <?php } ?> 318 <?php } ?>
282 </td> 319 </td>
283 <td class="hidden"> <?php echo $cat; ?></td> 320 <td class="hidden"> <?php echo $cat; ?></td>
284 <td class="hidden"><?php echo get_post_time('U',false, $id ); ?></td> 321 <td class="hidden"><?php echo $post_date; ?></td>
285 </tr> 322 </tr>
286 <?php 323 <?php
287 $output = ob_get_clean(); 324 $output = ob_get_clean();
......