PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.9
Elementor Website Builder – more than just a page builder v4.0.9
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
elementor / modules / components / utils / parsing-utils.php

parsing-utils.php in Elementor Website Builder – more than just a page builder 4.0.9, at modules/components/utils/parsing-utils.php

55 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Modules\Components\Utils;
3
4 use Elementor\Plugin;
5 use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Element_Base;
6 use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Widget_Base;
7 use Elementor\Modules\AtomicWidgets\Utils\Utils;
8 use Elementor\Modules\AtomicWidgets\PropTypes\Contracts\Prop_Type;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit; // Exit if accessed directly.
12 }
13
14 class Parsing_Utils {
15 public static function get_prop_type( string $el_type, string $widget_type, string $prop_key ): Prop_Type {
16 $element = Plugin::$instance->elements_manager->get_element( $el_type, $widget_type );
17
18 if ( ! $element ) {
19 throw new \Exception( esc_html( "Invalid element: Element type $el_type with widget type $widget_type is not registered." ) );
20 }
21
22 $element_instance = new $element();
23
24 /** @var Atomic_Element_Base | Atomic_Widget_Base $element_instance */
25 if ( ! Utils::is_atomic( $element_instance ) ) {
26 throw new \Exception( esc_html( "Invalid element: Element type $el_type with widget type $widget_type is not an atomic element/widget." ) );
27 }
28
29 $props_schema = $element_instance->get_props_schema();
30
31 if ( ! isset( $props_schema[ $prop_key ] ) ) {
32 throw new \Exception( esc_html( "Prop key '$prop_key' does not exist in the schema of element '{$element_instance->get_element_type()}'." ) );
33 }
34
35 return $props_schema[ $prop_key ];
36 }
37
38 public static function get_duplicates( array $array ): array {
39 $duplicates = [];
40 $seen = [];
41
42 foreach ( $array as $item ) {
43 if ( in_array( $item, $seen, true ) ) {
44 if ( ! in_array( $item, $duplicates, true ) ) {
45 $duplicates[] = $item;
46 }
47 } else {
48 $seen[] = $item;
49 }
50 }
51
52 return $duplicates;
53 }
54 }
55