PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 2.4.0
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v2.4.0
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / admin / views / sp-framework / fields / border / border.php

border.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 2.4.0, at admin/views/sp-framework/fields/border/border.php

192 lines 7.7 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( 'SP_PC_Field_border' ) ) {
11 class SP_PC_Field_border extends SP_PC_Fields {
12
13 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 parent::__construct( $field, $value, $unique, $where, $parent );
15 }
16
17 /**
18 * Render method.
19 *
20 * @return void
21 */
22 public function render() {
23
24 $args = wp_parse_args(
25 $this->field,
26 array(
27 'top_icon' => '<i class="fa fa-long-arrow-up"></i>',
28 'left_icon' => '<i class="fa fa-long-arrow-left"></i>',
29 'bottom_icon' => '<i class="fa fa-long-arrow-down"></i>',
30 'right_icon' => '<i class="fa fa-long-arrow-right"></i>',
31 'all_icon' => '<i class="fa fa-arrows"></i>',
32 'top_placeholder' => esc_html__( 'top', 'smart-post-show' ),
33 'right_placeholder' => esc_html__( 'right', 'smart-post-show' ),
34 'bottom_placeholder' => esc_html__( 'bottom', 'smart-post-show' ),
35 'left_placeholder' => esc_html__( 'left', 'smart-post-show' ),
36 'all_placeholder' => esc_html__( 'all', 'smart-post-show' ),
37 'top' => true,
38 'left' => true,
39 'bottom' => true,
40 'right' => true,
41 'all' => false,
42 'color' => true,
43 'style' => true,
44 'unit' => 'px',
45 'min' => '0',
46 )
47 );
48
49 $default_value = array(
50 'top' => '',
51 'right' => '',
52 'bottom' => '',
53 'left' => '',
54 'color' => '',
55 'style' => 'solid',
56 'all' => '',
57 'min' => '',
58 );
59
60 $border_props = array(
61 'solid' => esc_html__( 'Solid', 'smart-post-show' ),
62 'dashed' => esc_html__( 'Dashed', 'smart-post-show' ),
63 'dotted' => esc_html__( 'Dotted', 'smart-post-show' ),
64 'double' => esc_html__( 'Double', 'smart-post-show' ),
65 'inset' => esc_html__( 'Inset', 'smart-post-show' ),
66 'outset' => esc_html__( 'Outset', 'smart-post-show' ),
67 'groove' => esc_html__( 'Groove', 'smart-post-show' ),
68 'ridge' => esc_html__( 'ridge', 'smart-post-show' ),
69 'none' => esc_html__( 'None', 'smart-post-show' ),
70 );
71
72 $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
73
74 $value = wp_parse_args( $this->value, $default_value );
75
76 echo wp_kses_post( $this->field_before() );
77
78 echo '<div class="spf--inputs">';
79 $min = ( isset( $args['min'] ) ) ? ' min="' . $args['min'] . '"' : '';
80
81 if ( ! empty( $args['all'] ) ) {
82
83 $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . $args['all_placeholder'] . '"' : '';
84
85 echo '<div class="spf--input">';
86 echo ( ! empty( $args['all_icon'] ) ) ? '<span class="spf--label spf--icon">' . wp_kses_post( $args['all_icon'] ) . '</span>' : '';
87 echo '<input type="number" name="' . esc_attr( $this->field_name( '[all]' ) ) . '" value="' . esc_attr( $value['all'] ) . '"' . wp_kses_post( $placeholder ) . wp_kses_post( $min ) . ' class="spf-input-number spf--is-unit" />';
88 echo ( ! empty( $args['unit'] ) ) ? '<span class="spf--label spf--unit">' . esc_html( $args['unit'] ) . '</span>' : '';
89 echo '</div>';
90
91 } else {
92
93 $properties = array();
94
95 foreach ( array( 'top', 'right', 'bottom', 'left' ) as $prop ) {
96 if ( ! empty( $args[ $prop ] ) ) {
97 $properties[] = $prop;
98 }
99 }
100
101 $properties = ( array( 'right', 'left' ) === $properties ) ? array_reverse( $properties ) : $properties;
102
103 foreach ( $properties as $property ) {
104
105 $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . $args[ $property . '_placeholder' ] . '"' : '';
106
107 echo '<div class="spf--input">';
108 echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '<span class="spf--label spf--icon">' . wp_kses_post( $args[ $property . '_icon' ] ) . '</span>' : '';
109 echo '<input type="number" name="' . esc_attr( $this->field_name( '[' . $property . ']' ) ) . '" value="' . esc_attr( $value[ $property ] ) . '"' . wp_kses_post( $placeholder . $min ) . ' class="spf-input-number spf--is-unit" />';
110 echo ( ! empty( $args['unit'] ) ) ? '<span class="spf--label spf--unit">' . esc_html( $args['unit'] ) . '</span>' : '';
111 echo '</div>';
112
113 }
114 }
115
116 if ( ! empty( $args['style'] ) ) {
117 echo '<div class="spf--input">';
118 echo '<select name="' . esc_attr( $this->field_name( '[style]' ) ) . '">';
119 foreach ( $border_props as $border_prop_key => $border_prop_value ) {
120 $selected = ( $value['style'] === $border_prop_key ) ? ' selected' : '';
121 echo '<option value="' . esc_attr( $border_prop_key ) . '"' . esc_attr( $selected ) . '>' . esc_html( $border_prop_value ) . '</option>';
122 }
123 echo '</select>';
124 echo '</div>';
125 }
126 echo '</div>';
127 if ( ! empty( $args['color'] ) ) {
128 $default_color_attr = ( ! empty( $default_value['color'] ) ) ? ' data-default-color="' . $default_value['color'] . '"' : '';
129 echo '<div class="spf--color">';
130 echo '<div class="spf-field-color">';
131 echo '<input type="text" name="' . esc_attr( $this->field_name( '[color]' ) ) . '" value="' . esc_attr( $value['color'] ) . '" class="spf-color"' . wp_kses_post( $default_color_attr ) . ' />';
132 echo '</div>';
133 echo '</div>';
134 }
135
136 echo '<div class="clear"></div>';
137
138 echo wp_kses_post( $this->field_after() );
139
140 }
141
142 /**
143 * Output method.
144 *
145 * @return mixed
146 */
147 public function output() {
148
149 $output = '';
150 $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
151 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
152 $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
153
154 // properties.
155 $top = ( isset( $this->value['top'] ) && $this->value['top'] ) ? $this->value['top'] : '';
156 $right = ( isset( $this->value['right'] ) && $this->value['right'] ) ? $this->value['right'] : '';
157 $bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] ) ? $this->value['bottom'] : '';
158 $left = ( isset( $this->value['left'] ) && $this->value['left'] ) ? $this->value['left'] : '';
159 $style = ( isset( $this->value['style'] ) && $this->value['style'] ) ? $this->value['style'] : '';
160 $color = ( isset( $this->value['color'] ) && $this->value['color'] ) ? $this->value['color'] : '';
161 $all = ( isset( $this->value['all'] ) && $this->value['all'] ) ? $this->value['all'] : '';
162
163 if ( ! empty( $this->field['all'] ) && ( $all || $color ) ) {
164
165 $output = $element . '{';
166 $output .= ( '' !== $all ) ? 'border-width:' . $all . $unit . $important . ';' : '';
167 $output .= ( '' !== $color ) ? 'border-color:' . $color . $important . ';' : '';
168 $output .= ( '' !== $style ) ? 'border-style:' . $style . $important . ';' : '';
169 $output .= '}';
170
171 } elseif ( '' !== $top || '' !== $right || '' !== $bottom || '' !== $left || '' !== $color ) {
172
173 $output = $element . '{';
174 $output .= ( '' !== $top ) ? 'border-top-width:' . $top . $unit . $important . ';' : '';
175 $output .= ( '' !== $right ) ? 'border-right-width:' . $right . $unit . $important . ';' : '';
176 $output .= ( '' !== $bottom ) ? 'border-bottom-width:' . $bottom . $unit . $important . ';' : '';
177 $output .= ( '' !== $left ) ? 'border-left-width:' . $left . $unit . $important . ';' : '';
178 $output .= ( '' !== $color ) ? 'border-color:' . $color . $important . ';' : '';
179 $output .= ( '' !== $style ) ? 'border-style:' . $style . $important . ';' : '';
180 $output .= '}';
181
182 }
183
184 $this->parent->output_css .= $output;
185
186 return $output;
187
188 }
189
190 }
191 }
192