PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.0-dev3
Elementor Website Builder – more than just a page builder v3.32.0-dev3
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 | modules/global-classes/global-classes-parser.php +10 -36 4.0.73.32.0-dev3 View file →
@@ -3,12 +3,13 @@
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;
7 +use Elementor\Modules\AtomicWidgets\Opt_In;
8 8 use Elementor\Core\Utils\Api\Parse_Result;
9 9 use Elementor\Modules\AtomicWidgets\Parsers\Style_Parser;
10 10 use Elementor\Modules\AtomicWidgets\Styles\Style_Schema;
11 +use Elementor\Plugin;
11 12
12 13 class Global_Classes_Parser {
13 14 public static function make() {
14 15 return new static();
@@ -88,8 +89,16 @@
88 89
89 90 continue;
90 91 }
91 92
93 + if ( Plugin::$instance->experiments->is_feature_active( Opt_In::EXPERIMENT_NAME ) ) {
94 + if ( in_array( $sanitized_item['label'], $existing_labels, true ) ) {
95 + $result->errors()->add( "$item_id.id", 'duplicated_class_label' );
96 +
97 + continue;
98 + }
99 + }
100 +
92 101 $sanitized_items[ $sanitized_item['id'] ] = $sanitized_item;
93 102 $existing_labels[] = $sanitized_item['label'];
94 103 }
95 104
@@ -115,41 +124,6 @@
115 124
116 125 return $result->is_valid()
117 126 ? $result->wrap( $order->values() )
118 127 : $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 128 }
155 129 }