| 1 |
<?php |
| 2 |
namespace Easyel\EasyElements\Extensions\ExtensionHook; |
| 3 |
use Easyel\EasyElements\Extensions\ExtensionHook\HookControl; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 6 |
|
| 7 |
class ExtensionModule { |
| 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 |
add_action( |
| 22 |
'elementor/element/container/section_layout/after_section_end', |
| 23 |
array( $this, 'register_extension_sections' ), |
| 24 |
10, |
| 25 |
2 |
| 26 |
); |
| 27 |
|
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Register multiple extension sections in a DRY way |
| 32 |
*/ |
| 33 |
public function register_extension_sections( $element, $args ) { |
| 34 |
|
| 35 |
$sections = [ |
| 36 |
'scroll_trigger' => [ |
| 37 |
'label' => __('ScrollTrigger', 'easy-elements'), |
| 38 |
'promo_key' => 'scroll_trigger_html_promo', |
| 39 |
], |
| 40 |
'cursor_move' => [ |
| 41 |
'label' => __('Cursor Move Effect', 'easy-elements'), |
| 42 |
'promo_key' => 'scroll_cursor_move_html_promo', |
| 43 |
], |
| 44 |
'sticky_elements' => [ |
| 45 |
'label' => __('Sticky Elements', 'easy-elements'), |
| 46 |
'promo_key' => 'sticky_elements_html_promo', |
| 47 |
|
| 48 |
], |
| 49 |
'background_parallax' => [ |
| 50 |
'label' => __('Background Parallax', 'easy-elements'), |
| 51 |
'promo_key' => 'background_parallax_html_promo', |
| 52 |
], |
| 53 |
'cursor_hover' => [ |
| 54 |
'label' => __('Cursor Hover Effect', 'easy-elements'), |
| 55 |
'promo_key' => 'cursor_move_hover_html_promo', |
| 56 |
], |
| 57 |
]; |
| 58 |
|
| 59 |
foreach( $sections as $id => $section ) { |
| 60 |
|
| 61 |
if ( in_array( $id, [ 'cursor_hover', 'cursor_move','scroll_trigger','background_parallax','sticky_elements' ], true ) && class_exists( 'Easy_Elements_Pro' ) ) { |
| 62 |
continue; |
| 63 |
} |
| 64 |
|
| 65 |
$element->start_controls_section( |
| 66 |
"id_{$id}_section", |
| 67 |
[ |
| 68 |
'label' => EASY_EXTENSION_BADGE . $section['label'], |
| 69 |
'tab' => \Elementor\Controls_Manager::TAB_ADVANCED, |
| 70 |
] |
| 71 |
); |
| 72 |
|
| 73 |
if ( ! class_exists( 'Easy_Elements_Pro' ) ) { |
| 74 |
HookControl::register_controls( $element, $section['promo_key'] ); |
| 75 |
} |
| 76 |
|
| 77 |
$element->end_controls_section(); |
| 78 |
} |
| 79 |
|
| 80 |
} |
| 81 |
} |