| @@ -3,31 +3,11 @@ | ||
| 3 | 3 | class WPUPG_Content { |
| 4 | 4 | |
| 5 | 5 | public function __construct() |
| 6 | 6 | { |
| 7 | - add_filter( 'the_content', array( $this, 'prefilter_grid' ), 1 ); | |
| 8 | 7 | add_filter( 'the_content', array( $this, 'content_filter' ), 10 ); |
| 9 | 8 | } |
| 10 | 9 | |
| 11 | - public function prefilter_grid( $content ) | |
| 12 | - { | |
| 13 | - $pattern = get_shortcode_regex( array( 'wpupg-grid' ) ); | |
| 14 | - | |
| 15 | - if ( preg_match_all( '/' . $pattern . '/s', $content, $matches ) && array_key_exists( 2, $matches ) ) { | |
| 16 | - foreach ( $matches[2] as $key => $value ) { | |
| 17 | - if ( 'wpupg-grid' === $value ) { | |
| 18 | - $grid_shortcode = $matches[0][ $key ]; | |
| 19 | - $grid_shortcode = str_ireplace( '[wpupg-grid ', '[wpupg-grid wpupg_no_output="1" ', $grid_shortcode ); | |
| 20 | - | |
| 21 | - // This forces a prefilter of the grid without actual output. | |
| 22 | - do_shortcode( $grid_shortcode ); | |
| 23 | - } | |
| 24 | - } | |
| 25 | - } | |
| 26 | - | |
| 27 | - return $content; | |
| 28 | - } | |
| 29 | - | |
| 30 | 10 | public function content_filter( $content ) |
| 31 | 11 | { |
| 32 | 12 | $ignore_query = !is_main_query(); |
| 33 | 13 | if ( apply_filters( 'wpupg_content_loop_check', $ignore_query ) ) { |
| @@ -36,9 +16,9 @@ | ||
| 36 | 16 | |
| 37 | 17 | if ( get_post_type() == WPUPG_POST_TYPE ) { |
| 38 | 18 | remove_filter( 'the_content', array( $this, 'content_filter' ), 10 ); |
| 39 | 19 | |
| 40 | - $grid = WPUPG_Grid_Manager::get( get_post() ); | |
| 20 | + $grid = new WPUPG_Grid( get_post() ); | |
| 41 | 21 | |
| 42 | 22 | $content .= '[wpupg-filter id="' . $grid->slug() . '"]'; |
| 43 | 23 | $content .= '[wpupg-grid id="' . $grid->slug() . '"]'; |
| 44 | 24 | |