PluginProbe ʕ •ᴥ•ʔ
Essential Addons for Elementor – Popular Elementor Templates & Widgets / 6.6.9
Essential Addons for Elementor – Popular Elementor Templates & Widgets v6.6.9
6.6.9 6.6.8 6.6.7 6.6.6 6.6.5 6.6.4 6.6.3 5.7.3 5.7.4 5.8.0 5.8.1 5.8.10 5.8.11 5.8.12 5.8.13 5.8.14 5.8.15 5.8.16 5.8.18 5.8.2 5.8.3 5.8.4 5.8.5 5.8.6 5.8.7 5.8.8 5.8.9 5.9.0 5.9.1 5.9.10 5.9.11 5.9.12 5.9.13 5.9.14 5.9.15 5.9.16 5.9.17 5.9.18 5.9.19 5.9.2 5.9.20 5.9.21 5.9.22 5.9.23 5.9.24 5.9.25 5.9.26 5.9.27 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 5.9.9 6.0.0 6.0.1 6.0.10 6.0.11 6.0.12 6.0.13 6.0.14 6.0.15 6.0.2 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 6.0.8 6.0.9 6.1.0 6.1.1 6.1.10 6.1.11 trunk 6.1.12 1.0.0 6.1.13 1.0.1 6.1.14 1.1.0 6.1.15 2.0 6.1.17 2.1 6.1.18 2.10.0 6.1.19 2.10.1 6.1.2 2.10.2 6.1.20 2.10.3 6.1.3 2.10.4 6.1.4 2.10.5 6.1.5 2.2.0 6.1.6 2.2.1 6.1.7 2.2.2 6.1.8 2.2.3 6.1.9 2.2.4 6.2.0 2.2.5 6.2.1 2.3.0 6.2.2 2.3.1 6.2.3 2.4.0 6.2.4 2.4.1 6.3.0 2.4.2 6.3.1 2.4.3 6.3.2 2.5.0 6.3.3 2.6.0 6.4.0 2.7.0 6.5.0 2.7.1 6.5.1 2.7.10 6.5.10 2.7.11 6.5.11 2.7.2 6.5.12 2.7.3 6.5.13 2.7.4 6.5.2 2.7.5 6.5.3 2.7.6 6.5.4 2.7.7 6.5.5 2.7.8 6.5.6 2.7.9 6.5.7 2.8.0 6.5.8 2.8.1 6.5.9 2.8.2 6.6.0 2.8.3 6.6.1 2.8.4 6.6.2 2.8.5 2.8.6 2.8.7 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.4.1 3.1.5 3.2.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.5.0 3.5.1 3.5.2 3.6.0 3.6.1 3.6.2 3.7.0 3.7.1 3.7.2 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.8 4.3.9 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.9.0 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 4.9.6 4.9.7 5.0.0 5.0.1 5.0.10 5.0.11 5.0.12 5.0.13 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.0.9 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.2.0 5.2.1 5.2.2 5.2.3 5.2.4 5.3.0 5.3.1 5.3.2 5.4.6 5.5.5 5.6.5 5.7.2
essential-addons-for-elementor-lite / includes / Classes / Elements_Manager.php
essential-addons-for-elementor-lite / includes / Classes Last commit date
AllTraits.php 1 year ago Asset_Builder.php 9 months ago Bootstrap.php 2 weeks ago Compatibility_Support.php 2 months ago Elements_Manager.php 7 months ago Helper.php 1 month ago Migration.php 5 months ago Plugin_Usage_Tracker.php 5 months ago WPDeveloper_Core_Installer.php 5 months ago WPDeveloper_Notice.php 2 months ago WPDeveloper_Plugin_Installer.php 5 months ago WPDeveloper_Setup_Wizard.php 2 months ago index.php 3 years ago
Elements_Manager.php
419 lines
1 <?php
2
3 namespace Essential_Addons_Elementor\Classes;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 } // Exit if accessed directly
8
9 use Elementor\Plugin;
10 use Essential_Addons_Elementor\Traits\Library;
11
12 class Elements_Manager {
13 use Library;
14
15 /**
16 * custom key name which are used for store widget list in option table
17 */
18 const ELEMENT_KEY = '_eael_widget_elements';
19
20 /**
21 * This is hold custom js data in option table
22 */
23 const JS_KEY = '_eael_custom_js';
24
25 public $css_print_method;
26 public $js_print_method;
27
28 /**
29 * Post id
30 * @var string
31 */
32 protected $post_id;
33
34 /**
35 * registered element list from essential addons settings
36 * @var array
37 */
38 protected $registered_elements;
39
40 /**
41 * registered extensions list from essential addons settings
42 * @var array
43 */
44 protected $registered_extensions;
45
46 /**
47 * __construct
48 * @param array $registered_elements
49 * @param array $registered_extensions
50 */
51 public function __construct( $registered_elements, $registered_extensions ) {
52 $this->registered_elements = $registered_elements;
53 $this->registered_extensions = $registered_extensions;
54 add_action( 'elementor/editor/after_save', array( $this, 'eael_elements_cache' ), 10, 2 );
55 }
56
57 /**
58 * eael_elements_cache
59 * Save widget name list in option table for improve performance.
60 * @param int $post_id
61 * @param array $data
62 */
63 public function eael_elements_cache( $post_id, $data ) {
64 $widget_list = $this->get_widget_list( $data );
65 $page_setting = get_post_meta( $post_id, '_elementor_page_settings', true );
66 $custom_js = isset( $page_setting['eael_custom_js'] ) ? trim( $page_setting['eael_custom_js'] ) : '';
67 $this->save_widgets_list( $post_id, $widget_list, $custom_js );
68 }
69
70 /**
71 * get_widget_list
72 * get widget names
73 * @param array $data
74 *
75 * @return array
76 */
77 public function get_widget_list( $data ) {
78 $widget_list = [];
79 $replace = $this->replace_widget_name();
80
81 if ( is_object( Plugin::$instance->db ) ) {
82 Plugin::$instance->db->iterate_data( $data, function ( $element ) use ( &$widget_list, $replace ) {
83
84 if ( empty( $element['widgetType'] ) ) {
85 $type = $element['elType'];
86 } else {
87 $type = $element['widgetType'];
88 }
89
90 if ( ! empty( $element['widgetType'] ) && $element['widgetType'] === 'global' ) {
91 $document = Plugin::$instance->documents->get( $element['templateID'] );
92 $type = is_object( $document ) ? current( $this->get_widget_list( $document->get_elements_data() ) ) : $type;
93
94 if ( ! empty( $type ) ) {
95 $type = 'eael-' . $type;
96 }
97 }
98
99 if ( ! empty( $type ) && ! is_array( $type ) ) {
100
101 if ( isset( $replace[ $type ] ) ) {
102 $type = $replace[ $type ];
103 }
104
105 if ( strpos( $type, 'eael-' ) !== false ) {
106
107 $type = str_replace( 'eael-', '', $type );
108 if ( ! isset( $widget_list[ $type ] ) ) {
109 $widget_list[ $type ] = $type;
110 }
111 }
112
113 $widget_list += $this->get_extension_list( $element );
114 }
115
116 } );
117 }
118
119 return $widget_list;
120 }
121
122 /**
123 * get_element_list
124 * get cached widget list
125 * @param $post_id
126 *
127 * @return bool
128 */
129 public function get_element_list( $post_id ) {
130
131 if ( is_object( Plugin::instance()->editor ) && Plugin::instance()->editor->is_edit_mode() ) {
132 return false;
133 }
134
135 if ( $this->has_exist( $post_id ) ) {
136 return false;
137 }
138
139 $document = is_object( Plugin::$instance->documents ) ? Plugin::$instance->documents->get( $post_id ) : [];
140 $data = is_object( $document ) ? $document->get_elements_data() : [];
141 $data = $this->get_widget_list( $data );
142 $this->save_widgets_list( $post_id, $data, false );
143
144 return true;
145 }
146
147 /**
148 * get_extension_list
149 * get extension name those name had been changed for some reason.
150 * @param array $element
151 *
152 * @return array
153 */
154 public function get_extension_list( $element ) {
155 $list = [];
156 if ( isset( $element['elType'] ) && ( $element['elType'] == 'section' || $element['elType'] == 'container' ) ) {
157 if ( ! empty( $element['settings']['eael_particle_switch'] ) ) {
158 $list['section-particles'] = 'section-particles';
159 }
160 if ( ! empty( $element['settings']['eael_parallax_switcher'] ) ) {
161 $list['section-parallax'] = 'section-parallax';
162 }
163 } else {
164 if ( ! empty( $element['settings']['eael_tooltip_section_enable'] ) ) {
165 $list['tooltip-section'] = 'tooltip-section';
166 }
167 if ( ! empty( $element['settings']['eael_ext_content_protection'] ) ) {
168 $list['content-protection'] = 'content-protection';
169 }
170 }
171
172 if ( ! empty( $element['settings']['eael_wrapper_link_switch'] ) ) {
173 $list['wrapper-link'] = 'wrapper-link';
174 }
175 if ( ! empty( $element['settings']['eael_enable_custom_cursor'] ) || ! empty( $element['settings']['eael_cursor_trail_show'] ) ) {
176 $list['custom-cursor'] = 'custom-cursor';
177 }
178
179 if ( ! empty( $element['settings']['eael_ext_advanced_dynamic_tags'] ) ) {
180 $list['advanced-dynamic-tags'] = 'advanced-dynamic-tags';
181 }
182
183 //Smooth Animation
184 if ( ! empty( $element['settings']['eael_smooth_animation_section'] ) ) {
185 $list['smooth-animation'] = 'smooth-animation';
186 }
187
188 //Hover Interactions
189 if ( ! empty( $element['settings']['eael_hover_effect_switch'] ) ) {
190 $list['special-hover-effect'] = 'special-hover-effect';
191 }
192
193 //Liquid Glass Effects
194 if ( ! empty( $element['settings']['eael_liquid_glass_effect_switch'] ) ) {
195 $list['liquid-glass-effect'] = 'liquid-glass-effect';
196 }
197
198 // Vertical Text Orientation
199 if ( ! empty( $element['settings']['eael_vertical_text_orientation_switch'] ) ) {
200 $list['vertical-text-orientation'] = 'vertical-text-orientation';
201 }
202
203 //Image Masking
204 if ( ! empty( $element['settings']['eael_enable_image_masking'] ) ) {
205 $list['image-masking'] = 'image-masking';
206 }
207
208 return $list;
209 }
210
211 /*
212 * replace_widget_name
213 * Added backward compatibility
214 */
215 public static function replace_widget_name() {
216 return [
217 'eicon-woocommerce' => 'eael-product-grid',
218 'eael-countdown' => 'eael-count-down',
219 'eael-creative-button' => 'eael-creative-btn',
220 'eael-team-member' => 'eael-team-members',
221 'eael-testimonial' => 'eael-testimonials',
222 'eael-weform' => 'eael-weforms',
223 'eael-cta-box' => 'eael-call-to-action',
224 'eael-dual-color-header' => 'eael-dual-header',
225 'eael-pricing-table' => 'eael-price-table',
226 'eael-filterable-gallery' => 'eael-filter-gallery',
227 'eael-one-page-nav' => 'eael-one-page-navigation',
228 'eael-interactive-card' => 'eael-interactive-cards',
229 'eael-image-comparison' => 'eael-img-comparison',
230 'eael-dynamic-filterable-gallery' => 'eael-dynamic-filter-gallery',
231 'eael-google-map' => 'eael-adv-google-map',
232 'eael-instafeed' => 'eael-instagram-gallery',
233 'eael-ninja' => 'eael-ninja-form',
234 ];
235 }
236
237 /**
238 * save_widgets_list
239 * save widget list and custom js data in option table
240 * @param int $post_id
241 * @param array $list
242 * @param string $custom_js
243 *
244 * @return bool|mixed
245 */
246 public function save_widgets_list( $post_id, $list, $custom_js = '' ) {
247
248 if ( \defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
249 return $post_id;
250 }
251
252 $documents = is_object( Plugin::$instance->documents ) ? Plugin::$instance->documents->get( $post_id ) : [];
253
254 if ( ! in_array( get_post_status( $post_id ), [ 'publish', 'private' ] ) || ( is_object( $documents ) && ! $documents->is_built_with_elementor() ) ) {
255 return false;
256 }
257
258 if ( in_array( get_post_meta( $post_id, '_elementor_template_type', true ), $this->excluded_template_type() ) ) {
259 return false;
260 }
261
262 if ( $custom_js !== false ) {
263 update_post_meta( $post_id, '_eael_custom_js', $custom_js );
264 }
265
266 if ( md5( implode( '', (array) $list ) ) == md5( implode( '', (array) get_post_meta( $post_id, self::ELEMENT_KEY, true ) ) ) ) {
267 return false;
268 }
269
270 try {
271 update_post_meta( $post_id, self::ELEMENT_KEY, $list );
272 $this->remove_files( $post_id );
273
274 if ( $this->has_exist( $post_id ) ) {
275 $this->update_asset( $post_id, $list );
276 }
277
278 return true;
279 } catch ( \Exception $e ) {
280 return false;
281 }
282 }
283
284 /**
285 * generate_script
286 * create js/css file as per widget loaded in page
287 * @param int $post_id
288 * @param array $elements
289 * @param string $context
290 * @param string $ext
291 */
292 public function generate_script( $post_id, $elements, $context, $ext ) {
293 // if folder not exists, create new folder
294 if ( ! file_exists( EAEL_ASSET_PATH ) ) {
295 wp_mkdir_p( EAEL_ASSET_PATH );
296 }
297
298 // naming asset file
299 $file_name = 'eael' . ( $post_id ? '-' . $post_id : '' ) . '.' . $ext;
300
301 // output asset string
302 $output = $this->generate_strings( $elements, $context, $ext );
303
304 // write to file
305 $file_path = $this->safe_path( EAEL_ASSET_PATH . DIRECTORY_SEPARATOR . $file_name );
306 file_put_contents( $file_path, $output );
307 }
308
309 /**
310 * generate_strings
311 * Load assets for inline loading
312 * @param string $elements
313 * @param string $context
314 * @param string $ext
315 *
316 * @return string
317 */
318 public function generate_strings( $elements, $context, $ext ) {
319 $output = '';
320
321 $paths = $this->generate_dependency( $elements, $context, $ext );
322
323 if ( ! empty( $paths ) ) {
324 foreach ( $paths as $path ) {
325 $output .= file_get_contents( $this->safe_path( $path ) );
326 }
327 }
328
329 return $output;
330 }
331
332 /**
333 * generate_dependency
334 * Load core library for widget list which are defined on config.php file
335 * @param array $elements
336 * @param string $context
337 * @param string $type
338 *
339 * @return array
340 */
341 public function generate_dependency( $elements, $context, $type ) {
342 $lib = [ 'view' => [], 'edit' => [] ];
343 $self = [ 'general' => [], 'view' => [], 'edit' => [] ];
344
345 if ( $type == 'js' ) {
346 $self['general'][] = EAEL_PLUGIN_PATH . 'assets/front-end/js/view/general.min.js';
347 $self['edit'][] = EAEL_PLUGIN_PATH . 'assets/front-end/js/edit/promotion.min.js';
348 } else if ( $type == 'css' && ! $this->is_edit_mode() ) {
349 $self['view'][] = EAEL_PLUGIN_PATH . "assets/front-end/css/view/general.min.css";
350 }
351
352 foreach ( $elements as $element ) {
353
354 if ( isset( $this->registered_elements[ $element ] ) ) {
355 if ( ! empty( $this->registered_elements[ $element ]['dependency'][ $type ] ) ) {
356 foreach ( $this->registered_elements[ $element ]['dependency'][ $type ] as $file ) {
357 if ( ! empty( $file['type'] ) && ! empty( $file['context'] ) && ! empty( $file['file'] ) ) {
358 ${$file['type']}[ $file['context'] ][] = $file['file'];
359 }
360 }
361 }
362 } elseif ( isset( $this->registered_extensions[ $element ] ) ) {
363 if ( ! empty( $this->registered_extensions[ $element ]['dependency'][ $type ] ) ) {
364 foreach ( $this->registered_extensions[ $element ]['dependency'][ $type ] as $file ) {
365 if ( ! empty( $file['type'] ) && ! empty( $file['context'] ) && ! empty( $file['file'] ) ) {
366 ${$file['type']}[ $file['context'] ][] = $file['file'];
367 }
368 }
369 }
370 }
371 }
372
373 if ( $context == 'view' ) {
374 return array_unique( array_merge( $lib['view'], $self['view'] ) );
375 }
376
377 return array_unique( array_merge( $lib['view'], $lib['edit'], $self['edit'], $self['view'] ) );
378 }
379
380 /**
381 * has_exist
382 * @param $post_id
383 * check widget list already saved in option table weather load or not
384 * @return bool
385 */
386 public function has_exist( $post_id ) {
387 $status = get_post_meta( $post_id, self::ELEMENT_KEY, true );
388
389 return ! empty( $status );
390 }
391
392 /**
393 * update_asset
394 * @param int $post_id
395 * @param $elements
396 */
397 public function update_asset( $post_id, $elements ) {
398
399 if ( $this->css_print_method != 'internal' ) {
400 $this->generate_script( $post_id, $elements, 'view', 'css' );
401 }
402
403 if ( $this->js_print_method != 'internal' ) {
404 $this->generate_script( $post_id, $elements, 'view', 'js' );
405 }
406
407 }
408
409 /**
410 * excluded_template_type
411 * @return string[]
412 */
413 public function excluded_template_type() {
414 return [
415 'kit',
416 ];
417 }
418 }
419