| 1 |
<?php |
| 2 |
|
| 3 |
class WPUPG_Content { |
| 4 |
|
| 5 |
public function __construct() |
| 6 |
{ |
| 7 |
add_filter( 'the_content', array( $this, 'content_filter' ), 10 ); |
| 8 |
} |
| 9 |
|
| 10 |
public function content_filter( $content ) |
| 11 |
{ |
| 12 |
$ignore_query = !is_main_query(); |
| 13 |
if ( apply_filters( 'wpupg_content_loop_check', $ignore_query ) ) { |
| 14 |
return $content; |
| 15 |
} |
| 16 |
|
| 17 |
if ( get_post_type() == WPUPG_POST_TYPE ) { |
| 18 |
remove_filter( 'the_content', array( $this, 'content_filter' ), 10 ); |
| 19 |
|
| 20 |
$grid = new WPUPG_Grid( get_post() ); |
| 21 |
|
| 22 |
$content .= '[wpupg-filter id="' . $grid->slug() . '"]'; |
| 23 |
$content .= '[wpupg-grid id="' . $grid->slug() . '"]'; |
| 24 |
|
| 25 |
add_filter( 'the_content', array( $this, 'content_filter' ), 10 ); |
| 26 |
} |
| 27 |
|
| 28 |
return $content; |
| 29 |
} |
| 30 |
} |