PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
4.3.0-beta3 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 All 452 releases
elementor / modules / components / utils / strip-component-instances.php

strip-component-instances.php in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at modules/components/utils/strip-component-instances.php

43 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\Components\Utils;
4
5 use Elementor\Modules\Components\PropTypes\Component_Instance_Prop_Type;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly.
9 }
10
11 /**
12 * Removes every `e-component` widget from an elements tree.
13 *
14 * Used at import time when components round-trip is disabled, to clean up any dangling
15 * `e-component` widgets that survived from a zip exported before the flag or by an
16 * external site. Dangling instances would point at nonexistent component posts and
17 * either render empty or throw in the editor panel.
18 */
19 class Strip_Component_Instances {
20 public static function apply( array $elements ): array {
21 $result = [];
22
23 foreach ( $elements as $element ) {
24 if ( ! is_array( $element ) ) {
25 $result[] = $element;
26 continue;
27 }
28
29 if ( Component_Instance_Prop_Type::is_instance_element( $element ) ) {
30 continue;
31 }
32
33 if ( ! empty( $element['elements'] ) && is_array( $element['elements'] ) ) {
34 $element['elements'] = self::apply( $element['elements'] );
35 }
36
37 $result[] = $element;
38 }
39
40 return $result;
41 }
42 }
43