PluginProbe
Elementor Website Builder – more than just a page builder / 3.30.2
Elementor Website Builder – more than just a page builder v3.30.2
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 / style-schema.php

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

92 lines 2.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\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\Primitives\String_Prop_Type;
8 use Elementor\Modules\AtomicWidgets\PropTypes\Color_Prop_Type;
9 use Elementor\Modules\AtomicWidgets\PropTypes\Union_Prop_Type;
10 use Elementor\Modules\Variables\PropTypes\Color_Variable_Prop_Type;
11 use Elementor\Modules\Variables\PropTypes\Font_Variable_Prop_Type;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit; // Exit if accessed directly.
15 }
16
17 class Style_Schema {
18 public function augment( array $schema ): array {
19 foreach ( $schema as $key => $prop_type ) {
20 $schema[ $key ] = $this->update( $prop_type );
21 }
22
23 if ( isset( $schema['font-family'] ) ) {
24 $schema['font-family'] = $this->update_font_family( $schema['font-family'] );
25 }
26
27 return $schema;
28 }
29
30 private function update( $prop_type ) {
31 if ( $prop_type instanceof Color_Prop_Type ) {
32 return $this->update_color( $prop_type );
33 }
34
35 if ( $prop_type instanceof Union_Prop_Type ) {
36 return $this->update_union( $prop_type );
37 }
38
39 if ( $prop_type instanceof Object_Prop_Type ) {
40 return $this->update_object( $prop_type );
41 }
42
43 if ( $prop_type instanceof Array_Prop_Type ) {
44 return $this->update_array( $prop_type );
45 }
46
47 return $prop_type;
48 }
49
50 private function update_font_family( String_Prop_Type $prop_type ): Union_Prop_Type {
51 return Union_Prop_Type::create_from( $prop_type )
52 ->add_prop_type( Font_Variable_Prop_Type::make() );
53 }
54
55 private function update_color( Color_Prop_Type $color_prop_type ): Union_Prop_Type {
56 return Union_Prop_Type::create_from( $color_prop_type )
57 ->add_prop_type( Color_Variable_Prop_Type::make() );
58 }
59
60 private function update_array( Array_Prop_Type $array_prop_type ): Array_Prop_Type {
61 return $array_prop_type->set_item_type(
62 $this->update( $array_prop_type->get_item_type() )
63 );
64 }
65
66 private function update_object( Object_Prop_Type $object_prop_type ): Object_Prop_Type {
67 return $object_prop_type->set_shape(
68 $this->augment( $object_prop_type->get_shape() )
69 );
70 }
71
72 private function update_union( Union_Prop_Type $union_prop_type ): Union_Prop_Type {
73 $new_union = Union_Prop_Type::make();
74
75 foreach ( $union_prop_type->get_prop_types() as $prop_type ) {
76 $updated = $this->update( $prop_type );
77
78 if ( $updated instanceof Union_Prop_Type ) {
79 foreach ( $updated->get_prop_types() as $updated_prop_type ) {
80 $new_union->add_prop_type( $updated_prop_type );
81 }
82
83 continue;
84 }
85
86 $new_union->add_prop_type( $updated );
87 }
88
89 return $new_union;
90 }
91 }
92