| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\DefaultStyles\Utils; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
class Default_Style_Data_Normalizer { |
| 10 |
const CSS_NAME_PREFIX = 'e-default-'; |
| 11 |
|
| 12 |
public static function normalize_style( string $tag, array $data ): array { |
| 13 |
return array_merge( |
| 14 |
[ |
| 15 |
'id' => $tag, |
| 16 |
'label' => $tag, |
| 17 |
'cssName' => self::CSS_NAME_PREFIX . $tag, |
| 18 |
], |
| 19 |
self::normalize_style_fields( $data ) |
| 20 |
); |
| 21 |
} |
| 22 |
|
| 23 |
public static function normalize_style_fields( array $item ): array { |
| 24 |
return [ |
| 25 |
'type' => $item['type'] ?? 'class', |
| 26 |
'variants' => $item['variants'] ?? [], |
| 27 |
]; |
| 28 |
} |
| 29 |
} |
| 30 |
|