| 1 |
<?php |
| 2 |
/** |
| 3 |
* Thrive Visual Editor Compatibility |
| 4 |
* |
| 5 |
* @package CartFlows |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Class for Thrive Visual Editor Compatibility |
| 10 |
*/ |
| 11 |
class Cartflows_Thrive_Compatibility { |
| 12 |
|
| 13 |
/** |
| 14 |
* Member Variable |
| 15 |
* |
| 16 |
* @var instance |
| 17 |
*/ |
| 18 |
private static $instance; |
| 19 |
|
| 20 |
/** |
| 21 |
* Initiator |
| 22 |
*/ |
| 23 |
public static function get_instance() { |
| 24 |
if ( ! isset( self::$instance ) ) { |
| 25 |
self::$instance = new self; |
| 26 |
} |
| 27 |
return self::$instance; |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Constructor |
| 32 |
*/ |
| 33 |
public function __construct() { |
| 34 |
|
| 35 |
// Add CartFlows post type in the thrive page editor. |
| 36 |
add_filter( 'tve_post_type_can_use_landing_page', array( $this, 'send_post_type_to_thrive' ) ); |
| 37 |
|
| 38 |
// add_filter( 'tve_landing_page_post_types', array( $this, 'send_post_type_to_thrive' ) );. |
| 39 |
add_filter( 'tcb_can_use_landing_pages', array( $this, 'display_change_template_option' ) ); |
| 40 |
|
| 41 |
add_filter( 'tcb_has_templates_tab', array( $this, 'display_change_template_option' ) ); |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Return step post type for Thrive Architect. |
| 46 |
* |
| 47 |
* @since 1.0.0 |
| 48 |
* @param array $post_type_pt the current step post type. |
| 49 |
* @return array $post_type_pt current step post type. |
| 50 |
*/ |
| 51 |
function send_post_type_to_thrive( $post_type_pt ) { |
| 52 |
|
| 53 |
$post_type_pt[] = CARTFLOWS_STEP_POST_TYPE; |
| 54 |
|
| 55 |
return $post_type_pt; |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Return true/false to show change template option. |
| 60 |
* |
| 61 |
* @since 1.0.0 |
| 62 |
* @param array $bool true/false. |
| 63 |
* @return array $bool true/false. |
| 64 |
*/ |
| 65 |
function display_change_template_option( $bool ) { |
| 66 |
|
| 67 |
if ( wcf()->utils->is_step_post_type() ) { |
| 68 |
$bool = true; |
| 69 |
} |
| 70 |
return $bool; |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Kicking this off by calling 'get_instance()' method |
| 76 |
*/ |
| 77 |
Cartflows_Thrive_Compatibility::get_instance(); |
| 78 |
|