PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.2.3
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.2.3
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 / spacing / spacing.php

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

170 lines 6.6 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: spacing
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 */
10 if ( ! class_exists( 'DRK_LITE_Field_spacing' ) ) {
11 class DRK_LITE_Field_spacing 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 'right_icon' => '<i class="fas fa-long-arrow-alt-right"></i>',
24 'bottom_icon' => '<i class="fas fa-long-arrow-alt-down"></i>',
25 'left_icon' => '<i class="fas fa-long-arrow-alt-left"></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 'unit' => true,
37 'show_units' => true,
38 'all' => false,
39 'units' => array( 'px', '%', 'em' ),
40 )
41 );
42
43 $default_values = array(
44 'top' => '',
45 'right' => '',
46 'bottom' => '',
47 'left' => '',
48 'all' => '',
49 'unit' => 'px',
50 );
51
52 $value = wp_parse_args( $this->value, $default_values );
53 $unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
54 $is_unit = ( ! empty( $unit ) ) ? ' drk_lite--is-unit' : '';
55
56 echo wp_kses_post( $this->field_before() );
57
58 echo '<div class="drk_lite--inputs" data-depend-id="' . esc_attr( $this->field['id'] ) . '">';
59
60 if ( ! empty( $args['all'] ) ) {
61
62 $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . esc_attr( $args['all_placeholder'] ) . '"' : '';
63
64 echo '<div class="drk_lite--input">';
65 echo ( ! empty( $args['all_icon'] ) ) ? '<span class="drk_lite--label drk_lite--icon">' . wp_kses_post($args['all_icon']) . '</span>' : '';
66 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' . esc_attr( $is_unit ) . '" step="any" />';
67 echo ( $unit ) ? '<span class="drk_lite--label drk_lite--unit">' . esc_attr( $args['units'][0] ) . '</span>' : '';
68 echo '</div>';
69
70 } else {
71
72 $properties = array();
73
74 foreach ( array( 'top', 'right', 'bottom', 'left' ) as $prop ) {
75 if ( ! empty( $args[ $prop ] ) ) {
76 $properties[] = $prop;
77 }
78 }
79
80 $properties = ( $properties === array( 'right', 'left' ) ) ? array_reverse( $properties ) : $properties;
81
82 foreach ( $properties as $property ) {
83
84 $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . esc_attr( $args[ $property . '_placeholder' ] ) . '"' : '';
85
86 echo '<div class="drk_lite--input">';
87 echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '<span class="drk_lite--label drk_lite--icon">' . wp_kses_post($args[ $property . '_icon' ]) . '</span>' : '';
88 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' . esc_attr( $is_unit ) . '" step="any" />';
89 echo ( $unit ) ? '<span class="drk_lite--label drk_lite--unit">' . esc_attr( $args['units'][0] ) . '</span>' : '';
90 echo '</div>';
91
92 }
93 }
94
95 if ( ! empty( $args['unit'] ) && ! empty( $args['show_units'] ) && count( $args['units'] ) > 1 ) {
96 echo '<div class="drk_lite--input">';
97 echo '<select name="' . esc_attr( $this->field_name( '[unit]' ) ) . '">';
98 foreach ( $args['units'] as $unit ) {
99 $selected = ( $value['unit'] === $unit ) ? ' selected' : '';
100 echo '<option value="' . esc_attr( $unit ) . '"' . esc_attr( $selected ) . '>' . esc_attr( $unit ) . '</option>';
101 }
102 echo '</select>';
103 echo '</div>';
104 }
105
106 echo '</div>';
107
108 echo wp_kses_post( $this->field_after() );
109 }
110
111 public function output() {
112
113 $output = '';
114 $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
115 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
116 $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
117
118 $mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'padding';
119
120 if ( $mode === 'border-radius' || $mode === 'radius' ) {
121
122 $top = 'border-top-left-radius';
123 $right = 'border-top-right-radius';
124 $bottom = 'border-bottom-right-radius';
125 $left = 'border-bottom-left-radius';
126
127 } elseif ( $mode === 'relative' || $mode === 'absolute' || $mode === 'none' ) {
128
129 $top = 'top';
130 $right = 'right';
131 $bottom = 'bottom';
132 $left = 'left';
133
134 } else {
135
136 $top = $mode . '-top';
137 $right = $mode . '-right';
138 $bottom = $mode . '-bottom';
139 $left = $mode . '-left';
140
141 }
142
143 if ( ! empty( $this->field['all'] ) && isset( $this->value['all'] ) && $this->value['all'] !== '' ) {
144
145 $output = $element . '{';
146 $output .= $top . ':' . $this->value['all'] . $unit . $important . ';';
147 $output .= $right . ':' . $this->value['all'] . $unit . $important . ';';
148 $output .= $bottom . ':' . $this->value['all'] . $unit . $important . ';';
149 $output .= $left . ':' . $this->value['all'] . $unit . $important . ';';
150 $output .= '}';
151
152 } else {
153
154 $top = ( isset( $this->value['top'] ) && $this->value['top'] !== '' ) ? $top . ':' . $this->value['top'] . $unit . $important . ';' : '';
155 $right = ( isset( $this->value['right'] ) && $this->value['right'] !== '' ) ? $right . ':' . $this->value['right'] . $unit . $important . ';' : '';
156 $bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] !== '' ) ? $bottom . ':' . $this->value['bottom'] . $unit . $important . ';' : '';
157 $left = ( isset( $this->value['left'] ) && $this->value['left'] !== '' ) ? $left . ':' . $this->value['left'] . $unit . $important . ';' : '';
158
159 if ( $top !== '' || $right !== '' || $bottom !== '' || $left !== '' ) {
160 $output = $element . '{' . $top . $right . $bottom . $left . '}';
161 }
162 }
163
164 $this->parent->output_css .= $output;
165
166 return $output;
167 }
168 }
169 }
170