PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.3
Elementor Website Builder – more than just a page builder v3.32.3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | modules/variables/hooks.php +11 -58 4.1.0-dev13.32.3 View file →
@@ -1,29 +1,23 @@
1 1 <?php
2 2
3 3 namespace Elementor\Modules\Variables;
4 4
5 -use Elementor\Modules\Variables\Adapters\Prop_Type_Adapter;
6 5 use Elementor\Modules\Variables\Classes\Variable_Types_Registry;
7 6 use Elementor\Modules\Variables\PropTypes\Color_Variable_Prop_Type;
8 7 use Elementor\Modules\Variables\PropTypes\Font_Variable_Prop_Type;
9 -use Elementor\Modules\Variables\PropTypes\Size_Variable_Prop_Type;
10 -use Elementor\Modules\Variables\Services\Batch_Operations\Batch_Processor;
11 -use Elementor\Modules\Variables\Services\Variables_Service;
12 -use Elementor\Modules\Variables\Storage\Variables_Repository;
13 -use Elementor\Modules\Variables\Utils\Template_Library_Variables;
14 8 use Elementor\Plugin;
15 9 use Elementor\Core\Files\CSS\Post as Post_CSS;
16 10 use Elementor\Modules\Variables\Classes\CSS_Renderer as Variables_CSS_Renderer;
17 11 use Elementor\Modules\Variables\Classes\Fonts;
18 12 use Elementor\Modules\Variables\Classes\Rest_Api as Variables_API;
13 +use Elementor\Modules\Variables\Storage\Repository as Variables_Repository;
19 14 use Elementor\Modules\Variables\Classes\Style_Schema;
20 -use Elementor\Modules\Variables\Classes\Size_Style_Schema;
21 15 use Elementor\Modules\Variables\Classes\Style_Transformers;
22 16 use Elementor\Modules\Variables\Classes\Variables;
23 17
24 18 if ( ! defined( 'ABSPATH' ) ) {
25 - exit;
19 + exit; // Exit if accessed directly.
26 20 }
27 21
28 22 class Hooks {
29 23 const PACKAGES = [
@@ -31,15 +25,14 @@
31 25 ];
32 26
33 27 public function register() {
34 28 $this->register_styles_transformers()
29 + ->register_packages()
30 + ->filter_for_style_schema()
35 31 ->register_css_renderer()
36 - ->register_packages()
37 32 ->register_fonts()
38 33 ->register_api_endpoints()
39 - ->filter_for_style_schema()
40 - ->register_variable_types()
41 - ->register_template_library_import();
34 + ->register_variable_types();
42 35
43 36 return $this;
44 37 }
45 38
@@ -46,10 +39,8 @@
46 39 private function register_variable_types() {
47 40 add_action( 'elementor/variables/register', function ( Variable_Types_Registry $registry ) {
48 41 $registry->register( Color_Variable_Prop_Type::get_key(), new Color_Variable_Prop_Type() );
49 42 $registry->register( Font_Variable_Prop_Type::get_key(), new Font_Variable_Prop_Type() );
50 - $registry->register( Prop_Type_Adapter::GLOBAL_CUSTOM_SIZE_VARIABLE_KEY, new Size_Variable_Prop_Type() );
51 - $registry->register( Size_Variable_Prop_Type::get_key(), new Size_Variable_Prop_Type() );
52 43 } );
53 44
54 45 return $this;
55 46 }
@@ -63,9 +54,9 @@
63 54 }
64 55
65 56 private function register_styles_transformers() {
66 57 add_action( 'elementor/atomic-widgets/styles/transformers/register', function ( $registry ) {
67 - Variables::init( $this->variables_service() );
58 + Variables::init( $this->variables_repository() );
68 59 ( new Style_Transformers() )->append_to( $registry );
69 60 } );
70 61
71 62 return $this;
@@ -75,17 +66,13 @@
75 66 add_filter( 'elementor/atomic-widgets/styles/schema', function ( array $schema ) {
76 67 return ( new Style_Schema() )->augment( $schema );
77 68 } );
78 69
79 - add_filter( 'elementor/atomic-widgets/styles/schema', function ( array $schema ) {
80 - return ( new Size_Style_Schema() )->augment( $schema );
81 - } );
82 -
83 70 return $this;
84 71 }
85 72
86 73 private function css_renderer() {
87 - return new Variables_CSS_Renderer( $this->variables_service() );
74 + return new Variables_CSS_Renderer( $this->variables_repository() );
88 75 }
89 76
90 77 private function register_css_renderer() {
91 78 add_action( 'elementor/css-file/post/parse', function ( Post_CSS $post_css ) {
@@ -101,9 +88,9 @@
101 88 return $this;
102 89 }
103 90
104 91 private function fonts() {
105 - return new Fonts( $this->variables_service() );
92 + return new Fonts( $this->variables_repository() );
106 93 }
107 94
108 95 private function register_fonts() {
109 96 add_action( 'elementor/css-file/post/parse', function ( $post_css ) {
@@ -113,9 +100,9 @@
113 100 return $this;
114 101 }
115 102
116 103 private function rest_api() {
117 - return new Variables_API( $this->variables_service() );
104 + return new Variables_API( $this->variables_repository() );
118 105 }
119 106
120 107 private function register_api_endpoints() {
121 108 add_action( 'rest_api_init', function () {
@@ -124,44 +111,10 @@
124 111
125 112 return $this;
126 113 }
127 114
128 - private function variables_service() {
129 - $repository = new Variables_Repository(
115 + private function variables_repository() {
116 + return new Variables_Repository(
130 117 Plugin::$instance->kits_manager->get_active_kit()
131 118 );
132 -
133 - return new Variables_Service( $repository, new Batch_Processor() );
134 - }
135 -
136 - private function register_template_library_import() {
137 - add_filter(
138 - 'elementor/template_library/export/build_snapshots',
139 - [ Template_Library_Variables::class, 'add_variables_snapshot' ],
140 - 20,
141 - 4
142 - );
143 -
144 - add_filter(
145 - 'elementor/template_library/get_data/extract_snapshots',
146 - [ Template_Library_Variables::class, 'extract_variables_from_data' ],
147 - 10,
148 - 3
149 - );
150 -
151 - add_filter(
152 - 'elementor/template_library/import/process_content',
153 - [ Template_Library_Variables::class, 'process_variables_import' ],
154 - 10,
155 - 3
156 - );
157 -
158 - add_filter(
159 - 'elementor/global_classes/import/transform_snapshot',
160 - [ Template_Library_Variables::class, 'transform_variables_in_classes_snapshot' ],
161 - 10,
162 - 4
163 - );
164 -
165 - return $this;
166 119 }
167 120 }