PluginProbe
Elementor Website Builder – more than just a page builder / 3.2.0
Elementor Website Builder – more than just a page builder v3.2.0
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 +19 -160 4.2.33.2.0 View file →
@@ -1,9 +1,7 @@
1 1 <?php
2 2 namespace Elementor;
3 3
4 -use Elementor\Includes\Elements\Container;
5 -
6 4 if ( ! defined( 'ABSPATH' ) ) {
7 5 exit; // Exit if accessed directly.
8 6 }
9 7
@@ -16,17 +14,8 @@
16 14 * @since 1.0.0
17 15 */
18 16 class Elements_Manager {
19 17
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 18 /**
30 19 * Element types.
31 20 *
32 21 * Holds the list of all the element types.
@@ -43,9 +32,9 @@
43 32 * Holds the list of all the element categories.
44 33 *
45 34 * @access private
46 35 *
47 - * @var $categories
36 + * @var
48 37 */
49 38 private $categories;
50 39
51 40 /**
@@ -75,11 +64,15 @@
75 64 *
76 65 * @return Element_Base|null Element instance if element created, or null
77 66 * otherwise.
78 67 */
79 - public function create_element_instance( array $element_data, array $element_args = [], ?Element_Base $element_type = null ) {
68 + public function create_element_instance( array $element_data, array $element_args = [], Element_Base $element_type = null ) {
80 69 if ( null === $element_type ) {
81 - $element_type = $this->get_element( $element_data['elType'], isset( $element_data['widgetType'] ) ? $element_data['widgetType'] : null );
70 + if ( 'widget' === $element_data['elType'] ) {
71 + $element_type = Plugin::$instance->widgets_manager->get_widget_types( $element_data['widgetType'] );
72 + } else {
73 + $element_type = $this->get_element_types( $element_data['elType'] );
74 + }
82 75 }
83 76
84 77 if ( ! $element_type ) {
85 78 return null;
@@ -97,20 +90,8 @@
97 90
98 91 return $element;
99 92 }
100 93
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 94 /**
114 95 * Get element categories.
115 96 *
116 97 * Retrieve the list of categories the element belongs to.
@@ -266,14 +247,8 @@
266 247
267 248 $this->register_element_type( new $class_name() );
268 249 }
269 250
270 - $experiments_manager = Plugin::$instance->experiments;
271 -
272 - if ( $experiments_manager->is_feature_active( 'container' ) ) {
273 - $this->register_element_type( new Container() );
274 - }
275 -
276 251 /**
277 252 * After elements registered.
278 253 *
279 254 * Fires after Elementor elements are registered.
@@ -279,9 +254,9 @@
279 254 * Fires after Elementor elements are registered.
280 255 *
281 256 * @since 1.0.0
282 257 */
283 - do_action( 'elementor/elements/elements_registered', $this );
258 + do_action( 'elementor/elements/elements_registered' );
284 259 }
285 260
286 261 /**
287 262 * Init categories.
@@ -292,87 +267,29 @@
292 267 * @access private
293 268 */
294 269 private function init_categories() {
295 270 $this->categories = [
296 - self::CATEGORY_ATOMIC_ELEMENTS => [
297 - 'title' => esc_html__( 'Atomic Elements', 'elementor' ),
298 - 'hideIfEmpty' => true,
299 - ],
300 - 'layout' => [
301 - 'title' => esc_html__( 'Layout', 'elementor' ),
302 - 'hideIfEmpty' => true,
303 - ],
304 271 'basic' => [
305 - 'title' => esc_html__( 'Basic', 'elementor' ),
272 + 'title' => __( 'Basic', 'elementor' ),
306 273 'icon' => 'eicon-font',
307 274 ],
308 - self::CATEGORY_PRO_ELEMENTS => [
309 - 'title' => esc_html__( 'Pro', 'elementor' ),
310 - 'promotion' => [
311 - 'url' => esc_url( 'https://go.elementor.com/go-pro-section-pro-widget-panel/' ),
312 - ],
275 + 'pro-elements' => [
276 + 'title' => __( 'Pro', 'elementor' ),
313 277 ],
314 - 'helloplus' => [
315 - 'title' => esc_html__( 'Hello+', 'elementor' ),
316 - 'hideIfEmpty' => true,
317 - ],
318 278 'general' => [
319 - 'title' => esc_html__( 'General', 'elementor' ),
279 + 'title' => __( 'General', 'elementor' ),
320 280 'icon' => 'eicon-font',
321 281 ],
322 - 'link-in-bio' => [
323 - 'title' => esc_html__( 'Link In Bio', 'elementor' ),
324 - 'hideIfEmpty' => true,
325 - ],
326 282 'theme-elements' => [
327 - 'title' => esc_html__( 'Site', 'elementor' ),
283 + 'title' => __( 'Site', 'elementor' ),
328 284 'active' => false,
329 - 'promotion' => [
330 - 'url' => esc_url( 'https://go.elementor.com/go-pro-section-site-widget-panel/' ),
331 - ],
332 285 ],
333 286 'woocommerce-elements' => [
334 - 'title' => esc_html__( 'WooCommerce', 'elementor' ),
287 + 'title' => __( 'WooCommerce', 'elementor' ),
335 288 'active' => false,
336 - 'promotion' => [
337 - 'url' => esc_url( 'https://go.elementor.com/go-pro-section-woocommerce-widget-panel/' ),
338 - ],
339 289 ],
340 290 ];
341 291
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 - // Not using the `add_category` because it doesn't allow 3rd party to inject a category on top the others.
366 - $this->categories = array_merge_recursive( [
367 - self::CATEGORY_FAVORITES => [
368 - 'title' => esc_html__( 'Favorites', 'elementor' ),
369 - 'icon' => 'eicon-heart',
370 - 'sort' => 'a-z',
371 - 'hideIfEmpty' => false,
372 - ],
373 - ], $this->categories );
374 -
375 292 /**
376 293 * When categories are registered.
377 294 *
378 295 * Fires after basic categories are registered, before WordPress
@@ -386,76 +303,18 @@
386 303 * @param Elements_Manager $this Elements manager instance.
387 304 */
388 305 do_action( 'elementor/elements/categories_registered', $this );
389 306
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 ];
307 + $this->categories['pojo'] = [
308 + 'title' => __( 'Pojo Themes', 'elementor' ),
309 + 'icon' => 'eicon-pojome',
310 + ];
393 311
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 312 $this->categories['wordpress'] = [
407 - 'title' => esc_html__( 'WordPress', 'elementor' ),
313 + 'title' => __( 'WordPress', 'elementor' ),
408 314 'icon' => 'eicon-wordpress',
409 315 'active' => false,
410 316 ];
411 - }
412 -
413 - public function enqueue_elements_styles() {
414 - foreach ( $this->get_element_types() as $element ) {
415 - $element->enqueue_styles();
416 - }
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 317 }
459 318
460 319 /**
461 320 * Require files.