wpfunnels
/
includes
/
core
/
widgets
/
divi-modules
/
classes
/
class-wpfnl-divi-theme-compatibility.php
class-wpfnl-divi-theme-compatibility.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.12.1, at includes/core/widgets/divi-modules/classes/class-wpfnl-divi-theme-compatibility.php
| 1 | <?php |
| 2 | /** |
| 3 | * Theme compattability |
| 4 | * |
| 5 | * @package |
| 6 | */ |
| 7 | if ( ! defined( 'ABSPATH' ) ) { |
| 8 | // Exit if accessed directly. |
| 9 | exit; |
| 10 | } |
| 11 | |
| 12 | class Wpfnl_Divi_Theme_Compatibility extends ET_Builder_Plugin_Compat_Base { |
| 13 | /** |
| 14 | * Constructor. |
| 15 | * |
| 16 | * @since 2.3.4 |
| 17 | */ |
| 18 | public function __construct() { |
| 19 | $this->plugin_id = 'wpfunnels/wpfnl.php'; |
| 20 | $this->init_hooks(); |
| 21 | } |
| 22 | /** |
| 23 | * Hook methods to WordPress. |
| 24 | * |
| 25 | * @since 2.3.4 |
| 26 | * |
| 27 | * @return void |
| 28 | */ |
| 29 | public function init_hooks() { |
| 30 | // Bail if there's no version found. |
| 31 | if ( ! $this->get_plugin_version() ) { |
| 32 | return; |
| 33 | } |
| 34 | add_action( 'wp', array( $this, 'maybe_disable_theme_builder' ), 9 ); |
| 35 | } |
| 36 | /** |
| 37 | * Disable theme builder for specific Wpfunnels templates that don't use |
| 38 | * the normal WordPress partials (get_header(), get_footer()). |
| 39 | * |
| 40 | * @since 2.3.4 |
| 41 | */ |
| 42 | public function maybe_disable_theme_builder() { |
| 43 | $step_post_type = defined( 'WPFNL_STEPS_POST_TYPE' ) ? WPFNL_STEPS_POST_TYPE : 'wpfunnel_steps'; |
| 44 | |
| 45 | if ( is_singular( $step_post_type ) ) { |
| 46 | /** |
| 47 | * Filters page templates that should have the Theme Builder disabled. |
| 48 | * |
| 49 | * @param string[] $templates |
| 50 | * |
| 51 | * @since 2.3.4 |
| 52 | */ |
| 53 | $disable_for = apply_filters( 'et_builder_compatibility_wpfunnel_templates_without_theme_builder', array('wpfunnels_fullwidth_without_header_footer' ) ); |
| 54 | $template = get_post_meta( get_the_ID(), '_wp_page_template', true ); |
| 55 | |
| 56 | if ( in_array( $template, $disable_for, true ) ) { |
| 57 | add_filter( 'et_theme_builder_template_layouts', array( $this, 'disable_theme_builder' ) ); |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Disable theme builder for the current request by returning no layouts for it. |
| 64 | * |
| 65 | * @param array $layouts |
| 66 | * |
| 67 | * @return array |
| 68 | * @since 2.3.4 |
| 69 | */ |
| 70 | |
| 71 | public function disable_theme_builder( $layouts ) { |
| 72 | return array(); |
| 73 | } |
| 74 | } |
| 75 | new Wpfnl_Divi_Theme_Compatibility(); |
| 76 |