PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.2
Elementor Website Builder – more than just a page builder v4.3.2
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 / converter / v3-conversion-context.php

v3-conversion-context.php in Elementor Website Builder – more than just a page builder 4.3.2, at modules/mcp/abilities/appliers/v3/converter/v3-conversion-context.php

105 lines 2.3 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\Converter;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 /**
10 * Mutable per-node conversion state: accumulates the settings patch that will be
11 * merged into the V3 widget, the unmapped CSS chunks (destined for `custom_css`),
12 * warnings, and typography-group buckets which are finalized in one pass at the end.
13 */
14 class V3_Conversion_Context {
15
16 /** @var array<string, mixed> */
17 private array $settings_patch = [];
18
19 /** @var string[] */
20 private array $unmapped_parts = [];
21
22 /** @var string[] */
23 private array $warnings = [];
24
25 /**
26 * @var array<string, array{
27 * prefix: string,
28 * breakpoint: string,
29 * state: ?string,
30 * responsive: bool,
31 * declarations: array<string, string>
32 * }>
33 */
34 private array $typography_buckets = [];
35
36 /**
37 * @param array<string, mixed> $patch
38 */
39 public function merge_patch( array $patch ): void {
40 if ( empty( $patch ) ) {
41 return;
42 }
43
44 $this->settings_patch = array_merge( $this->settings_patch, $patch );
45 }
46
47 public function add_typography_declaration( string $prefix, string $breakpoint, ?string $state, bool $responsive, string $property, string $value ): void {
48 $bucket_key = $breakpoint . '|' . ( $state ?? '' ) . '|' . $prefix;
49
50 if ( ! isset( $this->typography_buckets[ $bucket_key ] ) ) {
51 $this->typography_buckets[ $bucket_key ] = [
52 'prefix' => $prefix,
53 'breakpoint' => $breakpoint,
54 'state' => $state,
55 'responsive' => $responsive,
56 'declarations' => [],
57 ];
58 }
59
60 $this->typography_buckets[ $bucket_key ]['declarations'][ $property ] = $value;
61 }
62
63 public function mark_unmapped( string $original_css ): void {
64 $trimmed = trim( $original_css );
65 if ( '' === $trimmed ) {
66 return;
67 }
68
69 $this->unmapped_parts[] = $trimmed;
70 }
71
72 public function warn( string $message ): void {
73 if ( '' === $message ) {
74 return;
75 }
76
77 $this->warnings[] = $message;
78 }
79
80 public function settings_patch(): array {
81 return $this->settings_patch;
82 }
83
84 /**
85 * @return string[]
86 */
87 public function unmapped_parts(): array {
88 return $this->unmapped_parts;
89 }
90
91 /**
92 * @return string[]
93 */
94 public function warnings(): array {
95 return $this->warnings;
96 }
97
98 /**
99 * @return array<string, array>
100 */
101 public function typography_buckets(): array {
102 return $this->typography_buckets;
103 }
104 }
105