PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.3
Elementor Website Builder – more than just a page builder v3.26.3
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 +8 -101 4.0.73.26.3 View file →
@@ -16,13 +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 -
25 20 /**
26 21 * Element types.
27 22 *
28 23 * Holds the list of all the element types.
@@ -39,9 +34,9 @@
39 34 * Holds the list of all the element categories.
40 35 *
41 36 * @access private
42 37 *
43 - * @var $categories
38 + * @var
44 39 */
45 40 private $categories;
46 41
47 42 /**
@@ -71,11 +66,15 @@
71 66 *
72 67 * @return Element_Base|null Element instance if element created, or null
73 68 * otherwise.
74 69 */
75 - 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 ) {
76 71 if ( null === $element_type ) {
77 - $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 + }
78 77 }
79 78
80 79 if ( ! $element_type ) {
81 80 return null;
@@ -93,20 +92,8 @@
93 92
94 93 return $element;
95 94 }
96 95
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 96 /**
110 97 * Get element categories.
111 98 *
112 99 * Retrieve the list of categories the element belongs to.
@@ -288,12 +275,8 @@
288 275 * @access private
289 276 */
290 277 private function init_categories() {
291 278 $this->categories = [
292 - self::CATEGORY_ATOMIC_ELEMENTS => [
293 - 'title' => esc_html__( 'Atomic Elements', 'elementor' ),
294 - 'hideIfEmpty' => true,
295 - ],
296 279 'layout' => [
297 280 'title' => esc_html__( 'Layout', 'elementor' ),
298 281 'hideIfEmpty' => true,
299 282 ],
@@ -306,12 +289,8 @@
306 289 'promotion' => [
307 290 'url' => esc_url( 'https://go.elementor.com/go-pro-section-pro-widget-panel/' ),
308 291 ],
309 292 ],
310 - 'helloplus' => [
311 - 'title' => esc_html__( 'Hello+', 'elementor' ),
312 - 'hideIfEmpty' => true,
313 - ],
314 293 'general' => [
315 294 'title' => esc_html__( 'General', 'elementor' ),
316 295 'icon' => 'eicon-font',
317 296 ],
@@ -334,34 +313,11 @@
334 313 ],
335 314 ],
336 315 ];
337 316
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 317 // Not using the `add_category` because it doesn't allow 3rd party to inject a category on top the others.
362 318 $this->categories = array_merge_recursive( [
363 - self::CATEGORY_FAVORITES => [
319 + 'favorites' => [
364 320 'title' => esc_html__( 'Favorites', 'elementor' ),
365 321 'icon' => 'eicon-heart',
366 322 'sort' => 'a-z',
367 323 'hideIfEmpty' => false,
@@ -382,62 +338,13 @@
382 338 * @param Elements_Manager $this Elements manager instance.
383 339 */
384 340 do_action( 'elementor/elements/categories_registered', $this );
385 341
386 - $this->promote_category_after( self::CATEGORY_ANGIE_WIDGETS, [ self::CATEGORY_ATOMIC_FORM, self::CATEGORY_ATOMIC_ELEMENTS ] );
387 -
388 342 $this->categories['wordpress'] = [
389 343 'title' => esc_html__( 'WordPress', 'elementor' ),
390 344 'icon' => 'eicon-wordpress',
391 345 'active' => false,
392 346 ];
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 347 }
441 348
442 349 /**
443 350 * Require files.