PluginProbe
Elementor Website Builder – more than just a page builder / 3.5.6
Elementor Website Builder – more than just a page builder v3.5.6
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 +22 -133 4.1.0-dev13.5.6 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2 namespace Elementor;
3 3
4 -use Elementor\Includes\Elements\Container;
4 +use Elementor\Core\Experiments\Manager;
5 5
6 6 if ( ! defined( 'ABSPATH' ) ) {
7 7 exit; // Exit if accessed directly.
8 8 }
@@ -16,14 +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 -
26 20 /**
27 21 * Element types.
28 22 *
29 23 * Holds the list of all the element types.
@@ -40,9 +34,9 @@
40 34 * Holds the list of all the element categories.
41 35 *
42 36 * @access private
43 37 *
44 - * @var $categories
38 + * @var
45 39 */
46 40 private $categories;
47 41
48 42 /**
@@ -72,11 +66,15 @@
72 66 *
73 67 * @return Element_Base|null Element instance if element created, or null
74 68 * otherwise.
75 69 */
76 - 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 ) {
77 71 if ( null === $element_type ) {
78 - $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 + }
79 77 }
80 78
81 79 if ( ! $element_type ) {
82 80 return null;
@@ -94,20 +92,8 @@
94 92
95 93 return $element;
96 94 }
97 95
98 - public function get_element( string $el_type, ?string $widget_type = null ) {
99 - $element = null;
100 -
101 - if ( 'widget' === $el_type ) {
102 - $element = Plugin::$instance->widgets_manager->get_widget_types( $widget_type );
103 - } else {
104 - $element = $this->get_element_types( $el_type );
105 - }
106 -
107 - return $element;
108 - }
109 -
110 96 /**
111 97 * Get element categories.
112 98 *
113 99 * Retrieve the list of categories the element belongs to.
@@ -263,14 +249,8 @@
263 249
264 250 $this->register_element_type( new $class_name() );
265 251 }
266 252
267 - $experiments_manager = Plugin::$instance->experiments;
268 -
269 - if ( $experiments_manager->is_feature_active( 'container' ) ) {
270 - $this->register_element_type( new Container() );
271 - }
272 -
273 253 /**
274 254 * After elements registered.
275 255 *
276 256 * Fires after Elementor elements are registered.
@@ -289,16 +269,8 @@
289 269 * @access private
290 270 */
291 271 private function init_categories() {
292 272 $this->categories = [
293 - self::CATEGORY_ATOMIC_ELEMENTS => [
294 - 'title' => esc_html__( 'Atomic Elements', 'elementor' ),
295 - 'hideIfEmpty' => true,
296 - ],
297 - 'layout' => [
298 - 'title' => esc_html__( 'Layout', 'elementor' ),
299 - 'hideIfEmpty' => true,
300 - ],
301 273 'basic' => [
302 274 'title' => esc_html__( 'Basic', 'elementor' ),
303 275 'icon' => 'eicon-font',
304 276 ],
@@ -303,73 +275,35 @@
303 275 'icon' => 'eicon-font',
304 276 ],
305 277 'pro-elements' => [
306 278 'title' => esc_html__( 'Pro', 'elementor' ),
307 - 'promotion' => [
308 - 'url' => esc_url( 'https://go.elementor.com/go-pro-section-pro-widget-panel/' ),
309 - ],
310 279 ],
311 - 'helloplus' => [
312 - 'title' => esc_html__( 'Hello+', 'elementor' ),
313 - 'hideIfEmpty' => true,
314 - ],
315 280 'general' => [
316 281 'title' => esc_html__( 'General', 'elementor' ),
317 282 'icon' => 'eicon-font',
318 283 ],
319 - 'link-in-bio' => [
320 - 'title' => esc_html__( 'Link In Bio', 'elementor' ),
321 - 'hideIfEmpty' => true,
322 - ],
323 284 'theme-elements' => [
324 285 'title' => esc_html__( 'Site', 'elementor' ),
325 286 'active' => false,
326 - 'promotion' => [
327 - 'url' => esc_url( 'https://go.elementor.com/go-pro-section-site-widget-panel/' ),
328 - ],
329 287 ],
330 288 'woocommerce-elements' => [
331 289 'title' => esc_html__( 'WooCommerce', 'elementor' ),
332 290 'active' => false,
333 - 'promotion' => [
334 - 'url' => esc_url( 'https://go.elementor.com/go-pro-section-woocommerce-widget-panel/' ),
335 - ],
336 291 ],
337 292 ];
338 293
339 - if ( Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' ) ) {
340 - $atomic_form_category = [
341 - 'title' => esc_html__( 'Atomic Form', 'elementor' ),
342 - ];
343 -
344 - if ( Utils::has_pro() && Plugin::$instance->experiments->is_feature_active( 'e_pro_atomic_form' ) ) {
345 - $atomic_form_category['hideIfEmpty'] = true;
346 - } elseif ( ! Utils::has_pro() ) {
347 - $atomic_form_category['hideIfEmpty'] = false;
348 - $atomic_form_category['promotion'] = [
349 - 'url' => esc_url( 'https://go.elementor.com/go-pro-atomic-form-section/' ),
350 - ];
351 - } else {
352 - $atomic_form_category['hideIfEmpty'] = true;
353 - }
354 -
355 - $this->categories = array_merge(
356 - [ self::CATEGORY_ATOMIC_ELEMENTS => $this->categories[ self::CATEGORY_ATOMIC_ELEMENTS ] ],
357 - [ self::CATEGORY_ATOMIC_FORM => $atomic_form_category ],
358 - array_diff_key( $this->categories, [ self::CATEGORY_ATOMIC_ELEMENTS => true ] )
359 - );
294 + // Not using the `add_category` because it doesn't allow 3rd party to inject a category on top the others.
295 + if ( Plugin::instance()->experiments->is_feature_active( 'favorite-widgets' ) ) {
296 + $this->categories = array_merge_recursive( [
297 + 'favorites' => [
298 + 'title' => esc_html__( 'Favorites', 'elementor' ),
299 + 'icon' => 'eicon-heart',
300 + 'sort' => 'a-z',
301 + 'hideIfEmpty' => false,
302 + ],
303 + ], $this->categories );
360 304 }
361 305
362 - // Not using the `add_category` because it doesn't allow 3rd party to inject a category on top the others.
363 - $this->categories = array_merge_recursive( [
364 - self::CATEGORY_FAVORITES => [
365 - 'title' => esc_html__( 'Favorites', 'elementor' ),
366 - 'icon' => 'eicon-heart',
367 - 'sort' => 'a-z',
368 - 'hideIfEmpty' => false,
369 - ],
370 - ], $this->categories );
371 -
372 306 /**
373 307 * When categories are registered.
374 308 *
375 309 * Fires after basic categories are registered, before WordPress
@@ -383,10 +317,12 @@
383 317 * @param Elements_Manager $this Elements manager instance.
384 318 */
385 319 do_action( 'elementor/elements/categories_registered', $this );
386 320
387 - $this->promote_category_after( self::CATEGORY_ANGIE_WIDGETS, [ self::CATEGORY_ATOMIC_FORM, self::CATEGORY_ATOMIC_ELEMENTS ] );
388 - $this->promote_category_after( self::CATEGORY_CUSTOM_WIDGETS, [ self::CATEGORY_ATOMIC_FORM, self::CATEGORY_ATOMIC_ELEMENTS ] );
321 + $this->categories['pojo'] = [
322 + 'title' => esc_html__( 'Pojo Themes', 'elementor' ),
323 + 'icon' => 'eicon-pojome',
324 + ];
389 325
390 326 $this->categories['wordpress'] = [
391 327 'title' => esc_html__( 'WordPress', 'elementor' ),
392 328 'icon' => 'eicon-wordpress',
@@ -391,55 +327,8 @@
391 327 'title' => esc_html__( 'WordPress', 'elementor' ),
392 328 'icon' => 'eicon-wordpress',
393 329 'active' => false,
394 330 ];
395 - }
396 -
397 - public function enqueue_elements_styles() {
398 - foreach ( $this->get_element_types() as $element ) {
399 - $element->enqueue_styles();
400 - }
401 - }
402 -
403 - public function enqueue_elements_scripts() {
404 - foreach ( $this->get_element_types() as $element ) {
405 - $element->enqueue_scripts();
406 - }
407 - }
408 -
409 - public function register_frontend_handlers() {
410 - foreach ( $this->get_element_types() as $element ) {
411 - $element->register_frontend_handlers();
412 - }
413 - }
414 -
415 - private function promote_category_after( string $category_name, array $after_candidates ): void {
416 - if ( ! isset( $this->categories[ $category_name ] ) ) {
417 - return;
418 - }
419 -
420 - $after = null;
421 -
422 - foreach ( $after_candidates as $candidate ) {
423 - if ( isset( $this->categories[ $candidate ] ) ) {
424 - $after = $candidate;
425 - break;
426 - }
427 - }
428 -
429 - if ( ! $after ) {
430 - return;
431 - }
432 -
433 - $category = $this->categories[ $category_name ];
434 - unset( $this->categories[ $category_name ] );
435 -
436 - $position = array_search( $after, array_keys( $this->categories ), true ) + 1;
437 - $this->categories = array_merge(
438 - array_slice( $this->categories, 0, $position, true ),
439 - [ $category_name => $category ],
440 - array_slice( $this->categories, $position, null, true )
441 - );
442 331 }
443 332
444 333 /**
445 334 * Require files.