PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.2.1
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.2.1
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 / admin / ta-framework / fields / border / border.php

border.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.2.1, at admin/ta-framework/fields/border/border.php

176 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) {
2 die; } // Cannot access directly.
3 /**
4 *
5 * Field: border
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 */
10 if ( ! class_exists( 'DRK_LITE_Field_border' ) ) {
11 class DRK_LITE_Field_border extends DRK_LITE_Fields {
12
13 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 parent::__construct( $field, $value, $unique, $where, $parent );
15 }
16
17 public function render() {
18
19 $args = wp_parse_args(
20 $this->field,
21 array(
22 'top_icon' => '<i class="fas fa-long-arrow-alt-up"></i>',
23 'left_icon' => '<i class="fas fa-long-arrow-alt-left"></i>',
24 'bottom_icon' => '<i class="fas fa-long-arrow-alt-down"></i>',
25 'right_icon' => '<i class="fas fa-long-arrow-alt-right"></i>',
26 'all_icon' => '<i class="fas fa-arrows-alt"></i>',
27 'top_placeholder' => esc_html__( 'top', 'darkify' ),
28 'right_placeholder' => esc_html__( 'right', 'darkify' ),
29 'bottom_placeholder' => esc_html__( 'bottom', 'darkify' ),
30 'left_placeholder' => esc_html__( 'left', 'darkify' ),
31 'all_placeholder' => esc_html__( 'all', 'darkify' ),
32 'top' => true,
33 'left' => true,
34 'bottom' => true,
35 'right' => true,
36 'all' => false,
37 'color' => true,
38 'style' => true,
39 'unit' => 'px',
40 )
41 );
42
43 $default_value = array(
44 'top' => '',
45 'right' => '',
46 'bottom' => '',
47 'left' => '',
48 'color' => '',
49 'style' => 'solid',
50 'all' => '',
51 );
52
53 $border_props = array(
54 'solid' => esc_html__( 'Solid', 'darkify' ),
55 'dashed' => esc_html__( 'Dashed', 'darkify' ),
56 'dotted' => esc_html__( 'Dotted', 'darkify' ),
57 'double' => esc_html__( 'Double', 'darkify' ),
58 'inset' => esc_html__( 'Inset', 'darkify' ),
59 'outset' => esc_html__( 'Outset', 'darkify' ),
60 'groove' => esc_html__( 'Groove', 'darkify' ),
61 'ridge' => esc_html__( 'ridge', 'darkify' ),
62 'none' => esc_html__( 'None', 'darkify' ),
63 );
64
65 $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
66
67 $value = wp_parse_args( $this->value, $default_value );
68
69 echo wp_kses_post( $this->field_before() );
70
71 echo '<div class="drk_lite--inputs" data-depend-id="' . esc_attr( $this->field['id'] ) . '">';
72
73 if ( ! empty( $args['all'] ) ) {
74
75 $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . esc_attr( $args['all_placeholder'] ) . '"' : '';
76
77 echo '<div class="drk_lite--input">';
78 echo ( ! empty( $args['all_icon'] ) ) ? '<span class="drk_lite--label drk_lite--icon">' . wp_kses_post($args['all_icon']) . '</span>' : '';
79 echo '<input type="number" name="' . esc_attr( $this->field_name( '[all]' ) ) . '" value="' . esc_attr( $value['all'] ) . '"' . wp_kses_post($placeholder) . ' class="drk_lite-input-number drk_lite--is-unit" step="any" />';
80 echo ( ! empty( $args['unit'] ) ) ? '<span class="drk_lite--label drk_lite--unit">' . esc_attr( $args['unit'] ) . '</span>' : '';
81 echo '</div>';
82
83 } else {
84
85 $properties = array();
86
87 foreach ( array( 'top', 'right', 'bottom', 'left' ) as $prop ) {
88 if ( ! empty( $args[ $prop ] ) ) {
89 $properties[] = $prop;
90 }
91 }
92
93 $properties = ( $properties === array( 'right', 'left' ) ) ? array_reverse( $properties ) : $properties;
94
95 foreach ( $properties as $property ) {
96
97 $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . esc_attr( $args[ $property . '_placeholder' ] ) . '"' : '';
98
99 echo '<div class="drk_lite--input">';
100 echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '<span class="drk_lite--label drk_lite--icon">' . wp_kses_post($args[ $property . '_icon' ]) . '</span>' : '';
101 echo '<input type="number" name="' . esc_attr( $this->field_name( '[' . $property . ']' ) ) . '" value="' . esc_attr( $value[ $property ] ) . '"' . wp_kses_post($placeholder) . ' class="drk_lite-input-number drk_lite--is-unit" step="any" />';
102 echo ( ! empty( $args['unit'] ) ) ? '<span class="drk_lite--label drk_lite--unit">' . esc_attr( $args['unit'] ) . '</span>' : '';
103 echo '</div>';
104
105 }
106 }
107
108 if ( ! empty( $args['style'] ) ) {
109 echo '<div class="drk_lite--input">';
110 echo '<select name="' . esc_attr( $this->field_name( '[style]' ) ) . '">';
111 foreach ( $border_props as $border_prop_key => $border_prop_value ) {
112 $selected = ( $value['style'] === $border_prop_key ) ? ' selected' : '';
113 echo '<option value="' . esc_attr( $border_prop_key ) . '"' . esc_attr( $selected ) . '>' . esc_attr( $border_prop_value ) . '</option>';
114 }
115 echo '</select>';
116 echo '</div>';
117 }
118
119 echo '</div>';
120
121 if ( ! empty( $args['color'] ) ) {
122 $default_color_attr = ( ! empty( $default_value['color'] ) ) ? ' data-default-color="' . esc_attr( $default_value['color'] ) . '"' : '';
123 echo '<div class="drk_lite--color">';
124 echo '<div class="drk_lite-field-color">';
125 echo '<input type="text" name="' . esc_attr( $this->field_name( '[color]' ) ) . '" value="' . esc_attr( $value['color'] ) . '" class="drk_lite-color"' . wp_kses_post($default_color_attr) . ' />';
126 echo '</div>';
127 echo '</div>';
128 }
129
130 echo wp_kses_post( $this->field_after() );
131 }
132
133 public function output() {
134
135 $output = '';
136 $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
137 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
138 $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
139
140 // properties
141 $top = ( isset( $this->value['top'] ) && $this->value['top'] !== '' ) ? $this->value['top'] : '';
142 $right = ( isset( $this->value['right'] ) && $this->value['right'] !== '' ) ? $this->value['right'] : '';
143 $bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] !== '' ) ? $this->value['bottom'] : '';
144 $left = ( isset( $this->value['left'] ) && $this->value['left'] !== '' ) ? $this->value['left'] : '';
145 $style = ( isset( $this->value['style'] ) && $this->value['style'] !== '' ) ? $this->value['style'] : '';
146 $color = ( isset( $this->value['color'] ) && $this->value['color'] !== '' ) ? $this->value['color'] : '';
147 $all = ( isset( $this->value['all'] ) && $this->value['all'] !== '' ) ? $this->value['all'] : '';
148
149 if ( ! empty( $this->field['all'] ) && ( $all !== '' || $color !== '' ) ) {
150
151 $output = $element . '{';
152 $output .= ( $all !== '' ) ? 'border-width:' . $all . $unit . $important . ';' : '';
153 $output .= ( $color !== '' ) ? 'border-color:' . $color . $important . ';' : '';
154 $output .= ( $style !== '' ) ? 'border-style:' . $style . $important . ';' : '';
155 $output .= '}';
156
157 } elseif ( $top !== '' || $right !== '' || $bottom !== '' || $left !== '' || $color !== '' ) {
158
159 $output = $element . '{';
160 $output .= ( $top !== '' ) ? 'border-top-width:' . $top . $unit . $important . ';' : '';
161 $output .= ( $right !== '' ) ? 'border-right-width:' . $right . $unit . $important . ';' : '';
162 $output .= ( $bottom !== '' ) ? 'border-bottom-width:' . $bottom . $unit . $important . ';' : '';
163 $output .= ( $left !== '' ) ? 'border-left-width:' . $left . $unit . $important . ';' : '';
164 $output .= ( $color !== '' ) ? 'border-color:' . $color . $important . ';' : '';
165 $output .= ( $style !== '' ) ? 'border-style:' . $style . $important . ';' : '';
166 $output .= '}';
167
168 }
169
170 $this->parent->output_css .= $output;
171
172 return $output;
173 }
174 }
175 }
176