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 / dimensions_advanced / dimensions_advanced.php

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

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