PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0
Elementor Website Builder – more than just a page builder v4.3.0
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
elementor / modules / mcp / abilities / appliers / v3 / mapper / unmapped-css-serializer.php

unmapped-css-serializer.php in Elementor Website Builder – more than just a page builder 4.3.0, at modules/mcp/abilities/appliers/v3/mapper/unmapped-css-serializer.php

54 lines 1.4 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\Mcp\Abilities\Appliers\V3\Mapper;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 /**
10 * Re-serializes CSS fragments that could not be mapped to V3 settings, back into a
11 * single CSS string suitable for V3's `custom_css`. Wraps state fragments as `&:state`
12 * and non-desktop breakpoints as `@media(--breakpoint) { ... }`.
13 */
14 class Unmapped_Css_Serializer {
15
16 public function serialize_declaration( string $breakpoint, ?string $state, string $property, string $value ): string {
17 $decl = $property . ': ' . $value . ';';
18
19 if ( null !== $state ) {
20 $decl = '&:' . $state . ' { ' . $decl . ' }';
21 }
22
23 return $this->serialize_breakpoint_block( $breakpoint, $decl );
24 }
25
26 public function serialize_nested_block( string $breakpoint, string $selector, string $css ): string {
27 $inner = '&' . $selector . ' { ' . trim( $css ) . ' }';
28
29 return $this->serialize_breakpoint_block( $breakpoint, $inner );
30 }
31
32 public function serialize_breakpoint_block( string $breakpoint, string $css ): string {
33 $css = trim( $css );
34 if ( '' === $css ) {
35 return '';
36 }
37
38 if ( Responsive_Key_Resolver::BASE_BREAKPOINT === $breakpoint ) {
39 return $css;
40 }
41
42 return '@media(--' . $breakpoint . ') { ' . $css . ' }';
43 }
44
45 /**
46 * @param string[] $parts
47 */
48 public function join( array $parts ): string {
49 $parts = array_values( array_filter( array_map( 'trim', $parts ) ) );
50
51 return implode( ' ', $parts );
52 }
53 }
54