PluginProbe
Elementor Website Builder – more than just a page builder / 4.1.0-beta3
Elementor Website Builder – more than just a page builder v4.1.0-beta3
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
elementor / modules / global-classes / utils / global-class-data-normalizer.php

global-class-data-normalizer.php in Elementor Website Builder – more than just a page builder 4.1.0-beta3, at modules/global-classes/utils/global-class-data-normalizer.php

43 lines 972 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\GlobalClasses\Utils;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly.
7 }
8
9 class Global_Class_Data_Normalizer {
10 public static function normalize_styles( array $raw_items ): array {
11 $normalized = [];
12
13 foreach ( $raw_items as $class_id => $class_data ) {
14 $normalized[ $class_id ] = self::normalize_style( $class_id, $class_data );
15 }
16
17 return $normalized;
18 }
19
20 public static function normalize_style( string $class_id, array $class_data ): array {
21 return array_merge(
22 [
23 'id' => $class_id,
24 'label' => $class_data['label'] ?? $class_id,
25 ],
26 self::normalize_style_fields( $class_data )
27 );
28 }
29
30 public static function normalize_style_fields( array $item ): array {
31 $data = [
32 'type' => $item['type'] ?? 'class',
33 'variants' => $item['variants'] ?? [],
34 ];
35
36 if ( array_key_exists( 'sync_to_v3', $item ) ) {
37 $data['sync_to_v3'] = (bool) $item['sync_to_v3'];
38 }
39
40 return $data;
41 }
42 }
43