PluginProbe
Elementor Website Builder – more than just a page builder / 3.30.1
Elementor Website Builder – more than just a page builder v3.30.1
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
← All changes | modules/global-classes/global-classes-parser.php +10 -37 4.0.93.30.1 View file →
@@ -3,12 +3,12 @@
3 3 namespace Elementor\Modules\GlobalClasses;
4 4
5 5 use Elementor\Core\Utils\Collection;
6 6 use Elementor\Modules\AtomicWidgets\Module;
7 -use Elementor\Modules\AtomicWidgets\OptIn\Opt_In;
8 -use Elementor\Core\Utils\Api\Parse_Result;
7 +use Elementor\Modules\AtomicWidgets\Parsers\Parse_Result;
9 8 use Elementor\Modules\AtomicWidgets\Parsers\Style_Parser;
10 9 use Elementor\Modules\AtomicWidgets\Styles\Style_Schema;
10 +use Elementor\Plugin;
11 11
12 12 class Global_Classes_Parser {
13 13 public static function make() {
14 14 return new static();
@@ -88,8 +88,16 @@
88 88
89 89 continue;
90 90 }
91 91
92 + if ( Plugin::$instance->experiments->is_feature_active( Module::EXPERIMENT_VERSION_3_30 ) ) {
93 + if ( in_array( $sanitized_item['label'], $existing_labels, true ) ) {
94 + $result->errors()->add( "$item_id.id", 'duplicated_class_label' );
95 +
96 + continue;
97 + }
98 + }
99 +
92 100 $sanitized_items[ $sanitized_item['id'] ] = $sanitized_item;
93 101 $existing_labels[] = $sanitized_item['label'];
94 102 }
95 103
@@ -115,41 +123,6 @@
115 123
116 124 return $result->is_valid()
117 125 ? $result->wrap( $order->values() )
118 126 : $result;
119 - }
120 -
121 - public static function check_for_duplicate_labels( array $existing_labels, array $items, array $new_items_ids ) {
122 -
123 - if ( empty( $new_items_ids ) ) {
124 - return false;
125 - }
126 - $new_added_items = array_filter( $items, fn( $item ) => in_array( $item['id'], $new_items_ids, true ) );
127 -
128 - $duplicates = [];
129 -
130 - foreach ( $new_added_items as $item_id => $item ) {
131 - if ( in_array( $item['label'], $existing_labels, true ) ) {
132 - $duplicates[] = [
133 - 'item_id' => $item_id,
134 - 'label' => $item['label'],
135 - ];
136 - }
137 - }
138 - return $duplicates;
139 - }
140 -
141 - public static function sanitize_order( array $items, array $order ): array {
142 - if ( empty( $items ) ) {
143 - return [];
144 - }
145 -
146 - $item_ids = array_keys( $items );
147 - $order = array_filter( $order, 'is_string' );
148 - $order = array_unique( $order );
149 - $order_existing = array_values( array_intersect( $order, $item_ids ) );
150 - $missing = array_diff( $item_ids, $order_existing );
151 - sort( $missing, SORT_STRING );
152 -
153 - return array_merge( $order_existing, $missing );
154 127 }
155 128 }