| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elementor compatibility controller. |
| 4 |
* |
| 5 |
* @package ContentControl\Admin |
| 6 |
* @copyright (c) 2023 Code Atlantic LLC |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace ContentControl\Controllers\Compatibility; |
| 10 |
|
| 11 |
use ContentControl\Base\Controller; |
| 12 |
|
| 13 |
/** |
| 14 |
* Elementor controller class. |
| 15 |
*/ |
| 16 |
class Elementor extends Controller { |
| 17 |
|
| 18 |
/** |
| 19 |
* Initialize widget editor UX. |
| 20 |
* |
| 21 |
* @return void |
| 22 |
*/ |
| 23 |
public function init() { |
| 24 |
add_filter( 'content_control/protection_is_disabled', [ $this, 'protection_is_disabled' ] ); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Conditionally disable Content Control for Elementor builder. |
| 29 |
* |
| 30 |
* @param boolean $protection_is_disabled Whether protection is disabled. |
| 31 |
* @return boolean |
| 32 |
*/ |
| 33 |
public function protection_is_disabled( $protection_is_disabled ) { |
| 34 |
if ( did_action( 'elementor/loaded' ) && $this->elementor_builder_is_active() ) { |
| 35 |
return true; |
| 36 |
} |
| 37 |
|
| 38 |
return $protection_is_disabled; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Check if Elementor builder is active. |
| 43 |
* |
| 44 |
* @return boolean |
| 45 |
*/ |
| 46 |
public function elementor_builder_is_active() { |
| 47 |
return class_exists( '\Elementor\Plugin' ) && |
| 48 |
isset( \Elementor\Plugin::$instance ) && |
| 49 |
isset( \Elementor\Plugin::$instance->preview ) && |
| 50 |
method_exists( \Elementor\Plugin::$instance->preview, 'is_preview_mode' ) && |
| 51 |
\Elementor\Plugin::$instance->preview->is_preview_mode(); |
| 52 |
} |
| 53 |
} |
| 54 |
|