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 / atomic-widgets / css-converter / property-converter-base.php

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

60 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 Property_Converter_Base implements Property_Converter {
10 /**
11 * Exact, enumerated property names this converter 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 convert( Conversion_Context $context, array $rule ): bool {
28 $custom = $this->get_custom_converter( $context, $rule );
29
30 if ( null !== $custom ) {
31 return $custom();
32 }
33
34 if ( null === $rule['value'] ) {
35 return $this->convert_null( $context, $rule );
36 }
37
38 return $this->do_convert( $context, $rule );
39 }
40
41 /**
42 * Override to handle special-case rules before the standard null-check and do_convert path.
43 * Receives the full rule (value may be null). Return null to fall through to default behavior.
44 */
45 protected function get_custom_converter( Conversion_Context $context, array $rule ): ?callable {
46 return null;
47 }
48
49 /**
50 * Override to customize null-reset behavior. Default: set the prop to null directly.
51 */
52 protected function convert_null( Conversion_Context $context, array $rule ): bool {
53 $context->set_prop( $rule['property'], null );
54
55 return true;
56 }
57
58 abstract protected function do_convert( Conversion_Context $context, array $rule ): bool;
59 }
60