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 -94 2.5.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 {
@@ -152,13 +147,8 @@
152 147 $post_ids = array_map( 'intval', $posts );
153 148
154 149 $post_ids = apply_filters( 'wpupg_grid_cache_post_ids', $post_ids, $grid );
155 150
156 - // Offset posts
157 - if( $grid->limit_posts_offset() ) {
158 - $post_ids = array_slice($post_ids, $grid->limit_posts_offset() );
159 - }
160 -
161 151 // Limit Total # Posts
162 152 if( $grid->limit_posts_number() ) {
163 153 $post_ids = array_slice($post_ids, 0, $grid->limit_posts_number() );
164 154 }
@@ -241,18 +231,13 @@
241 231
242 232 // Terms per post
243 233 $post_taxonomy_term_ids[] = $slug;
244 234
245 - if( !array_key_exists( $slug, $filter_terms ) ) {
246 - // Filter terms
247 - $filter_terms[$slug] = array(
248 - 'taxonomy' => $taxonomy,
249 - 'name' => $term->name,
250 - 'count' => 1,
251 - );
252 - } else {
253 - $filter_terms[$slug]['count']++;
254 - }
235 + // Filter terms
236 + $filter_terms[$slug] = array(
237 + 'taxonomy' => $taxonomy,
238 + 'name' => $term->name,
239 + );
255 240 }
256 241
257 242 $terms_per_post[$post_id][$taxonomy] = $post_taxonomy_term_ids;
258 243 }
@@ -257,41 +242,8 @@
257 242 $terms_per_post[$post_id][$taxonomy] = $post_taxonomy_term_ids;
258 243 }
259 244 }
260 245
261 - // Show Empty Terms
262 - if( $grid->filter_show_empty() ) {
263 - foreach( $taxonomies as $taxonomy ) {
264 - $terms = get_terms( $taxonomy, array(
265 - 'hide_empty' => false,
266 - ) );
267 -
268 - foreach( $terms as $term ) {
269 - // Check if terms are being limited
270 - if( $grid->filter_limit() ) {
271 - if( $grid->filter_limit_exclude() ) {
272 - if( isset( $limit_terms[$taxonomy] ) && in_array( $term->term_id, $limit_terms[$taxonomy] ) ) continue;
273 - } else {
274 - if( !isset( $limit_terms[$taxonomy] ) || !in_array( $term->term_id, $limit_terms[$taxonomy] ) ) continue;
275 - }
276 - }
277 -
278 - $slug = urldecode( $term->slug );
279 -
280 - if( !isset( $posts_per_term[$taxonomy][$slug] ) ) $posts_per_term[$taxonomy][$slug] = array();
281 -
282 - if( !array_key_exists( $slug, $filter_terms ) ) {
283 - // Filter terms
284 - $filter_terms[$slug] = array(
285 - 'taxonomy' => $taxonomy,
286 - 'name' => $term->name,
287 - 'count' => 0,
288 - );
289 - }
290 - }
291 - }
292 - }
293 -
294 246 $cache['taxonomies'] = $posts_per_term;
295 247 $cache['terms'] = $terms_per_post;
296 248
297 249 // Generate Filter
@@ -296,9 +248,9 @@
296 248
297 249 // Generate Filter
298 250 $filter = '';
299 251
300 - if( count( $filter_terms ) > 0 && ($grid->filter_type() == 'isotope' ) || $grid->filter_type() == 'text_isotope') {
252 + if( count( $filter_terms ) > 0 && $grid->filter_type() == 'isotope' ) {
301 253 $filter_style = $grid->filter_style();
302 254
303 255 // All Button
304 256 if( $filter_style['isotope']['all_button_text'] ) {
@@ -304,36 +256,10 @@
304 256 if( $filter_style['isotope']['all_button_text'] ) {
305 257 $filter .= '<div class="wpupg-filter-item wpupg-filter-isotope-term wpupg-filter-tag- active">' . $filter_style['isotope']['all_button_text'] . '</div>';
306 258 }
307 259
308 - $filter_terms_order = array();
309 -
310 - if( $filter_style['isotope']['term_order'] == 'alphabetical_taxonomies' || $filter_style['isotope']['term_order'] == 'reverse_alphabetical_taxonomies' ) {
311 - // Order alphatically per taxonomy
312 - $terms_per_taxonomy = array();
313 -
314 - foreach( $filter_terms as $slug => $term ) {
315 - $taxonomy = $term['taxonomy'];
316 - if( !array_key_exists( $taxonomy, $terms_per_taxonomy ) ) {
317 - $terms_per_taxonomy[$taxonomy] = array();
318 - }
319 - $terms_per_taxonomy[$taxonomy][] = $slug;
320 - }
321 -
322 - foreach( $terms_per_taxonomy as $taxonomy => $terms ) {
323 - sort( $terms );
324 - $filter_terms_order = array_merge( $filter_terms_order, $terms );
325 - }
326 - } else {
327 - // Order alphabetically by default
328 - $filter_terms_order = array_keys( $filter_terms );
329 - sort( $filter_terms_order );
330 - }
331 -
332 - if( $filter_style['isotope']['term_order'] == 'reverse_alphabetical_taxonomies' || $filter_style['isotope']['term_order'] == 'reverse_alphabetical' ) {
333 - $filter_terms_order = array_reverse( $filter_terms_order );
334 - }
335 -
260 + $filter_terms_order = array_keys( $filter_terms );
261 + sort( $filter_terms_order );
336 262 $filter_terms_order = apply_filters( 'wpupg_grid_cache_filter_isotope_term_order', $filter_terms_order, $grid );
337 263
338 264 foreach( $filter_terms_order as $slug ) {
339 265 $options = isset( $filter_terms[$slug] ) ? $filter_terms[$slug] : false;
@@ -338,20 +264,10 @@
338 264 foreach( $filter_terms_order as $slug ) {
339 265 $options = isset( $filter_terms[$slug] ) ? $filter_terms[$slug] : false;
340 266
341 267 if( $options ) {
342 - if( $grid->filter_count() ) {
343 - $name = $options['name'] . ' (' . $options['count'] . ')';
344 - } else {
345 - $name = $options['name'];
346 - }
347 -
348 - $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>';
349 269 }
350 - }
351 -
352 - if( $grid->filter_type() == 'text_isotope' && WPUltimatePostGrid::is_addon_active('filter-text') ) {
353 - $filter .= WPUltimatePostGrid::addon('filter-text')->get_filter( $grid );
354 270 }
355 271 }
356 272
357 273 // Update Metadata