PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 2.2.10
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v2.2.10
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.2.10, at admin/views/sp-framework/fields/dimensions_advanced/dimensions_advanced.php

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