PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.4.7
JetFormBuilder — Dynamic Blocks Form Builder v3.4.7
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / modules / jet-style / css-compilers / border-css-compiler.php
jetformbuilder / modules / jet-style / css-compilers Last commit date
base-css-compiler.php 2 years ago border-css-compiler.php 2 years ago border-radius-css-compiler.php 2 years ago
border-css-compiler.php
124 lines
1 <?php
2
3
4 namespace JFB_Modules\Jet_Style\Css_Compilers;
5
6 use Jet_Form_Builder\Classes\Arrayable\Array_Tools;
7
8 // If this file is called directly, abort.
9 if ( ! defined( 'WPINC' ) ) {
10 die;
11 }
12
13 /**
14 * @since 3.1.0
15 *
16 * Class Border_Css_Compiler
17 * @package Jet_Form_Builder\Compatibility\Wp_Experiments\Css_Compilers
18 */
19 class Border_Css_Compiler extends Base_Css_Compiler {
20
21 const SIDES = array( 'top', 'right', 'bottom', 'left' );
22
23 // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
24 public function is_supported( array $path ): bool {
25 return 'border' === Array_Tools::last( $path );
26 }
27
28 public function compile_declarations(
29 \WP_Style_Engine_CSS_Declarations $declarations,
30 array $root_styles,
31 array &$class_names
32 ) {
33 $base_border = Array_Tools::get( $root_styles, $this->path, array() );
34
35 if ( empty( $base_border ) || ! is_array( $base_border ) ) {
36 return;
37 }
38
39 $is_hover = $this->has_hover_path();
40
41 foreach ( array( 'style', 'width', 'color' ) as $type ) {
42 $top_value = $this->get_side_value( $base_border, 'top', $type );
43
44 $declarations->add_declaration(
45 $this->get_top_var( $type ),
46 $top_value
47 );
48
49 $right_value = $this->get_side_value( $base_border, 'right', $type );
50
51 $declarations->add_declaration(
52 $this->get_right_var( $type ),
53 $right_value
54 );
55
56 $bottom_value = $this->get_side_value( $base_border, 'bottom', $type );
57
58 $declarations->add_declaration(
59 $this->get_bottom_var( $type ),
60 $bottom_value
61 );
62
63 $left_value = $this->get_side_value( $base_border, 'left', $type );
64
65 $declarations->add_declaration(
66 $this->get_left_var( $type ),
67 $left_value
68 );
69
70 if ( ! $is_hover ) {
71 continue;
72 }
73
74 // get not empty values
75 $values = array_filter( array( $top_value, $right_value, $bottom_value, $left_value ) );
76
77 if ( count( $values ) ) {
78 $class_names[] = 'has-hover-border-' . $type;
79 }
80 }
81 }
82
83 public function compile_class_names( array &$class_names, array $root_styles ) {
84 // do nothing
85 }
86
87 public function is_linked( $value ): bool {
88 $first_key = array_keys( $value )[0] ?? '';
89
90 return in_array( $first_key, self::SIDES, true );
91 }
92
93 public function get_side_value( $value, string $side, $property ): string {
94 if ( ! in_array( $side, self::SIDES, true ) ) {
95 return '';
96 }
97
98 if ( $this->is_linked( $value ) ) {
99 $response = $value[ $side ][ $property ] ?? '';
100 } else {
101 $response = $value[ $property ] ?? '';
102 }
103
104 return trim( $response );
105 }
106
107 public function get_top_var( $type ): string {
108 return "{$this->css_var}-top-{$type}";
109 }
110
111 public function get_right_var( $type ): string {
112 return "{$this->css_var}-right-{$type}";
113 }
114
115 public function get_bottom_var( $type ): string {
116 return "{$this->css_var}-bottom-{$type}";
117 }
118
119 public function get_left_var( $type ): string {
120 return "{$this->css_var}-left-{$type}";
121 }
122
123 }
124