| 1 |
<?php |
| 2 |
/** |
| 3 |
* ConvertKit Uncode Theme Integration. |
| 4 |
* |
| 5 |
* @package ConvertKit |
| 6 |
* @author ConvertKit |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Adds compatibility with the Uncode theme by using |
| 11 |
* Uncode's specific hooks for outputting Forms and |
| 12 |
* Restrict Content functionality. |
| 13 |
* |
| 14 |
* @since 2.7.7 |
| 15 |
*/ |
| 16 |
class ConvertKit_Uncode { |
| 17 |
|
| 18 |
/** |
| 19 |
* Constructor. Registers actions and filters to possibly limit output of a Page/Post/CPT's |
| 20 |
* content on the frontend site. |
| 21 |
* |
| 22 |
* @since 2.7.7 |
| 23 |
*/ |
| 24 |
public function __construct() { |
| 25 |
|
| 26 |
add_action( 'convertkit_restrict_content_register_content_filter', array( $this, 'maybe_register_restrict_content_filter' ) ); |
| 27 |
|
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Registers the content filter if the Uncode theme is active |
| 32 |
* and the Page is using the Visual Composer Page Builder. |
| 33 |
* |
| 34 |
* @since 2.7.7 |
| 35 |
*/ |
| 36 |
public function maybe_register_restrict_content_filter() { |
| 37 |
|
| 38 |
// Don't register a different filter if the Uncode theme is not active. |
| 39 |
if ( ! function_exists( 'uncode_the_content' ) ) { |
| 40 |
return; |
| 41 |
} |
| 42 |
if ( ! function_exists( 'vc_is_page_editable' ) ) { |
| 43 |
return; |
| 44 |
} |
| 45 |
|
| 46 |
// Don't register a different filter if the Page is not using the Visual Composer Page Builder. |
| 47 |
$the_content = uncode_get_the_content(); // @phpstan-ignore-line |
| 48 |
if ( strpos( $the_content, '[vc_row' ) === false ) { |
| 49 |
return; |
| 50 |
} |
| 51 |
|
| 52 |
// If here, the Page is using the Visual Composer Page Builder, so we need to use a different content filter |
| 53 |
// to correctly restrict content. |
| 54 |
add_filter( 'uncode_the_content', array( WP_ConvertKit()->get_class( 'output_restrict_content' ), 'maybe_restrict_content' ) ); |
| 55 |
remove_filter( 'the_content', array( WP_ConvertKit()->get_class( 'output_restrict_content' ), 'maybe_restrict_content' ) ); |
| 56 |
|
| 57 |
} |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
new ConvertKit_Uncode(); |
| 62 |
|