PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.4.1
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.4.1
4.3.2 4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 All 165 releases
← All changes | Libs/adminify-framework/fields/spacing/spacing.php +122 -139 4.2.15 → 3.2.4.1 View file →
@@ -1,5 +1,6 @@
1 -<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
1 +<?php if ( ! defined( 'ABSPATH' ) ) {
2 + die; } // Cannot access directly.
2 3 /**
3 4 *
4 5 * Field: spacing
5 6 *
@@ -4,168 +5,150 @@
4 5 * Field: spacing
5 6 *
6 7 * @since 1.0.0
7 8 * @version 1.0.0
8 - *
9 9 */
10 10 if ( ! class_exists( 'ADMINIFY_Field_spacing' ) ) {
11 - class ADMINIFY_Field_spacing extends ADMINIFY_Fields {
11 + class ADMINIFY_Field_spacing extends ADMINIFY_Fields {
12 12
13 - public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 - parent::__construct( $field, $value, $unique, $where, $parent );
15 - }
13 + public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 + parent::__construct( $field, $value, $unique, $where, $parent );
15 + }
16 16
17 - public function render() {
17 + public function render() {
18 + $args = wp_parse_args(
19 + $this->field,
20 + [
21 + 'top_icon' => '<i class="fas fa-long-arrow-alt-up"></i>',
22 + 'right_icon' => '<i class="fas fa-long-arrow-alt-right"></i>',
23 + 'bottom_icon' => '<i class="fas fa-long-arrow-alt-down"></i>',
24 + 'left_icon' => '<i class="fas fa-long-arrow-alt-left"></i>',
25 + 'all_icon' => '<i class="fas fa-arrows-alt"></i>',
26 + 'top_placeholder' => esc_html__( 'top', 'adminify' ),
27 + 'right_placeholder' => esc_html__( 'right', 'adminify' ),
28 + 'bottom_placeholder' => esc_html__( 'bottom', 'adminify' ),
29 + 'left_placeholder' => esc_html__( 'left', 'adminify' ),
30 + 'all_placeholder' => esc_html__( 'all', 'adminify' ),
31 + 'top' => true,
32 + 'left' => true,
33 + 'bottom' => true,
34 + 'right' => true,
35 + 'unit' => true,
36 + 'show_units' => true,
37 + 'all' => false,
38 + 'units' => [ 'px', '%', 'em' ],
39 + ]
40 + );
18 41
19 - $args = wp_parse_args( $this->field, array(
20 - 'top_icon' => '<i class="fas fa-long-arrow-alt-up"></i>',
21 - 'right_icon' => '<i class="fas fa-long-arrow-alt-right"></i>',
22 - 'bottom_icon' => '<i class="fas fa-long-arrow-alt-down"></i>',
23 - 'left_icon' => '<i class="fas fa-long-arrow-alt-left"></i>',
24 - 'all_icon' => '<i class="fas fa-arrows-alt"></i>',
25 - 'top_placeholder' => esc_html__( 'top', 'adminify' ),
26 - 'right_placeholder' => esc_html__( 'right', 'adminify' ),
27 - 'bottom_placeholder' => esc_html__( 'bottom', 'adminify' ),
28 - 'left_placeholder' => esc_html__( 'left', 'adminify' ),
29 - 'all_placeholder' => esc_html__( 'all', 'adminify' ),
30 - 'top' => true,
31 - 'left' => true,
32 - 'bottom' => true,
33 - 'right' => true,
34 - 'unit' => true,
35 - 'show_units' => true,
36 - 'all' => false,
37 - 'units' => array( 'px', '%', 'em' )
38 - ) );
42 + $default_values = [
43 + 'top' => '',
44 + 'right' => '',
45 + 'bottom' => '',
46 + 'left' => '',
47 + 'all' => '',
48 + 'unit' => 'px',
49 + ];
39 50
40 - $default_values = array(
41 - 'top' => '',
42 - 'right' => '',
43 - 'bottom' => '',
44 - 'left' => '',
45 - 'all' => '',
46 - 'unit' => 'px',
47 - );
51 + $value = wp_parse_args( $this->value, $default_values );
52 + $unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
53 + $is_unit = ( ! empty( $unit ) ) ? ' adminify--is-unit' : '';
48 54
49 - $value = wp_parse_args( $this->value, $default_values );
50 - $unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
51 - $is_unit = ( ! empty( $unit ) ) ? ' adminify--is-unit' : '';
55 + echo wp_kses_post( $this->field_before() );
52 56
53 - echo wp_kses_post( $this->field_before() );
57 + echo '<div class="adminify--inputs" data-depend-id="' . esc_attr( $this->field['id'] ) . '">';
54 58
55 - echo '<div class="adminify--inputs" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
59 + if ( ! empty( $args['all'] ) ) {
60 + $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . esc_attr( $args['all_placeholder'] ) . '"' : '';
56 61
57 - if ( ! empty( $args['all'] ) ) {
62 + echo '<div class="adminify--input">';
63 + echo ( ! empty( $args['all_icon'] ) ) ? '<span class="adminify--label adminify--icon">' . wp_kses_post( $args['all_icon'] ) . '</span>' : '';
64 + echo '<input type="number" name="' . esc_attr( $this->field_name( '[all]' ) ) . '" value="' . esc_attr( $value['all'] ) . '"' . esc_attr( $placeholder ) . ' class="adminify-input-number' . esc_attr( $is_unit ) . '" step="any" />';
65 + echo ( $unit ) ? '<span class="adminify--label adminify--unit">' . esc_attr( $args['units'][0] ) . '</span>' : '';
66 + echo '</div>';
67 + } else {
68 + $properties = [];
58 69
59 - $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args['all_placeholder'] ) .'"' : '';
70 + foreach ( [ 'top', 'right', 'bottom', 'left' ] as $prop ) {
71 + if ( ! empty( $args[ $prop ] ) ) {
72 + $properties[] = $prop;
73 + }
74 + }
60 75
61 - echo '<div class="adminify--input">';
62 - echo ( ! empty( $args['all_icon'] ) ) ? '<span class="adminify--label adminify--icon">'. wp_kses_post( $args['all_icon'] ) .'</span>' : '';
63 - echo '<input type="number" name="'. esc_attr( $this->field_name( '[all]' ) ) .'" value="'. esc_attr( $value['all'] ) .'"'. $placeholder .' class="adminify-input-number'. esc_attr( $is_unit ) .'" step="any" />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- attribute value pre-escaped with esc_attr() where built.
64 - echo ( $unit ) ? '<span class="adminify--label adminify--unit">'. esc_attr( $args['units'][0] ) .'</span>' : '';
65 - echo '</div>';
76 + $properties = ( $properties === [ 'right', 'left' ] ) ? array_reverse( $properties ) : $properties;
66 77
67 - } else {
78 + foreach ( $properties as $property ) {
79 + $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . esc_attr( $args[ $property . '_placeholder' ] ) . '"' : '';
68 80
69 - $properties = array();
81 + echo '<div class="adminify--input">';
82 + echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '<span class="adminify--label adminify--icon">' . wp_kses_post( $args[ $property . '_icon' ] ) . '</span>' : '';
83 + echo '<input type="number" name="' . esc_attr( $this->field_name( '[' . $property . ']' ) ) . '" value="' . esc_attr( $value[ $property ] ) . '"' . esc_attr( $placeholder ) . ' class="adminify-input-number' . esc_attr( $is_unit ) . '" step="any" />';
84 + echo ( $unit ) ? '<span class="adminify--label adminify--unit">' . esc_attr( $args['units'][0] ) . '</span>' : '';
85 + echo '</div>';
86 + }
87 + }
70 88
71 - foreach ( array( 'top', 'right', 'bottom', 'left' ) as $prop ) {
72 - if ( ! empty( $args[$prop] ) ) {
73 - $properties[] = $prop;
74 - }
75 - }
89 + if ( ! empty( $args['unit'] ) && ! empty( $args['show_units'] ) && count( $args['units'] ) > 1 ) {
90 + echo '<div class="adminify--input">';
91 + echo '<select name="' . esc_attr( $this->field_name( '[unit]' ) ) . '">';
92 + foreach ( $args['units'] as $unit ) {
93 + $selected = ( $value['unit'] === $unit ) ? ' selected' : '';
94 + echo '<option value="' . esc_attr( $unit ) . '"' . esc_attr( $selected ) . '>' . esc_attr( $unit ) . '</option>';
95 + }
96 + echo '</select>';
97 + echo '</div>';
98 + }
76 99
77 - $properties = ( $properties === array( 'right', 'left' ) ) ? array_reverse( $properties ) : $properties;
100 + echo '</div>';
78 101
79 - foreach ( $properties as $property ) {
102 + echo wp_kses_post( $this->field_after() );
103 + }
80 104
81 - $placeholder = ( ! empty( $args[$property.'_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args[$property.'_placeholder'] ) .'"' : '';
105 + public function output() {
106 + $output = '';
107 + $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
108 + $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
109 + $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
82 110
83 - echo '<div class="adminify--input">';
84 - echo ( ! empty( $args[$property.'_icon'] ) ) ? '<span class="adminify--label adminify--icon">'. wp_kses_post( $args[$property.'_icon'] ) .'</span>' : '';
85 - echo '<input type="number" name="'. esc_attr( $this->field_name( '['. $property .']' ) ) .'" value="'. esc_attr( $value[$property] ) .'"'. $placeholder .' class="adminify-input-number'. esc_attr( $is_unit ) .'" step="any" />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- attribute value pre-escaped with esc_attr() where built.
86 - echo ( $unit ) ? '<span class="adminify--label adminify--unit">'. esc_attr( $args['units'][0] ) .'</span>' : '';
87 - echo '</div>';
111 + $mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'padding';
88 112
89 - }
113 + if ( $mode === 'border-radius' || $mode === 'radius' ) {
114 + $top = 'border-top-left-radius';
115 + $right = 'border-top-right-radius';
116 + $bottom = 'border-bottom-right-radius';
117 + $left = 'border-bottom-left-radius';
118 + } elseif ( $mode === 'relative' || $mode === 'absolute' || $mode === 'none' ) {
119 + $top = 'top';
120 + $right = 'right';
121 + $bottom = 'bottom';
122 + $left = 'left';
123 + } else {
124 + $top = $mode . '-top';
125 + $right = $mode . '-right';
126 + $bottom = $mode . '-bottom';
127 + $left = $mode . '-left';
128 + }
90 129
91 - }
130 + if ( ! empty( $this->field['all'] ) && isset( $this->value['all'] ) && $this->value['all'] !== '' ) {
131 + $output = $element . '{';
132 + $output .= $top . ':' . $this->value['all'] . $unit . $important . ';';
133 + $output .= $right . ':' . $this->value['all'] . $unit . $important . ';';
134 + $output .= $bottom . ':' . $this->value['all'] . $unit . $important . ';';
135 + $output .= $left . ':' . $this->value['all'] . $unit . $important . ';';
136 + $output .= '}';
137 + } else {
138 + $top = ( isset( $this->value['top'] ) && $this->value['top'] !== '' ) ? $top . ':' . $this->value['top'] . $unit . $important . ';' : '';
139 + $right = ( isset( $this->value['right'] ) && $this->value['right'] !== '' ) ? $right . ':' . $this->value['right'] . $unit . $important . ';' : '';
140 + $bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] !== '' ) ? $bottom . ':' . $this->value['bottom'] . $unit . $important . ';' : '';
141 + $left = ( isset( $this->value['left'] ) && $this->value['left'] !== '' ) ? $left . ':' . $this->value['left'] . $unit . $important . ';' : '';
92 142
93 - if ( ! empty( $args['unit'] ) && ! empty( $args['show_units'] ) && count( $args['units'] ) > 1 ) {
94 - echo '<div class="adminify--input">';
95 - echo '<select name="'. esc_attr( $this->field_name( '[unit]' ) ) .'">';
96 - foreach ( $args['units'] as $unit ) {
97 - $selected = ( $value['unit'] === $unit ) ? ' selected' : '';
98 - echo '<option value="'. esc_attr( $unit ) .'"'. esc_attr( $selected ) .'>'. esc_attr( $unit ) .'</option>';
99 - }
100 - echo '</select>';
101 - echo '</div>';
102 - }
143 + if ( $top !== '' || $right !== '' || $bottom !== '' || $left !== '' ) {
144 + $output = $element . '{' . $top . $right . $bottom . $left . '}';
145 + }
146 + }
103 147
104 - echo '</div>';
148 + $this->parent->output_css .= $output;
105 149
106 - echo wp_kses_post( $this->field_after() );
150 + return $output;
151 + }
107 152
108 - }
109 -
110 - public function output() {
111 -
112 - $output = '';
113 - $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
114 - $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
115 - $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
116 -
117 - $mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'padding';
118 -
119 - if ( $mode === 'border-radius' || $mode === 'radius' ) {
120 -
121 - $top = 'border-top-left-radius';
122 - $right = 'border-top-right-radius';
123 - $bottom = 'border-bottom-right-radius';
124 - $left = 'border-bottom-left-radius';
125 -
126 - } else if ( $mode === 'relative' || $mode === 'absolute' || $mode === 'none' ) {
127 -
128 - $top = 'top';
129 - $right = 'right';
130 - $bottom = 'bottom';
131 - $left = 'left';
132 -
133 - } else {
134 -
135 - $top = $mode .'-top';
136 - $right = $mode .'-right';
137 - $bottom = $mode .'-bottom';
138 - $left = $mode .'-left';
139 -
140 - }
141 -
142 - if ( ! empty( $this->field['all'] ) && isset( $this->value['all'] ) && $this->value['all'] !== '' ) {
143 -
144 - $output = $element .'{';
145 - $output .= $top .':'. $this->value['all'] . $unit . $important .';';
146 - $output .= $right .':'. $this->value['all'] . $unit . $important .';';
147 - $output .= $bottom .':'. $this->value['all'] . $unit . $important .';';
148 - $output .= $left .':'. $this->value['all'] . $unit . $important .';';
149 - $output .= '}';
150 -
151 - } else {
152 -
153 - $top = ( isset( $this->value['top'] ) && $this->value['top'] !== '' ) ? $top .':'. $this->value['top'] . $unit . $important .';' : '';
154 - $right = ( isset( $this->value['right'] ) && $this->value['right'] !== '' ) ? $right .':'. $this->value['right'] . $unit . $important .';' : '';
155 - $bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] !== '' ) ? $bottom .':'. $this->value['bottom'] . $unit . $important .';' : '';
156 - $left = ( isset( $this->value['left'] ) && $this->value['left'] !== '' ) ? $left .':'. $this->value['left'] . $unit . $important .';' : '';
157 -
158 - if ( $top !== '' || $right !== '' || $bottom !== '' || $left !== '' ) {
159 - $output = $element .'{'. $top . $right . $bottom . $left .'}';
160 - }
161 -
162 - }
163 -
164 - $this->parent->output_css .= $output;
165 -
166 - return $output;
167 -
168 - }
169 -
170 - }
153 + }
171 154 }