PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.5
Elementor Website Builder – more than just a page builder v4.0.5
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 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / modules / variables / classes / size-style-schema.php

size-style-schema.php in Elementor Website Builder – more than just a page builder 4.0.5, at modules/variables/classes/size-style-schema.php

95 lines 2.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\Variables\Classes;
4
5 use Elementor\Modules\AtomicWidgets\PropTypes\Base\Array_Prop_Type;
6 use Elementor\Modules\AtomicWidgets\PropTypes\Base\Object_Prop_Type;
7 use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
8 use Elementor\Modules\AtomicWidgets\PropTypes\Union_Prop_Type;
9 use Elementor\Modules\Variables\PropTypes\Size_Variable_Prop_Type;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 class Size_Style_Schema {
16 private $blacklist = [
17 'box-shadow',
18 'filter',
19 'backdrop-filter',
20 'transform',
21 'transition',
22 ];
23
24 private function ignore( $css_property ): bool {
25 if ( in_array( $css_property, $this->blacklist, true ) ) {
26 return true;
27 }
28
29 return false;
30 }
31
32 public function augment( array $schema ): array {
33 foreach ( $schema as $css_property => $prop_type ) {
34 if ( $this->ignore( $css_property ) ) {
35 continue;
36 }
37
38 $schema[ $css_property ] = $this->update( $prop_type );
39 }
40
41 return $schema;
42 }
43
44 private function update( $prop_type ) {
45 if ( $prop_type instanceof Size_Prop_Type ) {
46 return $this->update_size( $prop_type );
47 }
48
49 if ( $prop_type instanceof Union_Prop_Type ) {
50 return $this->update_union( $prop_type );
51 }
52
53 if ( $prop_type instanceof Object_Prop_Type ) {
54 return $this->update_object( $prop_type );
55 }
56
57 if ( $prop_type instanceof Array_Prop_Type ) {
58 return $this->update_array( $prop_type );
59 }
60
61 return $prop_type;
62 }
63
64 private function update_size( Size_Prop_Type $size_prop_type ): Union_Prop_Type {
65 return Union_Prop_Type::create_from( $size_prop_type )
66 ->add_prop_type( Size_Variable_Prop_Type::make() );
67 }
68
69 private function update_array( Array_Prop_Type $array_prop_type ): Array_Prop_Type {
70 return $array_prop_type->set_item_type(
71 $this->update( $array_prop_type->get_item_type() )
72 );
73 }
74
75 private function update_object( Object_Prop_Type $object_prop_type ): Object_Prop_Type {
76 return $object_prop_type->set_shape(
77 $this->augment( $object_prop_type->get_shape() )
78 );
79 }
80
81 private function update_union( Union_Prop_Type $union_prop_type ): Union_Prop_Type {
82 foreach ( $union_prop_type->get_prop_types() as $prop_type ) {
83 $updated = $this->update( $prop_type );
84
85 if ( $updated instanceof Union_Prop_Type ) {
86 foreach ( $updated->get_prop_types() as $updated_prop_type ) {
87 $union_prop_type->add_prop_type( $updated_prop_type );
88 }
89 }
90 }
91
92 return $union_prop_type;
93 }
94 }
95