PluginProbe
Elementor Website Builder – more than just a page builder / 3.28.4
Elementor Website Builder – more than just a page builder v3.28.4
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 | includes/managers/elements.php +10 -107 4.2.43.28.4 View file →
@@ -16,17 +16,8 @@
16 16 * @since 1.0.0
17 17 */
18 18 class Elements_Manager {
19 19
20 - const CATEGORY_ATOMIC_ELEMENTS = 'v4-elements';
21 - const CATEGORY_ATOMIC_FORM = 'atomic-form';
22 - const CATEGORY_FAVORITES = 'favorites';
23 - const CATEGORY_ANGIE_WIDGETS = 'angie-widgets';
24 - const CATEGORY_CUSTOM_WIDGETS = 'custom-widgets';
25 - const CATEGORY_BASIC = 'basic';
26 - const CATEGORY_PRO_ELEMENTS = 'pro-elements';
27 - const CATEGORY_WORDPRESS = 'wordpress';
28 -
29 20 /**
30 21 * Element types.
31 22 *
32 23 * Holds the list of all the element types.
@@ -75,11 +66,15 @@
75 66 *
76 67 * @return Element_Base|null Element instance if element created, or null
77 68 * otherwise.
78 69 */
79 - public function create_element_instance( array $element_data, array $element_args = [], ?Element_Base $element_type = null ) {
70 + public function create_element_instance( array $element_data, array $element_args = [], Element_Base $element_type = null ) {
80 71 if ( null === $element_type ) {
81 - $element_type = $this->get_element( $element_data['elType'], isset( $element_data['widgetType'] ) ? $element_data['widgetType'] : null );
72 + if ( 'widget' === $element_data['elType'] ) {
73 + $element_type = Plugin::$instance->widgets_manager->get_widget_types( $element_data['widgetType'] );
74 + } else {
75 + $element_type = $this->get_element_types( $element_data['elType'] );
76 + }
82 77 }
83 78
84 79 if ( ! $element_type ) {
85 80 return null;
@@ -97,20 +92,8 @@
97 92
98 93 return $element;
99 94 }
100 95
101 - public function get_element( string $el_type, ?string $widget_type = null ) {
102 - $element = null;
103 -
104 - if ( 'widget' === $el_type ) {
105 - $element = Plugin::$instance->widgets_manager->get_widget_types( $widget_type );
106 - } else {
107 - $element = $this->get_element_types( $el_type );
108 - }
109 -
110 - return $element;
111 - }
112 -
113 96 /**
114 97 * Get element categories.
115 98 *
116 99 * Retrieve the list of categories the element belongs to.
@@ -292,10 +275,10 @@
292 275 * @access private
293 276 */
294 277 private function init_categories() {
295 278 $this->categories = [
296 - self::CATEGORY_ATOMIC_ELEMENTS => [
297 - 'title' => esc_html__( 'Atomic Elements', 'elementor' ),
279 + 'v4-elements' => [
280 + 'title' => esc_html__( 'V4 Elements', 'elementor' ),
298 281 'hideIfEmpty' => true,
299 282 ],
300 283 'layout' => [
301 284 'title' => esc_html__( 'Layout', 'elementor' ),
@@ -304,9 +287,9 @@
304 287 'basic' => [
305 288 'title' => esc_html__( 'Basic', 'elementor' ),
306 289 'icon' => 'eicon-font',
307 290 ],
308 - self::CATEGORY_PRO_ELEMENTS => [
291 + 'pro-elements' => [
309 292 'title' => esc_html__( 'Pro', 'elementor' ),
310 293 'promotion' => [
311 294 'url' => esc_url( 'https://go.elementor.com/go-pro-section-pro-widget-panel/' ),
312 295 ],
@@ -338,34 +321,11 @@
338 321 ],
339 322 ],
340 323 ];
341 324
342 - if ( Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' ) ) {
343 - $atomic_form_category = [
344 - 'title' => esc_html__( 'Atomic Form', 'elementor' ),
345 - ];
346 -
347 - if ( Utils::has_pro() && Plugin::$instance->experiments->is_feature_active( 'e_pro_atomic_form' ) ) {
348 - $atomic_form_category['hideIfEmpty'] = true;
349 - } elseif ( ! Utils::has_pro() ) {
350 - $atomic_form_category['hideIfEmpty'] = false;
351 - $atomic_form_category['promotion'] = [
352 - 'url' => esc_url( 'https://go.elementor.com/go-pro-atomic-form-section/' ),
353 - ];
354 - } else {
355 - $atomic_form_category['hideIfEmpty'] = true;
356 - }
357 -
358 - $this->categories = array_merge(
359 - [ self::CATEGORY_ATOMIC_ELEMENTS => $this->categories[ self::CATEGORY_ATOMIC_ELEMENTS ] ],
360 - [ self::CATEGORY_ATOMIC_FORM => $atomic_form_category ],
361 - array_diff_key( $this->categories, [ self::CATEGORY_ATOMIC_ELEMENTS => true ] )
362 - );
363 - }
364 -
365 325 // Not using the `add_category` because it doesn't allow 3rd party to inject a category on top the others.
366 326 $this->categories = array_merge_recursive( [
367 - self::CATEGORY_FAVORITES => [
327 + 'favorites' => [
368 328 'title' => esc_html__( 'Favorites', 'elementor' ),
369 329 'icon' => 'eicon-heart',
370 330 'sort' => 'a-z',
371 331 'hideIfEmpty' => false,
@@ -386,24 +346,8 @@
386 346 * @param Elements_Manager $this Elements manager instance.
387 347 */
388 348 do_action( 'elementor/elements/categories_registered', $this );
389 349
390 - $after_candidates = Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' )
391 - ? [ self::CATEGORY_ATOMIC_FORM, self::CATEGORY_ATOMIC_ELEMENTS ]
392 - : [ self::CATEGORY_BASIC ];
393 -
394 - $this->promote_category_after( self::CATEGORY_ANGIE_WIDGETS, $after_candidates );
395 - $this->promote_category_after( self::CATEGORY_CUSTOM_WIDGETS, $after_candidates );
396 -
397 - if ( ! Utils::has_pro() && Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' ) ) {
398 - $this->promote_category_after( self::CATEGORY_PRO_ELEMENTS, [
399 - self::CATEGORY_CUSTOM_WIDGETS,
400 - self::CATEGORY_ANGIE_WIDGETS,
401 - self::CATEGORY_ATOMIC_FORM,
402 - self::CATEGORY_ATOMIC_ELEMENTS,
403 - ] );
404 - }
405 -
406 350 $this->categories['wordpress'] = [
407 351 'title' => esc_html__( 'WordPress', 'elementor' ),
408 352 'icon' => 'eicon-wordpress',
409 353 'active' => false,
@@ -413,49 +357,8 @@
413 357 public function enqueue_elements_styles() {
414 358 foreach ( $this->get_element_types() as $element ) {
415 359 $element->enqueue_styles();
416 360 }
417 - }
418 -
419 - public function enqueue_elements_scripts() {
420 - foreach ( $this->get_element_types() as $element ) {
421 - $element->enqueue_scripts();
422 - }
423 - }
424 -
425 - public function register_frontend_handlers() {
426 - foreach ( $this->get_element_types() as $element ) {
427 - $element->register_frontend_handlers();
428 - }
429 - }
430 -
431 - private function promote_category_after( string $category_name, array $after_candidates ): void {
432 - if ( ! isset( $this->categories[ $category_name ] ) ) {
433 - return;
434 - }
435 -
436 - $after = null;
437 -
438 - foreach ( $after_candidates as $candidate ) {
439 - if ( isset( $this->categories[ $candidate ] ) ) {
440 - $after = $candidate;
441 - break;
442 - }
443 - }
444 -
445 - if ( ! $after ) {
446 - return;
447 - }
448 -
449 - $category = $this->categories[ $category_name ];
450 - unset( $this->categories[ $category_name ] );
451 -
452 - $position = array_search( $after, array_keys( $this->categories ), true ) + 1;
453 - $this->categories = array_merge(
454 - array_slice( $this->categories, 0, $position, true ),
455 - [ $category_name => $category ],
456 - array_slice( $this->categories, $position, null, true )
457 - );
458 361 }
459 362
460 363 /**
461 364 * Require files.