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.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 4.0.8 All 454 releases
elementor / modules / atomic-widgets / css-converter / shorthand-expander-base.php

shorthand-expander-base.php in Elementor Website Builder – more than just a page builder 4.3.0, at modules/atomic-widgets/css-converter/shorthand-expander-base.php

62 lines 1.6 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\CssConverter;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly.
7 }
8
9 abstract class Shorthand_Expander_Base implements Shorthand_Expander {
10 /**
11 * Exact, enumerated shorthand property names this expander owns.
12 *
13 * @return string[]
14 */
15 abstract protected function get_supported_properties(): array;
16
17 public function is_supported( array $rule ): bool {
18 $property = $rule['property'] ?? null;
19
20 if ( ! is_string( $property ) || '' === $property ) {
21 return false;
22 }
23
24 return in_array( $property, $this->get_supported_properties(), true );
25 }
26
27 public function expand( array $rule ): array {
28 if ( null === $rule['value'] ) {
29 return $this->expand_null( $rule );
30 }
31
32 return $this->do_expand( $rule );
33 }
34
35 /**
36 * Override to fan out null resets to all longhand properties.
37 * Default: re-emit the same property with a null value (covers simple renamers).
38 *
39 * @return array<int, array{property: string, value: null, declaration: string}>
40 */
41 protected function expand_null( array $rule ): array {
42 return [ $this->null_rule( $rule['property'] ) ];
43 }
44
45 /**
46 * @return array{property: string, value: null, declaration: string}
47 */
48 protected function null_rule( string $property ): array {
49 return [
50 'property' => $property,
51 'value' => null,
52 'declaration' => $property . ': ',
53 ];
54 }
55
56 /**
57 * @param array{property: string, value: string} $rule A rule with a guaranteed non-null value.
58 * @return array<int, array{property: string, value: string, declaration: string}>
59 */
60 abstract protected function do_expand( array $rule ): array;
61 }
62