| @@ -22,9 +22,8 @@ | ||
| 22 | 22 | 'wpupg_layout_mode', |
| 23 | 23 | 'wpupg_limit_terms', |
| 24 | 24 | 'wpupg_limit_posts', |
| 25 | 25 | 'wpupg_limit_posts_number', |
| 26 | - 'wpupg_limit_posts_offset', | |
| 27 | 26 | 'wpupg_link_target', |
| 28 | 27 | 'wpupg_link_type', |
| 29 | 28 | 'wpupg_order_by', |
| 30 | 29 | 'wpupg_order', |
| @@ -101,10 +100,8 @@ | ||
| 101 | 100 | 'placeholder_text' => '', |
| 102 | 101 | ), |
| 103 | 102 | ); |
| 104 | 103 | |
| 105 | - private $dynamically_generated = false; | |
| 106 | - | |
| 107 | 104 | public function __construct( $post ) |
| 108 | 105 | { |
| 109 | 106 | // Get associated post |
| 110 | 107 | if( is_object( $post ) && $post instanceof WP_Post ) { |
| @@ -121,17 +118,8 @@ | ||
| 121 | 118 | // Defaults with expressions |
| 122 | 119 | $this->filter_style_fields['isotope']['all_button_text'] = __( 'All', 'wp-ultimate-post-grid' ); |
| 123 | 120 | } |
| 124 | 121 | |
| 125 | - public function regenerate() | |
| 126 | - { | |
| 127 | - $generated = WPUltimatePostGrid::get()->helper( 'grid_cache' )->dynamic_generate( $this ); | |
| 128 | - | |
| 129 | - $this->dynamically_generated = true; | |
| 130 | - $this->meta['wpupg_posts'][0] = serialize( $generated['cache'] ); | |
| 131 | - $this->meta['wpupg_filter'][0] = $generated['filter']; | |
| 132 | - } | |
| 133 | - | |
| 134 | 122 | public function is_present( $field ) |
| 135 | 123 | { |
| 136 | 124 | switch( $field ) { |
| 137 | 125 | default: |
| @@ -183,14 +171,9 @@ | ||
| 183 | 171 | return $this->meta( 'wpupg_empty_message' ); |
| 184 | 172 | } |
| 185 | 173 | |
| 186 | 174 | public function filter() |
| 187 | - { | |
| 188 | - // No cache mode. | |
| 189 | - if ( false === $this->dynamically_generated && WPUltimatePostGrid::option( 'use_cache', '1' ) !== '1' ) { | |
| 190 | - $this->regenerate(); | |
| 191 | - } | |
| 192 | - | |
| 175 | + { | |
| 193 | 176 | return $this->meta( 'wpupg_filter' ); |
| 194 | 177 | } |
| 195 | 178 | |
| 196 | 179 | public function filter_taxonomies() |
| @@ -319,13 +302,8 @@ | ||
| 319 | 302 | $limit = intval( $this->meta( 'wpupg_limit_posts_number' ) ); |
| 320 | 303 | return $limit > 0 ? $limit : ''; |
| 321 | 304 | } |
| 322 | 305 | |
| 323 | - public function limit_posts_offset() | |
| 324 | - { | |
| 325 | - return intval( $this->meta( 'wpupg_limit_posts_offset' ) ); | |
| 326 | - } | |
| 327 | - | |
| 328 | 306 | public function limit_rules() |
| 329 | 307 | { |
| 330 | 308 | $limit_rules = maybe_unserialize( $this->meta( 'wpupg_limit_rules' ) ); |
| 331 | 309 | return is_array( $limit_rules ) ? $limit_rules : array(); |
| @@ -393,13 +371,8 @@ | ||
| 393 | 371 | } |
| 394 | 372 | |
| 395 | 373 | public function posts() |
| 396 | 374 | { |
| 397 | - // No cache mode. | |
| 398 | - if ( false === $this->dynamically_generated && WPUltimatePostGrid::option( 'use_cache', '1' ) !== '1' ) { | |
| 399 | - $this->regenerate(); | |
| 400 | - } | |
| 401 | - | |
| 402 | 375 | $posts = maybe_unserialize( $this->meta( 'wpupg_posts' ) ); |
| 403 | 376 | return is_array( $posts ) ? $posts : array(); |
| 404 | 377 | } |
| 405 | 378 | |
| @@ -477,25 +450,20 @@ | ||
| 477 | 450 | |
| 478 | 451 | public function set_dynamic_rules( $dynamic_rules ) |
| 479 | 452 | { |
| 480 | 453 | if( WPUltimatePostGrid::is_premium_active() ) { |
| 481 | - if ( $this->type() == 'terms' ) { | |
| 482 | - $this->meta['wpupg_limit_terms'][0] = 'on'; | |
| 483 | - $this->meta['wpupg_limit_terms_type'][0] = $dynamic_rules['type']; | |
| 484 | - $this->meta['wpupg_limit_terms_terms'][0] = serialize( $dynamic_rules['values'] ); | |
| 485 | - } else { | |
| 486 | - if ( ! $this->dynamically_generated ) { | |
| 487 | - $this->meta['wpupg_limit_posts'][0] = 'on'; | |
| 454 | + $this->meta['wpupg_limit_posts'][0] = 'on'; | |
| 488 | 455 | |
| 489 | - $limit_rules = maybe_unserialize( $this->meta( 'wpupg_limit_rules' ) ); | |
| 490 | - $limit_rules = is_array( $limit_rules ) ? $limit_rules : array(); | |
| 456 | + $limit_rules = maybe_unserialize( $this->meta( 'wpupg_limit_rules' ) ); | |
| 457 | + $limit_rules = is_array( $limit_rules ) ? $limit_rules : array(); | |
| 491 | 458 | |
| 492 | - $new_rules = array_merge( $limit_rules, $dynamic_rules ); | |
| 493 | - $this->meta['wpupg_limit_rules'][0] = serialize( $new_rules ); | |
| 459 | + $new_rules = array_merge( $limit_rules, $dynamic_rules ); | |
| 460 | + $this->meta['wpupg_limit_rules'][0] = serialize( $new_rules ); | |
| 494 | 461 | |
| 495 | - $this->regenerate(); | |
| 496 | - } | |
| 497 | - } | |
| 462 | + $generated = WPUltimatePostGrid::get()->helper( 'grid_cache' )->dynamic_generate( $this ); | |
| 463 | + | |
| 464 | + $this->meta['wpupg_posts'][0] = serialize( $generated['cache'] ); | |
| 465 | + $this->meta['wpupg_filter'][0] = $generated['filter']; | |
| 498 | 466 | } |
| 499 | 467 | } |
| 500 | 468 | |
| 501 | 469 | public function get_posts( $page = 0, $post_ids = null ) |