PluginProbe
WP Ultimate Post Grid / 2.0
WP Ultimate Post Grid v2.0
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
← All changes | helpers/grid_cache.php +10 -89 2.4.02.0 View file →
@@ -39,21 +39,16 @@
39 39
40 40 $query = new WP_Query( $args );
41 41 $posts = $query->have_posts() ? $query->posts : array();
42 42
43 - $grid_ids = array();
44 43 foreach ( $posts as $grid_post )
45 44 {
46 45 $grid = new WPUPG_Grid( $grid_post );
47 46
48 47 if( in_array( $post_type, $grid->post_types() ) ) {
49 - $grid_ids[] = $grid->ID();
48 + $this->generate( $grid->ID() );
50 49 }
51 50 }
52 -
53 - if( count( $grid_ids ) > 0 ) {
54 - update_option( 'wpupg_regenerate_grids_check', $grid_ids );
55 - }
56 51 }
57 52
58 53 public function updated_term( $term_id, $taxonomy )
59 54 {
@@ -236,18 +231,13 @@
236 231
237 232 // Terms per post
238 233 $post_taxonomy_term_ids[] = $slug;
239 234
240 - if( !array_key_exists( $slug, $filter_terms ) ) {
241 - // Filter terms
242 - $filter_terms[$slug] = array(
243 - 'taxonomy' => $taxonomy,
244 - 'name' => $term->name,
245 - 'count' => 1,
246 - );
247 - } else {
248 - $filter_terms[$slug]['count']++;
249 - }
235 + // Filter terms
236 + $filter_terms[$slug] = array(
237 + 'taxonomy' => $taxonomy,
238 + 'name' => $term->name,
239 + );
250 240 }
251 241
252 242 $terms_per_post[$post_id][$taxonomy] = $post_taxonomy_term_ids;
253 243 }
@@ -252,41 +242,8 @@
252 242 $terms_per_post[$post_id][$taxonomy] = $post_taxonomy_term_ids;
253 243 }
254 244 }
255 245
256 - // Show Empty Terms
257 - if( $grid->filter_show_empty() ) {
258 - foreach( $taxonomies as $taxonomy ) {
259 - $terms = get_terms( $taxonomy, array(
260 - 'hide_empty' => false,
261 - ) );
262 -
263 - foreach( $terms as $term ) {
264 - // Check if terms are being limited
265 - if( $grid->filter_limit() ) {
266 - if( $grid->filter_limit_exclude() ) {
267 - if( isset( $limit_terms[$taxonomy] ) && in_array( $term->term_id, $limit_terms[$taxonomy] ) ) continue;
268 - } else {
269 - if( !isset( $limit_terms[$taxonomy] ) || !in_array( $term->term_id, $limit_terms[$taxonomy] ) ) continue;
270 - }
271 - }
272 -
273 - $slug = urldecode( $term->slug );
274 -
275 - if( !isset( $posts_per_term[$taxonomy][$slug] ) ) $posts_per_term[$taxonomy][$slug] = array();
276 -
277 - if( !array_key_exists( $slug, $filter_terms ) ) {
278 - // Filter terms
279 - $filter_terms[$slug] = array(
280 - 'taxonomy' => $taxonomy,
281 - 'name' => $term->name,
282 - 'count' => 0,
283 - );
284 - }
285 - }
286 - }
287 - }
288 -
289 246 $cache['taxonomies'] = $posts_per_term;
290 247 $cache['terms'] = $terms_per_post;
291 248
292 249 // Generate Filter
@@ -291,9 +248,9 @@
291 248
292 249 // Generate Filter
293 250 $filter = '';
294 251
295 - if( count( $filter_terms ) > 0 && ($grid->filter_type() == 'isotope' ) || $grid->filter_type() == 'text_isotope') {
252 + if( count( $filter_terms ) > 0 && $grid->filter_type() == 'isotope' ) {
296 253 $filter_style = $grid->filter_style();
297 254
298 255 // All Button
299 256 if( $filter_style['isotope']['all_button_text'] ) {
@@ -299,36 +256,10 @@
299 256 if( $filter_style['isotope']['all_button_text'] ) {
300 257 $filter .= '<div class="wpupg-filter-item wpupg-filter-isotope-term wpupg-filter-tag- active">' . $filter_style['isotope']['all_button_text'] . '</div>';
301 258 }
302 259
303 - $filter_terms_order = array();
304 -
305 - if( $filter_style['isotope']['term_order'] == 'alphabetical_taxonomies' || $filter_style['isotope']['term_order'] == 'reverse_alphabetical_taxonomies' ) {
306 - // Order alphatically per taxonomy
307 - $terms_per_taxonomy = array();
308 -
309 - foreach( $filter_terms as $slug => $term ) {
310 - $taxonomy = $term['taxonomy'];
311 - if( !array_key_exists( $taxonomy, $terms_per_taxonomy ) ) {
312 - $terms_per_taxonomy[$taxonomy] = array();
313 - }
314 - $terms_per_taxonomy[$taxonomy][] = $slug;
315 - }
316 -
317 - foreach( $terms_per_taxonomy as $taxonomy => $terms ) {
318 - sort( $terms );
319 - $filter_terms_order = array_merge( $filter_terms_order, $terms );
320 - }
321 - } else {
322 - // Order alphabetically by default
323 - $filter_terms_order = array_keys( $filter_terms );
324 - sort( $filter_terms_order );
325 - }
326 -
327 - if( $filter_style['isotope']['term_order'] == 'reverse_alphabetical_taxonomies' || $filter_style['isotope']['term_order'] == 'reverse_alphabetical' ) {
328 - $filter_terms_order = array_reverse( $filter_terms_order );
329 - }
330 -
260 + $filter_terms_order = array_keys( $filter_terms );
261 + sort( $filter_terms_order );
331 262 $filter_terms_order = apply_filters( 'wpupg_grid_cache_filter_isotope_term_order', $filter_terms_order, $grid );
332 263
333 264 foreach( $filter_terms_order as $slug ) {
334 265 $options = isset( $filter_terms[$slug] ) ? $filter_terms[$slug] : false;
@@ -333,20 +264,10 @@
333 264 foreach( $filter_terms_order as $slug ) {
334 265 $options = isset( $filter_terms[$slug] ) ? $filter_terms[$slug] : false;
335 266
336 267 if( $options ) {
337 - if( $grid->filter_count() ) {
338 - $name = $options['name'] . ' (' . $options['count'] . ')';
339 - } else {
340 - $name = $options['name'];
341 - }
342 -
343 - $filter .= '<div class="wpupg-filter-item wpupg-filter-isotope-term wpupg-filter-isotope-term-' . $options['taxonomy'] . ' wpupg-filter-tag-' . $slug . '" data-taxonomy="' . $options['taxonomy'] . '" data-filter="' . $slug . '">' . $name . '</div>';
268 + $filter .= '<div class="wpupg-filter-item wpupg-filter-isotope-term wpupg-filter-tag-' . $slug . '" data-taxonomy="' . $options['taxonomy'] . '" data-filter="' . $slug . '">' . $options['name'] . '</div>';
344 269 }
345 - }
346 -
347 - if( $grid->filter_type() == 'text_isotope' && WPUltimatePostGrid::is_addon_active('filter-text') ) {
348 - $filter .= WPUltimatePostGrid::addon('filter-text')->get_filter( $grid );
349 270 }
350 271 }
351 272
352 273 // Update Metadata