PluginProbe
Hello Plus / 1.4.0
Hello Plus v1.4.0
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7.0 1.7.1 1.7.2 1.7.3 All 30 releases
hello-plus / modules / template-parts / module.php

module.php in Hello Plus 1.4.0, at modules/template-parts/module.php

134 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 $settings = [
92 'isElementorDomain' => Utils::are_we_on_elementor_domains(),
93 ];
94
95 \wp_add_inline_script( 'helloplus-editor', 'const ehpTemplatePartsEditorSettings = ' . wp_json_encode( $settings ), 'before' );
96 }
97
98
99 /**
100 * @return void
101 */
102 public function enqueue_editor_styles(): void {
103 wp_enqueue_style(
104 'helloplus-template-parts-editor',
105 HELLOPLUS_STYLE_URL . 'helloplus-template-parts-editor.css',
106 [],
107 HELLOPLUS_VERSION
108 );
109 }
110
111 /**
112 * @return bool
113 */
114 public static function is_active(): bool {
115 return Utils::is_elementor_active();
116 }
117
118 public function register_controls( Controls_Manager $controls_manager ) {
119 $controls_manager->register( new Control_Media_Preview() );
120 }
121
122 /**
123 * @inheritDoc
124 */
125 protected function register_hooks(): void {
126 parent::register_hooks();
127 add_action( 'elementor/frontend/after_register_scripts', [ $this, 'register_scripts' ] );
128 add_action( 'elementor/frontend/after_register_styles', [ $this, 'register_styles' ] );
129 add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'enqueue_editor_styles' ] );
130 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_editor_scripts' ] );
131 add_action( 'elementor/controls/register', [ $this, 'register_controls' ] );
132 }
133 }
134