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

206 lines 8.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The framework border fields file.
4 *
5 * @package Smart_Post_Show
6 * @subpackage Smart_Post_Show/admin
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 die;
11 } // Cannot access directly.
12
13 if ( ! class_exists( 'SP_PC_Field_border' ) ) {
14 /**
15 * SP_PC_Field_border
16 */
17 class SP_PC_Field_border extends SP_PC_Fields {
18 /**
19 * Field constructor.
20 *
21 * @param array $field The field type.
22 * @param string $value The values of the field.
23 * @param string $unique The unique ID for the field.
24 * @param string $where To where show the output CSS.
25 * @param string $parent The parent args.
26 */
27 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
28 parent::__construct( $field, $value, $unique, $where, $parent );
29 }
30
31 /**
32 * Render method.
33 *
34 * @return void
35 */
36 public function render() {
37
38 $args = wp_parse_args(
39 $this->field,
40 array(
41 'top_icon' => '<i class="fa fa-long-arrow-up"></i>',
42 'left_icon' => '<i class="fa fa-long-arrow-left"></i>',
43 'bottom_icon' => '<i class="fa fa-long-arrow-down"></i>',
44 'right_icon' => '<i class="fa fa-long-arrow-right"></i>',
45 'all_icon' => '<i class="fa fa-arrows"></i>',
46 'top_placeholder' => esc_html__( 'top', 'post-carousel' ),
47 'right_placeholder' => esc_html__( 'right', 'post-carousel' ),
48 'bottom_placeholder' => esc_html__( 'bottom', 'post-carousel' ),
49 'left_placeholder' => esc_html__( 'left', 'post-carousel' ),
50 'all_placeholder' => esc_html__( 'all', 'post-carousel' ),
51 'top' => true,
52 'left' => true,
53 'bottom' => true,
54 'right' => true,
55 'all' => false,
56 'color' => true,
57 'style' => true,
58 'unit' => 'px',
59 'min' => '0',
60 )
61 );
62
63 $default_value = array(
64 'top' => '',
65 'right' => '',
66 'bottom' => '',
67 'left' => '',
68 'color' => '',
69 'style' => 'solid',
70 'all' => '',
71 'min' => '',
72 );
73
74 $border_props = array(
75 'solid' => esc_html__( 'Solid', 'post-carousel' ),
76 'dashed' => esc_html__( 'Dashed', 'post-carousel' ),
77 'dotted' => esc_html__( 'Dotted', 'post-carousel' ),
78 'double' => esc_html__( 'Double', 'post-carousel' ),
79 'inset' => esc_html__( 'Inset', 'post-carousel' ),
80 'outset' => esc_html__( 'Outset', 'post-carousel' ),
81 'groove' => esc_html__( 'Groove', 'post-carousel' ),
82 'ridge' => esc_html__( 'ridge', 'post-carousel' ),
83 'none' => esc_html__( 'None', 'post-carousel' ),
84 );
85
86 $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
87
88 $value = wp_parse_args( $this->value, $default_value );
89
90 echo wp_kses_post( $this->field_before() );
91
92 echo '<div class="spf--inputs">';
93 $min = ( isset( $args['min'] ) ) ? ' min="' . $args['min'] . '"' : '';
94
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">' . wp_kses_post( $args['all_icon'] ) . '</span>' : '';
101 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" />';
102 echo ( ! empty( $args['unit'] ) ) ? '<span class="spf--label spf--unit">' . esc_html( $args['unit'] ) . '</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 = ( array( 'right', 'left' ) === $properties ) ? 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">' . wp_kses_post( $args[ $property . '_icon' ] ) . '</span>' : '';
123 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" />';
124 echo ( ! empty( $args['unit'] ) ) ? '<span class="spf--label spf--unit">' . esc_html( $args['unit'] ) . '</span>' : '';
125 echo '</div>';
126
127 }
128 }
129
130 if ( ! empty( $args['style'] ) ) {
131 echo '<div class="spf--input">';
132 echo '<select name="' . esc_attr( $this->field_name( '[style]' ) ) . '">';
133 foreach ( $border_props as $border_prop_key => $border_prop_value ) {
134 $selected = ( $value['style'] === $border_prop_key ) ? ' selected' : '';
135 echo '<option value="' . esc_attr( $border_prop_key ) . '"' . esc_attr( $selected ) . '>' . esc_html( $border_prop_value ) . '</option>';
136 }
137 echo '</select>';
138 echo '</div>';
139 }
140 echo '</div>';
141 if ( ! empty( $args['color'] ) ) {
142 $default_color_attr = ( ! empty( $default_value['color'] ) ) ? ' data-default-color="' . $default_value['color'] . '"' : '';
143 echo '<div class="spf--color">';
144 echo '<div class="spf-field-color">';
145 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 ) . ' />';
146 echo '</div>';
147 echo '</div>';
148 }
149
150 echo '<div class="clear"></div>';
151
152 echo wp_kses_post( $this->field_after() );
153
154 }
155
156 /**
157 * Output method.
158 *
159 * @return mixed
160 */
161 public function output() {
162
163 $output = '';
164 $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
165 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
166 $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
167
168 // properties.
169 $top = ( isset( $this->value['top'] ) && $this->value['top'] ) ? $this->value['top'] : '';
170 $right = ( isset( $this->value['right'] ) && $this->value['right'] ) ? $this->value['right'] : '';
171 $bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] ) ? $this->value['bottom'] : '';
172 $left = ( isset( $this->value['left'] ) && $this->value['left'] ) ? $this->value['left'] : '';
173 $style = ( isset( $this->value['style'] ) && $this->value['style'] ) ? $this->value['style'] : '';
174 $color = ( isset( $this->value['color'] ) && $this->value['color'] ) ? $this->value['color'] : '';
175 $all = ( isset( $this->value['all'] ) && $this->value['all'] ) ? $this->value['all'] : '';
176
177 if ( ! empty( $this->field['all'] ) && ( $all || $color ) ) {
178
179 $output = $element . '{';
180 $output .= ( '' !== $all ) ? 'border-width:' . $all . $unit . $important . ';' : '';
181 $output .= ( '' !== $color ) ? 'border-color:' . $color . $important . ';' : '';
182 $output .= ( '' !== $style ) ? 'border-style:' . $style . $important . ';' : '';
183 $output .= '}';
184
185 } elseif ( '' !== $top || '' !== $right || '' !== $bottom || '' !== $left || '' !== $color ) {
186
187 $output = $element . '{';
188 $output .= ( '' !== $top ) ? 'border-top-width:' . $top . $unit . $important . ';' : '';
189 $output .= ( '' !== $right ) ? 'border-right-width:' . $right . $unit . $important . ';' : '';
190 $output .= ( '' !== $bottom ) ? 'border-bottom-width:' . $bottom . $unit . $important . ';' : '';
191 $output .= ( '' !== $left ) ? 'border-left-width:' . $left . $unit . $important . ';' : '';
192 $output .= ( '' !== $color ) ? 'border-color:' . $color . $important . ';' : '';
193 $output .= ( '' !== $style ) ? 'border-style:' . $style . $important . ';' : '';
194 $output .= '}';
195
196 }
197
198 $this->parent->output_css .= $output;
199
200 return $output;
201
202 }
203
204 }
205 }
206