Edit File by line
/home/zeestwma/ceyloniy.../wp-conte.../plugins/elemento.../modules/componen.../utils
File: parsing-utils.php
<?php
[0] Fix | Delete
namespace Elementor\Modules\Components\Utils;
[1] Fix | Delete
[2] Fix | Delete
use Elementor\Plugin;
[3] Fix | Delete
use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Element_Base;
[4] Fix | Delete
use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Widget_Base;
[5] Fix | Delete
use Elementor\Modules\AtomicWidgets\Utils\Utils;
[6] Fix | Delete
use Elementor\Modules\AtomicWidgets\PropTypes\Contracts\Prop_Type;
[7] Fix | Delete
[8] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[9] Fix | Delete
exit; // Exit if accessed directly.
[10] Fix | Delete
}
[11] Fix | Delete
[12] Fix | Delete
class Parsing_Utils {
[13] Fix | Delete
public static function get_prop_type( string $el_type, string $widget_type, string $prop_key ): Prop_Type {
[14] Fix | Delete
$element = Plugin::$instance->elements_manager->get_element( $el_type, $widget_type );
[15] Fix | Delete
[16] Fix | Delete
if ( ! $element ) {
[17] Fix | Delete
throw new \Exception( esc_html( "Invalid element: Element type $el_type with widget type $widget_type is not registered." ) );
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
$element_instance = new $element();
[21] Fix | Delete
[22] Fix | Delete
/** @var Atomic_Element_Base | Atomic_Widget_Base $element_instance */
[23] Fix | Delete
if ( ! Utils::is_atomic( $element_instance ) ) {
[24] Fix | Delete
throw new \Exception( esc_html( "Invalid element: Element type $el_type with widget type $widget_type is not an atomic element/widget." ) );
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
$props_schema = $element_instance->get_props_schema();
[28] Fix | Delete
[29] Fix | Delete
if ( ! isset( $props_schema[ $prop_key ] ) ) {
[30] Fix | Delete
throw new \Exception( esc_html( "Prop key '$prop_key' does not exist in the schema of element '{$element_instance->get_element_type()}'." ) );
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
return $props_schema[ $prop_key ];
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
public static function get_duplicates( array $array ): array {
[37] Fix | Delete
$duplicates = [];
[38] Fix | Delete
$seen = [];
[39] Fix | Delete
[40] Fix | Delete
foreach ( $array as $item ) {
[41] Fix | Delete
if ( in_array( $item, $seen, true ) ) {
[42] Fix | Delete
if ( ! in_array( $item, $duplicates, true ) ) {
[43] Fix | Delete
$duplicates[] = $item;
[44] Fix | Delete
}
[45] Fix | Delete
} else {
[46] Fix | Delete
$seen[] = $item;
[47] Fix | Delete
}
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
return $duplicates;
[51] Fix | Delete
}
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function