PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.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 / atomic-widgets / styles / local-style-serializer.php

local-style-serializer.php in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at modules/atomic-widgets/styles/local-style-serializer.php

39 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\AtomicWidgets\Styles;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 /**
10 * Projects an element's stored `styles` map into the MCP round-trip shape:
11 *
12 * [
13 * '__style_id' => 'e-widget1-abc1234',
14 * 'css' => 'color: red; &:hover { color: blue; } @media(--mobile) { ... }',
15 * ]
16 *
17 * The `css` value follows the same raw CSS format that the write-side tools
18 * (manage-classes, manage-elements.update.style, build-composition.style)
19 * accept as input, so consumers can round-trip styles without transformation.
20 *
21 * Rendering itself is delegated to `Local_Style` / `Local_Style_Variant` so each
22 * domain object owns its own CSS output — the serializer only adapts the shape.
23 */
24 class Local_Style_Serializer {
25
26 public static function serialize( array $styles ): array {
27 $local_style = Local_Style::from_styles_map( $styles );
28
29 if ( null === $local_style ) {
30 return [];
31 }
32
33 return [
34 '__style_id' => $local_style->id(),
35 'css' => $local_style->to_css(),
36 ];
37 }
38 }
39