| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPFNL compatibility class |
| 4 |
* |
| 5 |
* @package |
| 6 |
*/ |
| 7 |
namespace WPFunnels\Compatibility; |
| 8 |
|
| 9 |
use WPFunnels\Traits\SingletonTrait; |
| 10 |
|
| 11 |
/** |
| 12 |
* Class Wpfnl_Compatibility |
| 13 |
*/ |
| 14 |
class Wpfnl_Theme_Compatibility { |
| 15 |
|
| 16 |
use SingletonTrait; |
| 17 |
|
| 18 |
|
| 19 |
/** |
| 20 |
* Check is compatible theme enabled |
| 21 |
* |
| 22 |
* @return mixed|void |
| 23 |
*/ |
| 24 |
public function is_compatible_theme_enabled() { |
| 25 |
$theme = wp_get_theme(); |
| 26 |
$is_compatible = false; |
| 27 |
if ( $this->is_storefront_theme_enabled( $theme ) || $this->is_astra_theme_enabled( $theme ) ) { |
| 28 |
$is_compatible = true; |
| 29 |
} |
| 30 |
|
| 31 |
return apply_filters( 'wpfunnels/is_compatible_theme', $is_compatible ); |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
/** |
| 36 |
* Storfront theme checking |
| 37 |
* |
| 38 |
* @param $theme |
| 39 |
* |
| 40 |
* @return bool |
| 41 |
*/ |
| 42 |
private function is_storefront_theme_enabled( $theme ) { |
| 43 |
if ( ! $theme ) { |
| 44 |
$theme = wp_get_theme(); |
| 45 |
} |
| 46 |
if ( 'Storefront' == $theme->name || 'Storefront' == $theme->parent_theme ) { |
| 47 |
return true; |
| 48 |
} |
| 49 |
return false; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
/** |
| 54 |
* Astra theme checking |
| 55 |
* |
| 56 |
* @param $theme |
| 57 |
* |
| 58 |
* @return bool |
| 59 |
*/ |
| 60 |
private function is_astra_theme_enabled( $theme ) { |
| 61 |
if ( ! $theme ) { |
| 62 |
$theme = wp_get_theme(); |
| 63 |
} |
| 64 |
if ( 'Astra' == $theme->name || 'Astra' == $theme->parent_theme ) { |
| 65 |
return true; |
| 66 |
} |
| 67 |
return false; |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Check if the view is builder preview or not |
| 72 |
* |
| 73 |
* @return bool |
| 74 |
*/ |
| 75 |
public function is_builder_preview() { |
| 76 |
if( $this->is_elementor_preview() ) { |
| 77 |
return true; |
| 78 |
} |
| 79 |
return false; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
/** |
| 84 |
* Check if this is elementor preview |
| 85 |
* |
| 86 |
* @return bool |
| 87 |
*/ |
| 88 |
public function is_elementor_preview() { |
| 89 |
if ( class_exists( '\Elementor\Plugin' ) ) { |
| 90 |
$preview = \Elementor\Plugin::$instance->preview; |
| 91 |
if ( $preview && $preview->is_preview_mode() ) { |
| 92 |
return true; |
| 93 |
} |
| 94 |
} |
| 95 |
return false; |
| 96 |
} |
| 97 |
} |
| 98 |
|