PluginProbe
Elementor Website Builder – more than just a page builder / 3.29.0-beta4
Elementor Website Builder – more than just a page builder v3.29.0-beta4
4.3.2 4.3.1 4.3.0 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 All 455 releases
← All changes | modules/global-classes/global-classes-parser.php +1 -40 4.0.9 → 3.29.0-beta4 View file →
@@ -2,11 +2,9 @@
2 2
3 3 namespace Elementor\Modules\GlobalClasses;
4 4
5 5 use Elementor\Core\Utils\Collection;
6 -use Elementor\Modules\AtomicWidgets\Module;
7 -use Elementor\Modules\AtomicWidgets\OptIn\Opt_In;
8 -use Elementor\Core\Utils\Api\Parse_Result;
6 +use Elementor\Modules\AtomicWidgets\Parsers\Parse_Result;
9 7 use Elementor\Modules\AtomicWidgets\Parsers\Style_Parser;
10 8 use Elementor\Modules\AtomicWidgets\Styles\Style_Schema;
11 9
12 10 class Global_Classes_Parser {
@@ -69,9 +67,8 @@
69 67 public function parse_items( array $items ) {
70 68 $sanitized_items = [];
71 69 $result = Parse_Result::make();
72 70 $style_parser = Style_Parser::make( Style_Schema::get() );
73 - $existing_labels = [];
74 71
75 72 foreach ( $items as $item_id => $item ) {
76 73 $item_result = $style_parser->parse( $item );
77 74
@@ -89,9 +86,8 @@
89 86 continue;
90 87 }
91 88
92 89 $sanitized_items[ $sanitized_item['id'] ] = $sanitized_item;
93 - $existing_labels[] = $sanitized_item['label'];
94 90 }
95 91
96 92 return $result->wrap( $sanitized_items );
97 93 }
@@ -115,41 +111,6 @@
115 111
116 112 return $result->is_valid()
117 113 ? $result->wrap( $order->values() )
118 114 : $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 115 }
155 116 }