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

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

53 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\Converters;
4
5 use Elementor\Modules\AtomicWidgets\CssConverter\Conversion_Context;
6 use Elementor\Modules\AtomicWidgets\CssConverter\Property_Converter_Base;
7 use Elementor\Modules\AtomicWidgets\PropTypes\Span_Prop_Type;
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12
13 /**
14 * Reusable converter for properties backed by a Span_Prop_Type (grid-column/grid-row). One instance
15 * per property. Accepts any non-empty string that matches the schema regex (URLs/semicolons are
16 * rejected by the live grid-* pattern); a non-matching value declines (-> custom_css). Emits the
17 * canonical Span PropValue from generate().
18 */
19 class Span_Property_Converter extends Property_Converter_Base {
20 private string $property;
21
22 private ?string $pattern;
23
24 /**
25 * @param string $property The schema property this converter owns.
26 * @param string|null $pattern The Span regex sourced from the schema, or null for no constraint.
27 */
28 public function __construct( string $property, ?string $pattern = null ) {
29 $this->property = $property;
30 $this->pattern = $pattern;
31 }
32
33 protected function get_supported_properties(): array {
34 return [ $this->property ];
35 }
36
37 protected function do_convert( Conversion_Context $context, array $rule ): bool {
38 $value = trim( $rule['value'] );
39
40 if ( '' === $value ) {
41 return false;
42 }
43
44 if ( null !== $this->pattern && 1 !== preg_match( $this->pattern, $value ) ) {
45 return false;
46 }
47
48 $context->set_prop( $this->property, Span_Prop_Type::generate( $value ) );
49
50 return true;
51 }
52 }
53