PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.1.6
Adminify – White Label, Admin Menu Editor, Login Customizer v3.1.6
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
adminify / lib / adminify-framework / fields / border / border.php

border.php in Adminify – White Label, Admin Menu Editor, Login Customizer 3.1.6, at lib/adminify-framework/fields/border/border.php

166 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( 'ADMINIFY_Field_border' ) ) {
11 class ADMINIFY_Field_border extends ADMINIFY_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 $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 );
41
42 $default_value = [
43 'top' => '',
44 'right' => '',
45 'bottom' => '',
46 'left' => '',
47 'color' => '',
48 'style' => 'solid',
49 'all' => '',
50 ];
51
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 ];
63
64 $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
65
66 $value = wp_parse_args( $this->value, $default_value );
67
68 echo wp_kses_post( $this->field_before() );
69
70 echo '<div class="adminify--inputs" data-depend-id="' . esc_attr( $this->field['id'] ) . '">';
71
72 if ( ! empty( $args['all'] ) ) {
73 $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . esc_attr( $args['all_placeholder'] ) . '"' : '';
74
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 = [];
82
83 foreach ( [ 'top', 'right', 'bottom', 'left' ] as $prop ) {
84 if ( ! empty( $args[ $prop ] ) ) {
85 $properties[] = $prop;
86 }
87 }
88
89 $properties = ( $properties === [ 'right', 'left' ] ) ? array_reverse( $properties ) : $properties;
90
91 foreach ( $properties as $property ) {
92 $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . esc_attr( $args[ $property . '_placeholder' ] ) . '"' : '';
93
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 }
101
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 }
112
113 echo '</div>';
114
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 }
123
124 echo wp_kses_post( $this->field_after() );
125 }
126
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'];
132
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'] : '';
141
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 }
158
159 $this->parent->output_css .= $output;
160
161 return $output;
162 }
163
164 }
165 }
166