| 1 |
<?php |
| 2 |
namespace Easyel\EasyElements\Extensions\VisibilityControl; |
| 3 |
use Easyel\EasyElements\Extensions\ExtensionHook\HookControl; |
| 4 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 5 |
|
| 6 |
|
| 7 |
class VisibilityModule { |
| 8 |
|
| 9 |
private static $instance = null; |
| 10 |
|
| 11 |
private $prefix = 'easy_'; |
| 12 |
|
| 13 |
public static function get_instance() { |
| 14 |
if ( self::$instance === null ) { |
| 15 |
self::$instance = new self(); |
| 16 |
} |
| 17 |
return self::$instance; |
| 18 |
} |
| 19 |
|
| 20 |
private function __construct() { |
| 21 |
|
| 22 |
add_action('elementor/element/common/_section_style/after_section_end', [ $this, 'easy_register_section'] ); |
| 23 |
add_action('elementor/element/section/section_advanced/after_section_end', [ $this, 'easy_register_section'] ); |
| 24 |
add_action('elementor/element/common/easy_visibility_section/before_section_end', [ $this, 'easy_register_controls'], 10, 2 ); |
| 25 |
add_action('elementor/element/section/easy_visibility_section/before_section_end', [ $this, 'easy_register_controls'], 10, 2 ); |
| 26 |
|
| 27 |
add_action('elementor/element/container/section_layout/after_section_end', [ $this, 'easy_register_section'] ); |
| 28 |
|
| 29 |
add_action('elementor/element/container/easy_visibility_section/before_section_end', [ $this, 'easy_register_controls'], 10, 2 ); |
| 30 |
|
| 31 |
} |
| 32 |
|
| 33 |
public function easy_register_section( $element ) { |
| 34 |
if ( function_exists( 'easyel_element_is_enabled' ) && easyel_element_is_enabled( 'enable_visibility_control' ) || ! easyel_premium_addon_active() ) { |
| 35 |
$element->start_controls_section( |
| 36 |
'easy_visibility_section', |
| 37 |
[ |
| 38 |
'label' => EASYEL_EXTENSION_BADGE . __( 'Visibility Control', 'easy-elements' ), |
| 39 |
'tab' => \Elementor\Controls_Manager::TAB_ADVANCED, |
| 40 |
] |
| 41 |
); |
| 42 |
|
| 43 |
$element->end_controls_section(); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Register visibility controls in Elementor panel |
| 49 |
*/ |
| 50 |
public function easy_register_controls( $element, $args ) { |
| 51 |
|
| 52 |
if ( ! easyel_premium_addon_active() ) { |
| 53 |
|
| 54 |
HookControl::register_controls( $element ,"easyel_visibility_control_sec"); |
| 55 |
} else { |
| 56 |
if ( did_action( 'plugins_loaded' ) && function_exists( 'easyel_element_is_enabled' ) && easyel_element_is_enabled( 'enable_visibility_control' ) ) { |
| 57 |
$pro_version = easyel_get_pro_clean_version(); |
| 58 |
if ( |
| 59 |
$pro_version && |
| 60 |
version_compare( $pro_version, '1.0.8', '>=' ) |
| 61 |
) { |
| 62 |
if( class_exists( '\EasyElements_Elementor\Pro\Extension\VisibilityControl\VisibilityControlPro' ) ) { |
| 63 |
\EasyElements_Elementor\Pro\Extension\VisibilityControl\VisibilityControlPro::get_instance()->easy_add_visibility_section_control( $element, $args ); |
| 64 |
} |
| 65 |
|
| 66 |
} else { |
| 67 |
\Easy_Visibility_Module_Pro::easy_add_visibility_section_control( $element, $args ); |
| 68 |
} |
| 69 |
|
| 70 |
} |
| 71 |
} |
| 72 |
} |
| 73 |
} |