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