PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.5.2
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.5.2
2.1.3 2.1.2 2.1.1 2.1.0 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 trunk 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 All 57 releases
darkify / src / Admin / Framework / fields / border / border.php

border.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.5.2, at src/Admin/Framework/fields/border/border.php

236 lines 10.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Framework border field.
4 *
5 * @package darkify
6 * @subpackage darkify/public
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 die;
11 } // Cannot access directly.
12
13 if ( ! class_exists( 'DarkifyField_border' ) ) {
14 /**
15 *
16 * Field: border
17 *
18 * @since 1.0.0
19 * @version 1.0.0
20 */
21 class DarkifyField_border extends DarkifyFields {
22
23 /**
24 * Field constructor.
25 *
26 * @param array $field The field type.
27 * @param string $value The values of the field.
28 * @param string $unique The unique ID for the field.
29 * @param string $where To where show the output CSS.
30 * @param string $parent The parent args.
31 */
32 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
33
34 parent::__construct( $field, $value, $unique, $where, $parent );
35 }
36
37 /**
38 * Render field
39 *
40 * @return void
41 */
42 public function render() {
43
44 $args = wp_parse_args(
45 $this->field,
46 array(
47 'top_icon' => '<i class="icofont-long-arrow-up"></i>',
48 'left_icon' => '<i class="icofont-long-arrow-left"></i>',
49 'bottom_icon' => '<i class="icofont-long-arrow-down"></i>',
50 'right_icon' => '<i class="icofont-long-arrow-right"></i>',
51 'all_icon' => '<i class="icofont-justify-all"></i>',
52 'radius_icon' => '<i class="icofont-expand"></i>',
53 'top_placeholder' => esc_html__( 'top', 'darkify' ),
54 'right_placeholder' => esc_html__( 'right', 'darkify' ),
55 'bottom_placeholder' => esc_html__( 'bottom', 'darkify' ),
56 'left_placeholder' => esc_html__( 'left', 'darkify' ),
57 'all_placeholder' => esc_html__( 'all', 'darkify' ),
58 'top' => true,
59 'left' => true,
60 'bottom' => true,
61 'right' => true,
62 'all' => false,
63 'radius' => false,
64 'color' => true,
65 'color2' => true,
66 'color3' => true,
67 'style' => true,
68 'unit' => 'px',
69 )
70 );
71
72 $default_value = array(
73 'top' => '',
74 'right' => '',
75 'bottom' => '',
76 'left' => '',
77 'color' => '',
78 'style' => 'solid',
79 'all' => '',
80 'radius' => '',
81 );
82
83 $border_props = array(
84 'solid' => esc_html__( 'Solid', 'darkify' ),
85 'dashed' => esc_html__( 'Dashed', 'darkify' ),
86 'dotted' => esc_html__( 'Dotted', 'darkify' ),
87 'double' => esc_html__( 'Double', 'darkify' ),
88 'inset' => esc_html__( 'Inset', 'darkify' ),
89 'outset' => esc_html__( 'Outset', 'darkify' ),
90 'groove' => esc_html__( 'Groove', 'darkify' ),
91 'ridge' => esc_html__( 'ridge', 'darkify' ),
92 'none' => esc_html__( 'None', 'darkify' ),
93 );
94
95 $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
96
97 $value = wp_parse_args( $this->value, $default_value );
98
99 echo wp_kses_post( $this->field_before() );
100 echo '<div class="darkify--inputs">';
101 if ( ! empty( $args['all'] ) ) {
102
103 $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . $args['all_placeholder'] . '"' : '';
104
105 echo '<div class="darkify--input">';
106 echo '<div class="darkify--title">Width</div>';
107 echo ( ! empty( $args['all_icon'] ) ) ? '<span class="darkify--label darkify--icon">' . wp_kses_post( $args['all_icon'] ) . '</span>' : '';
108 echo '<input type="number" name="' . esc_attr( $this->field_name( '[all]' ) ) . '" value="' . esc_attr( $value['all'] ) . '"' . wp_kses_post( $placeholder ) . ' class="darkify-number darkify--is-unit" />';
109 echo ( ! empty( $args['unit'] ) ) ? '<span class="darkify--label darkify--unit">' . esc_html( $args['unit'] ) . '</span>' : '';
110 echo '</div>';
111 } else {
112 $properties = array();
113 foreach ( array( 'top', 'right', 'bottom', 'left' ) as $prop ) {
114 if ( ! empty( $args[ $prop ] ) ) {
115 $properties[] = $prop;
116 }
117 }
118
119 $properties = ( array( 'right', 'left' ) === $properties ) ? array_reverse( $properties ) : $properties;
120
121 foreach ( $properties as $property ) {
122 $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . $args[ $property . '_placeholder' ] . '"' : '';
123
124 echo '<div class="darkify--input">';
125 echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '<span class="darkify--label darkify--icon">' . wp_kses_post( $args[ $property . '_icon' ] ) . '</span>' : '';
126 echo '<div class="darkify--title">width</div>';
127 echo '<input type="number" name="' . esc_attr( $this->field_name( '[' . $property . ']' ) ) . '" value="' . esc_attr( $value[ $property ] ) . '"' . wp_kses_post( $placeholder ) . ' class="darkify-number darkify--is-unit" />';
128 echo ( ! empty( $args['unit'] ) ) ? '<span class="darkify--label darkify--unit">' . esc_html( $args['unit'] ) . '</span>' : '';
129 echo '</div>';
130
131 }
132 }
133
134 if ( ! empty( $args['style'] ) ) {
135 echo '<div class="darkify--input">';
136 echo '<div class="darkify--title">' . esc_html__( 'Style', 'darkify' ) . '</div>';
137 echo '<select name="' . esc_attr( $this->field_name( '[style]' ) ) . '">';
138 foreach ( $border_props as $border_prop_key => $border_prop_value ) {
139 $selected = ( $value['style'] === $border_prop_key ) ? ' selected' : '';
140 echo '<option value="' . esc_attr( $border_prop_key ) . '"' . esc_attr( $selected ) . '>' . esc_html( $border_prop_value ) . '</option>';
141 }
142 echo '</select>';
143 echo '</div>';
144 }
145
146 echo '</div>';
147 if ( ! empty( $args['color'] ) ) {
148 $default_color_attr = ( ! empty( $default_value['color'] ) ) ? ' data-default-color="' . $default_value['color'] . '"' : '';
149 echo '<div class="darkify--left darkify-field-color">';
150 echo '<div class="darkify--title">' . esc_html__( 'Light Color', 'darkify' ) . '</div>';
151 echo '<input type="text" name="' . esc_attr( $this->field_name( '[color]' ) ) . '" value="' . esc_attr( $value['color'] ) . '" class="darkify-color"' . wp_kses_post( $default_color_attr ) . ' />';
152 echo '</div>';
153 }
154 if ( ! empty( $args['color2'] ) ) {
155 $default_color_attr = ( ! empty( $default_value['color2'] ) ) ? ' data-default-color="' . $default_value['color'] . '"' : '';
156 echo '<div class="darkify--left darkify-field-color">';
157 echo '<div class="darkify--title">' . esc_html__( 'Active', 'darkify' ) . '</div>';
158 echo '<input type="text" name="' . esc_attr( $this->field_name( '[color2]' ) ) . '" value="' . esc_attr( $value['color2'] ) . '" class="darkify-color"' . wp_kses_post( $default_color_attr ) . ' />';
159 echo '</div>';
160 }
161 if ( ! empty( $args['color3'] ) ) {
162 $default_color_attr = ( ! empty( $default_value['color3'] ) ) ? ' data-default-color="' . $default_value['color3'] . '"' : '';
163 echo '<div class="darkify--left darkify-field-color">';
164 echo '<div class="darkify--title">' . esc_html__( 'Dark Color', 'darkify' ) . '</div>';
165 echo '<input type="text" name="' . esc_attr( $this->field_name( '[color3]' ) ) . '" value="' . esc_attr( $value['color3'] ) . '" class="darkify-color"' . wp_kses_post( $default_color_attr ) . ' />';
166 echo '</div>';
167 }
168 if ( ! empty( $args['radius'] ) ) {
169
170 $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . $args['all_placeholder'] . '"' : '';
171 echo '<div class="darkify--input">';
172 echo '<div class="darkify--title">' . esc_html__( 'Radius', 'darkify' ) . '</div>';
173 echo ( ! empty( $args['all_icon'] ) ) ? '<span class="darkify--label darkify--icon">' . wp_kses_post( $args['radius_icon'] ) . '</span>' : '';
174
175 echo '<input type="number" name="' . esc_attr( $this->field_name( '[radius]' ) ) . '" value="' . esc_attr( $value['radius'] ) . '"' . wp_kses_post( $placeholder ) . ' class="darkify-number darkify--is-unit" />';
176 echo ( ! empty( $args['unit'] ) ) ? '<span class="darkify--label darkify--unit">' . esc_html( $args['unit'] ) . '</span>' : '';
177 echo '</div>';
178
179 }
180 echo '<div class="clear"></div>';
181
182 echo wp_kses_post( $this->field_after() );
183
184 }
185
186 /**
187 * Output
188 *
189 * @return statement
190 */
191 public function output() {
192
193 $output = '';
194 $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
195 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
196 $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
197
198 // properties.
199 $top = ( isset( $this->value['top'] ) && '' !== $this->value['top'] ) ? $this->value['top'] : '';
200 $right = ( isset( $this->value['right'] ) && '' !== $this->value['right'] ) ? $this->value['right'] : '';
201 $bottom = ( isset( $this->value['bottom'] ) && '' !== $this->value['bottom'] ) ? $this->value['bottom'] : '';
202 $left = ( isset( $this->value['left'] ) && '' !== $this->value['left'] ) ? $this->value['left'] : '';
203 $style = ( isset( $this->value['style'] ) && '' !== $this->value['style'] ) ? $this->value['style'] : '';
204 $color = ( isset( $this->value['color'] ) && '' !== $this->value['color'] ) ? $this->value['color'] : '';
205 $all = ( isset( $this->value['all'] ) && '' !== $this->value['all'] ) ? $this->value['all'] : '';
206
207 if ( ! empty( $this->field['all'] ) && ( '' !== $all || '' !== $color ) ) {
208
209 $output = $element . '{';
210 $output .= ( '' !== $all ) ? 'border-width:' . $all . $unit . $important . ';' : '';
211 $output .= ( '' !== $color ) ? 'border-color:' . $color . $important . ';' : '';
212 $output .= ( '' !== $style ) ? 'border-style:' . $style . $important . ';' : '';
213 $output .= '}';
214
215 } elseif ( '' !== $top || '' !== $right || '' !== $bottom || '' !== $left || '' !== $color ) {
216
217 $output = $element . '{';
218 $output .= ( '' !== $top ) ? 'border-top-width:' . $top . $unit . $important . ';' : '';
219 $output .= ( '' !== $right ) ? 'border-right-width:' . $right . $unit . $important . ';' : '';
220 $output .= ( '' !== $bottom ) ? 'border-bottom-width:' . $bottom . $unit . $important . ';' : '';
221 $output .= ( '' !== $left ) ? 'border-left-width:' . $left . $unit . $important . ';' : '';
222 $output .= ( '' !== $color ) ? 'border-color:' . $color . $important . ';' : '';
223 $output .= ( '' !== $style ) ? 'border-style:' . $style . $important . ';' : '';
224 $output .= '}';
225
226 }
227
228 $this->parent->output_css .= $output;
229
230 return $output;
231
232 }
233
234 }
235 }
236