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