PluginProbe
Hello Plus / 1.7.0
Hello Plus v1.7.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.7.0, at modules/template-parts/module.php

142 lines 2.9 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 'Ehp_Flex_Footer',
45 ];
46 }
47
48 /**
49 * @return void
50 */
51 public function register_scripts(): void {
52 wp_register_script(
53 'helloplus-header-fe',
54 HELLOPLUS_SCRIPTS_URL . 'helloplus-header-fe.js',
55 [ 'elementor-frontend' ],
56 HELLOPLUS_VERSION,
57 true
58 );
59 }
60
61 /**
62 * @return void
63 */
64 public function register_styles(): void {
65 wp_register_style(
66 'helloplus-header',
67 HELLOPLUS_STYLE_URL . 'helloplus-header.css',
68 [ 'elementor-frontend' ],
69 HELLOPLUS_VERSION
70 );
71
72 wp_register_style(
73 'helloplus-footer',
74 HELLOPLUS_STYLE_URL . 'helloplus-footer.css',
75 [ 'elementor-frontend' ],
76 HELLOPLUS_VERSION
77 );
78
79 wp_register_style(
80 'helloplus-flex-footer',
81 HELLOPLUS_STYLE_URL . 'helloplus-flex-footer.css',
82 [ 'elementor-frontend' ],
83 HELLOPLUS_VERSION
84 );
85 }
86
87 /**
88 * @return void
89 */
90 public function enqueue_editor_scripts(): void {
91 wp_enqueue_script(
92 'helloplus-editor',
93 HELLOPLUS_SCRIPTS_URL . 'helloplus-editor.js',
94 [ 'elementor-editor' ],
95 HELLOPLUS_VERSION,
96 true
97 );
98
99 $settings = [
100 'isElementorDomain' => Utils::are_we_on_elementor_domains(),
101 ];
102
103 \wp_add_inline_script( 'helloplus-editor', 'const ehpTemplatePartsEditorSettings = ' . wp_json_encode( $settings ), 'before' );
104 }
105
106
107 /**
108 * @return void
109 */
110 public function enqueue_editor_styles(): void {
111 wp_enqueue_style(
112 'helloplus-template-parts-editor',
113 HELLOPLUS_STYLE_URL . 'helloplus-template-parts-editor.css',
114 [],
115 HELLOPLUS_VERSION
116 );
117 }
118
119 /**
120 * @return bool
121 */
122 public static function is_active(): bool {
123 return Utils::is_elementor_active();
124 }
125
126 public function register_controls( Controls_Manager $controls_manager ) {
127 $controls_manager->register( new Control_Media_Preview() );
128 }
129
130 /**
131 * @inheritDoc
132 */
133 protected function register_hooks(): void {
134 parent::register_hooks();
135 add_action( 'elementor/frontend/after_register_scripts', [ $this, 'register_scripts' ] );
136 add_action( 'elementor/frontend/after_register_styles', [ $this, 'register_styles' ] );
137 add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'enqueue_editor_styles' ] );
138 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_editor_scripts' ] );
139 add_action( 'elementor/controls/register', [ $this, 'register_controls' ] );
140 }
141 }
142