| 1 |
<?php |
| 2 |
|
| 3 |
namespace HelloPlus\Modules\Content; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly. |
| 7 |
} |
| 8 |
|
| 9 |
use Elementor\Controls_Manager; |
| 10 |
use HelloPlus\Includes\Module_Base; |
| 11 |
use HelloPlus\Includes\Utils; |
| 12 |
use HelloPlus\Modules\Content\Classes\Control_Zig_Zag_Animation; |
| 13 |
use HelloPlus\Modules\Content\Classes\Choose_Img_Control; |
| 14 |
|
| 15 |
/** |
| 16 |
* class Module |
| 17 |
**/ |
| 18 |
class Module extends Module_Base { |
| 19 |
|
| 20 |
/** |
| 21 |
* @inheritDoc |
| 22 |
*/ |
| 23 |
public static function get_name(): string { |
| 24 |
return 'content'; |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* @inheritDoc |
| 29 |
*/ |
| 30 |
protected function get_component_ids(): array { |
| 31 |
return []; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* @inheritDoc |
| 36 |
*/ |
| 37 |
protected function get_widget_ids(): array { |
| 38 |
return [ |
| 39 |
'Zig_Zag', |
| 40 |
'Hero', |
| 41 |
'CTA', |
| 42 |
'Flex_Hero', |
| 43 |
'Contact', |
| 44 |
]; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* @return void |
| 49 |
*/ |
| 50 |
public function register_scripts() { |
| 51 |
wp_register_script( |
| 52 |
'helloplus-zigzag-fe', |
| 53 |
HELLOPLUS_SCRIPTS_URL . 'helloplus-zigzag-fe.js', |
| 54 |
[ 'elementor-frontend' ], |
| 55 |
HELLOPLUS_VERSION, |
| 56 |
true |
| 57 |
); |
| 58 |
} |
| 59 |
|
| 60 |
public function register_styles(): void { |
| 61 |
wp_register_style( |
| 62 |
'helloplus-zigzag', |
| 63 |
HELLOPLUS_STYLE_URL . 'helloplus-zigzag.css', |
| 64 |
[ 'elementor-frontend' ], |
| 65 |
HELLOPLUS_VERSION |
| 66 |
); |
| 67 |
|
| 68 |
wp_register_style( |
| 69 |
'helloplus-hero', |
| 70 |
HELLOPLUS_STYLE_URL . 'helloplus-hero.css', |
| 71 |
[ 'elementor-frontend' ], |
| 72 |
HELLOPLUS_VERSION |
| 73 |
); |
| 74 |
|
| 75 |
wp_register_style( |
| 76 |
'helloplus-cta', |
| 77 |
HELLOPLUS_STYLE_URL . 'helloplus-cta.css', |
| 78 |
[ 'elementor-frontend' ], |
| 79 |
HELLOPLUS_VERSION |
| 80 |
); |
| 81 |
|
| 82 |
wp_register_style( |
| 83 |
'helloplus-flex-hero', |
| 84 |
HELLOPLUS_STYLE_URL . 'helloplus-flex-hero.css', |
| 85 |
[ 'elementor-frontend' ], |
| 86 |
HELLOPLUS_VERSION |
| 87 |
); |
| 88 |
|
| 89 |
wp_register_style( |
| 90 |
'helloplus-contact', |
| 91 |
HELLOPLUS_STYLE_URL . 'helloplus-contact.css', |
| 92 |
[ 'elementor-frontend' ], |
| 93 |
HELLOPLUS_VERSION |
| 94 |
); |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* Load the Module only if Elementor is active. |
| 99 |
* |
| 100 |
* @return bool |
| 101 |
*/ |
| 102 |
public static function is_active(): bool { |
| 103 |
return Utils::is_elementor_active(); |
| 104 |
} |
| 105 |
|
| 106 |
public function register_controls( Controls_Manager $controls_manager ) { |
| 107 |
$controls_manager->register( new Control_Zig_Zag_Animation() ); |
| 108 |
$controls_manager->register( new Choose_Img_Control() ); |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
public function enqueue_editor_styles() { |
| 113 |
wp_enqueue_style( |
| 114 |
'helloplus-control-choose-img', |
| 115 |
HELLOPLUS_STYLE_URL . 'helloplus-control-choose-img.css', |
| 116 |
[], |
| 117 |
HELLOPLUS_VERSION |
| 118 |
); |
| 119 |
} |
| 120 |
|
| 121 |
public function enqueue_editor_scripts() { |
| 122 |
wp_enqueue_script( |
| 123 |
'helloplus-control-choose-img', |
| 124 |
HELLOPLUS_SCRIPTS_URL . 'helloplus-control-choose-img.js', |
| 125 |
[], |
| 126 |
HELLOPLUS_VERSION, |
| 127 |
true |
| 128 |
); |
| 129 |
} |
| 130 |
|
| 131 |
|
| 132 |
protected function register_hooks(): void { |
| 133 |
parent::register_hooks(); |
| 134 |
add_action( 'elementor/frontend/after_register_scripts', [ $this, 'register_scripts' ] ); |
| 135 |
add_action( 'elementor/frontend/after_register_styles', [ $this, 'register_styles' ] ); |
| 136 |
add_action( 'elementor/controls/register', [ $this, 'register_controls' ] ); |
| 137 |
add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'enqueue_editor_styles' ] ); |
| 138 |
add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'enqueue_editor_scripts' ] ); |
| 139 |
} |
| 140 |
} |
| 141 |
|