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.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 4.1.17 All 164 releases
← All changes | Libs/adminify-framework/fields/border/border.php +132 -143 4.2.113.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: border
5 6 *
@@ -4,173 +5,161 @@
4 5 * Field: border
5 6 *
6 7 * @since 1.0.0
7 8 * @version 1.0.0
8 - *
9 9 */
10 10 if ( ! class_exists( 'ADMINIFY_Field_border' ) ) {
11 - class ADMINIFY_Field_border extends ADMINIFY_Fields {
11 + class ADMINIFY_Field_border 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 + 'left_icon' => '<i class="fas fa-long-arrow-alt-left"></i>',
23 + 'bottom_icon' => '<i class="fas fa-long-arrow-alt-down"></i>',
24 + 'right_icon' => '<i class="fas fa-long-arrow-alt-right"></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 + 'all' => false,
36 + 'color' => true,
37 + 'style' => true,
38 + 'unit' => 'px',
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 - 'left_icon' => '<i class="fas fa-long-arrow-alt-left"></i>',
22 - 'bottom_icon' => '<i class="fas fa-long-arrow-alt-down"></i>',
23 - 'right_icon' => '<i class="fas fa-long-arrow-alt-right"></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 - 'all' => false,
35 - 'color' => true,
36 - 'style' => true,
37 - 'unit' => 'px',
38 - ) );
42 + $default_value = [
43 + 'top' => '',
44 + 'right' => '',
45 + 'bottom' => '',
46 + 'left' => '',
47 + 'color' => '',
48 + 'style' => 'solid',
49 + 'all' => '',
50 + ];
39 51
40 - $default_value = array(
41 - 'top' => '',
42 - 'right' => '',
43 - 'bottom' => '',
44 - 'left' => '',
45 - 'color' => '',
46 - 'style' => 'solid',
47 - 'all' => '',
48 - );
52 + $border_props = [
53 + 'solid' => esc_html__( 'Solid', 'adminify' ),
54 + 'dashed' => esc_html__( 'Dashed', 'adminify' ),
55 + 'dotted' => esc_html__( 'Dotted', 'adminify' ),
56 + 'double' => esc_html__( 'Double', 'adminify' ),
57 + 'inset' => esc_html__( 'Inset', 'adminify' ),
58 + 'outset' => esc_html__( 'Outset', 'adminify' ),
59 + 'groove' => esc_html__( 'Groove', 'adminify' ),
60 + 'ridge' => esc_html__( 'ridge', 'adminify' ),
61 + 'none' => esc_html__( 'None', 'adminify' ),
62 + ];
49 63
50 - $border_props = array(
51 - 'solid' => esc_html__( 'Solid', 'adminify' ),
52 - 'dashed' => esc_html__( 'Dashed', 'adminify' ),
53 - 'dotted' => esc_html__( 'Dotted', 'adminify' ),
54 - 'double' => esc_html__( 'Double', 'adminify' ),
55 - 'inset' => esc_html__( 'Inset', 'adminify' ),
56 - 'outset' => esc_html__( 'Outset', 'adminify' ),
57 - 'groove' => esc_html__( 'Groove', 'adminify' ),
58 - 'ridge' => esc_html__( 'ridge', 'adminify' ),
59 - 'none' => esc_html__( 'None', 'adminify' )
60 - );
64 + $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
61 65
62 - $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
66 + $value = wp_parse_args( $this->value, $default_value );
63 67
64 - $value = wp_parse_args( $this->value, $default_value );
68 + echo wp_kses_post( $this->field_before() );
65 69
66 - echo wp_kses_post( $this->field_before() );
70 + echo '<div class="adminify--inputs" data-depend-id="' . esc_attr( $this->field['id'] ) . '">';
67 71
68 - echo '<div class="adminify--inputs" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
72 + if ( ! empty( $args['all'] ) ) {
73 + $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . esc_attr( $args['all_placeholder'] ) . '"' : '';
69 74
70 - if ( ! empty( $args['all'] ) ) {
75 + echo '<div class="adminify--input">';
76 + echo ( ! empty( $args['all_icon'] ) ) ? '<span class="adminify--label adminify--icon">' . wp_kses_post( $args['all_icon'] ) . '</span>' : '';
77 + echo '<input type="number" name="' . esc_attr( $this->field_name( '[all]' ) ) . '" value="' . esc_attr( $value['all'] ) . '"' . esc_attr( $placeholder ) . ' class="adminify-input-number adminify--is-unit" step="any" />';
78 + echo ( ! empty( $args['unit'] ) ) ? '<span class="adminify--label adminify--unit">' . esc_attr( $args['unit'] ) . '</span>' : '';
79 + echo '</div>';
80 + } else {
81 + $properties = [];
71 82
72 - $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args['all_placeholder'] ) .'"' : '';
83 + foreach ( [ 'top', 'right', 'bottom', 'left' ] as $prop ) {
84 + if ( ! empty( $args[ $prop ] ) ) {
85 + $properties[] = $prop;
86 + }
87 + }
73 88
74 - echo '<div class="adminify--input">';
75 - echo ( ! empty( $args['all_icon'] ) ) ? '<span class="adminify--label adminify--icon">'. wp_kses_post( $args['all_icon'] ) .'</span>' : '';
76 - echo '<input type="number" name="'. esc_attr( $this->field_name( '[all]' ) ) .'" value="'. esc_attr( $value['all'] ) .'"'. $placeholder .' class="adminify-input-number adminify--is-unit" step="any" />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- attribute value pre-escaped with esc_attr() where built.
77 - echo ( ! empty( $args['unit'] ) ) ? '<span class="adminify--label adminify--unit">'. esc_attr( $args['unit'] ) .'</span>' : '';
78 - echo '</div>';
89 + $properties = ( $properties === [ 'right', 'left' ] ) ? array_reverse( $properties ) : $properties;
79 90
80 - } else {
91 + foreach ( $properties as $property ) {
92 + $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . esc_attr( $args[ $property . '_placeholder' ] ) . '"' : '';
81 93
82 - $properties = array();
94 + echo '<div class="adminify--input">';
95 + echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '<span class="adminify--label adminify--icon">' . wp_kses_post( $args[ $property . '_icon' ] ) . '</span>' : '';
96 + echo '<input type="number" name="' . esc_attr( $this->field_name( '[' . $property . ']' ) ) . '" value="' . esc_attr( $value[ $property ] ) . '"' . esc_attr( $placeholder ) . ' class="adminify-input-number adminify--is-unit" step="any" />';
97 + echo ( ! empty( $args['unit'] ) ) ? '<span class="adminify--label adminify--unit">' . esc_attr( $args['unit'] ) . '</span>' : '';
98 + echo '</div>';
99 + }
100 + }
83 101
84 - foreach ( array( 'top', 'right', 'bottom', 'left' ) as $prop ) {
85 - if ( ! empty( $args[$prop] ) ) {
86 - $properties[] = $prop;
87 - }
88 - }
102 + if ( ! empty( $args['style'] ) ) {
103 + echo '<div class="adminify--input">';
104 + echo '<select name="' . esc_attr( $this->field_name( '[style]' ) ) . '">';
105 + foreach ( $border_props as $border_prop_key => $border_prop_value ) {
106 + $selected = ( $value['style'] === $border_prop_key ) ? ' selected' : '';
107 + echo '<option value="' . esc_attr( $border_prop_key ) . '"' . esc_attr( $selected ) . '>' . esc_attr( $border_prop_value ) . '</option>';
108 + }
109 + echo '</select>';
110 + echo '</div>';
111 + }
89 112
90 - $properties = ( $properties === array( 'right', 'left' ) ) ? array_reverse( $properties ) : $properties;
113 + echo '</div>';
91 114
92 - foreach ( $properties as $property ) {
115 + if ( ! empty( $args['color'] ) ) {
116 + $default_color_attr = ( ! empty( $default_value['color'] ) ) ? ' data-default-color="' . esc_attr( $default_value['color'] ) . '"' : '';
117 + echo '<div class="adminify--color">';
118 + echo '<div class="adminify-field-color">';
119 + echo '<input type="text" name="' . esc_attr( $this->field_name( '[color]' ) ) . '" value="' . esc_attr( $value['color'] ) . '" class="adminify-color"' . esc_attr( $default_color_attr ) . ' />';
120 + echo '</div>';
121 + echo '</div>';
122 + }
93 123
94 - $placeholder = ( ! empty( $args[$property.'_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args[$property.'_placeholder'] ) .'"' : '';
124 + echo wp_kses_post( $this->field_after() );
125 + }
95 126
96 - echo '<div class="adminify--input">';
97 - echo ( ! empty( $args[$property.'_icon'] ) ) ? '<span class="adminify--label adminify--icon">'. wp_kses_post( $args[$property.'_icon'] ) .'</span>' : '';
98 - echo '<input type="number" name="'. esc_attr( $this->field_name( '['. $property .']' ) ) .'" value="'. esc_attr( $value[$property] ) .'"'. $placeholder .' class="adminify-input-number adminify--is-unit" step="any" />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- attribute value pre-escaped with esc_attr() where built.
99 - echo ( ! empty( $args['unit'] ) ) ? '<span class="adminify--label adminify--unit">'. esc_attr( $args['unit'] ) .'</span>' : '';
100 - echo '</div>';
127 + public function output() {
128 + $output = '';
129 + $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
130 + $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
131 + $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
101 132
102 - }
133 + // properties
134 + $top = ( isset( $this->value['top'] ) && $this->value['top'] !== '' ) ? $this->value['top'] : '';
135 + $right = ( isset( $this->value['right'] ) && $this->value['right'] !== '' ) ? $this->value['right'] : '';
136 + $bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] !== '' ) ? $this->value['bottom'] : '';
137 + $left = ( isset( $this->value['left'] ) && $this->value['left'] !== '' ) ? $this->value['left'] : '';
138 + $style = ( isset( $this->value['style'] ) && $this->value['style'] !== '' ) ? $this->value['style'] : '';
139 + $color = ( isset( $this->value['color'] ) && $this->value['color'] !== '' ) ? $this->value['color'] : '';
140 + $all = ( isset( $this->value['all'] ) && $this->value['all'] !== '' ) ? $this->value['all'] : '';
103 141
104 - }
142 + if ( ! empty( $this->field['all'] ) && ( $all !== '' || $color !== '' ) ) {
143 + $output = $element . '{';
144 + $output .= ( $all !== '' ) ? 'border-width:' . $all . $unit . $important . ';' : '';
145 + $output .= ( $color !== '' ) ? 'border-color:' . $color . $important . ';' : '';
146 + $output .= ( $style !== '' ) ? 'border-style:' . $style . $important . ';' : '';
147 + $output .= '}';
148 + } elseif ( $top !== '' || $right !== '' || $bottom !== '' || $left !== '' || $color !== '' ) {
149 + $output = $element . '{';
150 + $output .= ( $top !== '' ) ? 'border-top-width:' . $top . $unit . $important . ';' : '';
151 + $output .= ( $right !== '' ) ? 'border-right-width:' . $right . $unit . $important . ';' : '';
152 + $output .= ( $bottom !== '' ) ? 'border-bottom-width:' . $bottom . $unit . $important . ';' : '';
153 + $output .= ( $left !== '' ) ? 'border-left-width:' . $left . $unit . $important . ';' : '';
154 + $output .= ( $color !== '' ) ? 'border-color:' . $color . $important . ';' : '';
155 + $output .= ( $style !== '' ) ? 'border-style:' . $style . $important . ';' : '';
156 + $output .= '}';
157 + }
105 158
106 - if ( ! empty( $args['style'] ) ) {
107 - echo '<div class="adminify--input">';
108 - echo '<select name="'. esc_attr( $this->field_name( '[style]' ) ) .'">';
109 - foreach ( $border_props as $border_prop_key => $border_prop_value ) {
110 - $selected = ( $value['style'] === $border_prop_key ) ? ' selected' : '';
111 - echo '<option value="'. esc_attr( $border_prop_key ) .'"'. esc_attr( $selected ) .'>'. esc_attr( $border_prop_value ) .'</option>';
112 - }
113 - echo '</select>';
114 - echo '</div>';
115 - }
159 + $this->parent->output_css .= $output;
116 160
117 - echo '</div>';
161 + return $output;
162 + }
118 163
119 - if ( ! empty( $args['color'] ) ) {
120 - $default_color_attr = ( ! empty( $default_value['color'] ) ) ? ' data-default-color="'. esc_attr( $default_value['color'] ) .'"' : '';
121 - echo '<div class="adminify--color">';
122 - echo '<div class="adminify-field-color">';
123 - echo '<input type="text" name="'. esc_attr( $this->field_name( '[color]' ) ) .'" value="'. esc_attr( $value['color'] ) .'" class="adminify-color"'. $default_color_attr .' />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- attribute value pre-escaped with esc_attr() where built.
124 - echo '</div>';
125 - echo '</div>';
126 - }
127 -
128 - echo wp_kses_post( $this->field_after() );
129 -
130 - }
131 -
132 - public function output() {
133 -
134 - $output = '';
135 - $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
136 - $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
137 - $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
138 -
139 - // properties
140 - $top = ( isset( $this->value['top'] ) && $this->value['top'] !== '' ) ? $this->value['top'] : '';
141 - $right = ( isset( $this->value['right'] ) && $this->value['right'] !== '' ) ? $this->value['right'] : '';
142 - $bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] !== '' ) ? $this->value['bottom'] : '';
143 - $left = ( isset( $this->value['left'] ) && $this->value['left'] !== '' ) ? $this->value['left'] : '';
144 - $style = ( isset( $this->value['style'] ) && $this->value['style'] !== '' ) ? $this->value['style'] : '';
145 - $color = ( isset( $this->value['color'] ) && $this->value['color'] !== '' ) ? $this->value['color'] : '';
146 - $all = ( isset( $this->value['all'] ) && $this->value['all'] !== '' ) ? $this->value['all'] : '';
147 -
148 - if ( ! empty( $this->field['all'] ) && ( $all !== '' || $color !== '' ) ) {
149 -
150 - $output = $element .'{';
151 - $output .= ( $all !== '' ) ? 'border-width:'. $all . $unit . $important .';' : '';
152 - $output .= ( $color !== '' ) ? 'border-color:'. $color . $important .';' : '';
153 - $output .= ( $style !== '' ) ? 'border-style:'. $style . $important .';' : '';
154 - $output .= '}';
155 -
156 - } else if ( $top !== '' || $right !== '' || $bottom !== '' || $left !== '' || $color !== '' ) {
157 -
158 - $output = $element .'{';
159 - $output .= ( $top !== '' ) ? 'border-top-width:'. $top . $unit . $important .';' : '';
160 - $output .= ( $right !== '' ) ? 'border-right-width:'. $right . $unit . $important .';' : '';
161 - $output .= ( $bottom !== '' ) ? 'border-bottom-width:'. $bottom . $unit . $important .';' : '';
162 - $output .= ( $left !== '' ) ? 'border-left-width:'. $left . $unit . $important .';' : '';
163 - $output .= ( $color !== '' ) ? 'border-color:'. $color . $important .';' : '';
164 - $output .= ( $style !== '' ) ? 'border-style:'. $style . $important .';' : '';
165 - $output .= '}';
166 -
167 - }
168 -
169 - $this->parent->output_css .= $output;
170 -
171 - return $output;
172 -
173 - }
174 -
175 - }
164 + }
176 165 }