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

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

164 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 * Field: Dimension Advanced
5 *
6 * @link https://shapedplugin.com/
7 *
8 * @package Smart_Post_Show
9 * @subpackage Smart_Post_Show/admin/views
10 */
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 die; } // Cannot access directly.
14
15 if ( ! class_exists( 'SP_PC_Field_dimensions_advanced' ) ) {
16
17 /**
18 * The Advanced Dimensions field class.
19 *
20 * @since 3.5
21 */
22 class SP_PC_Field_dimensions_advanced extends SP_PC_Fields {
23
24 /**
25 * Advanced Dimensions field constructor.
26 *
27 * @param array $field The field type.
28 * @param string $value The values of the field.
29 * @param string $unique The unique ID for the field.
30 * @param string $where To where show the output CSS.
31 * @param string $parent The parent args.
32 */
33 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
34 parent::__construct( $field, $value, $unique, $where, $parent );
35 }
36 /**
37 * The render method.
38 *
39 * @return void
40 */
41 public function render() {
42
43 $args = wp_parse_args(
44 $this->field,
45 array(
46 'top_icon' => '<i class="fa fa-long-arrow-up"></i>',
47 'right_icon' => '<i class="fa fa-long-arrow-right"></i>',
48 'left_icon' => '<i class="fa fa-long-arrow-left"></i>',
49 'bottom_icon' => '<i class="fa fa-long-arrow-down"></i>',
50 'all_icon' => '<i class="fa fa-arrows"></i>',
51 'top_placeholder' => esc_html__( 'top', 'post-carousel' ),
52 'right_placeholder' => esc_html__( 'right', 'post-carousel' ),
53 'bottom_placeholder' => esc_html__( 'bottom', 'post-carousel' ),
54 'left_placeholder' => esc_html__( 'left', 'post-carousel' ),
55 'all_placeholder' => esc_html__( 'all', 'post-carousel' ),
56 'top' => true,
57 'left' => true,
58 'bottom' => true,
59 'right' => true,
60 'all' => false,
61 'color' => true,
62 'style' => true,
63 'styles' => array( 'Soft-crop', 'Hard-crop' ),
64 'units' => array( 'px', '%', 'em' ),
65 'min' => '0',
66 )
67 );
68
69 $default_values = array(
70 'top' => '',
71 'right' => '',
72 'bottom' => '',
73 'left' => '',
74 'color' => '',
75 'style' => 'solid',
76 'all' => '',
77 'min' => '',
78 'unit' => 'px',
79 );
80
81 $border_props = array(
82 'solid' => esc_html__( 'Solid', 'post-carousel' ),
83 'dashed' => esc_html__( 'Dashed', 'post-carousel' ),
84 'dotted' => esc_html__( 'Dotted', 'post-carousel' ),
85 'double' => esc_html__( 'Double', 'post-carousel' ),
86 'inset' => esc_html__( 'Inset', 'post-carousel' ),
87 'outset' => esc_html__( 'Outset', 'post-carousel' ),
88 'groove' => esc_html__( 'Groove', 'post-carousel' ),
89 'ridge' => esc_html__( 'ridge', 'post-carousel' ),
90 'none' => esc_html__( 'None', 'post-carousel' ),
91 );
92
93 $default_values = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_values ) : $default_values;
94
95 $value = wp_parse_args( $this->value, $default_values );
96 $unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
97 $is_unit = ( ! empty( $unit ) ) ? ' spf--is-unit' : '';
98
99 echo wp_kses_post( $this->field_before() );
100
101 $min = ( isset( $args['min'] ) ) ? ' min="' . $args['min'] . '"' : '';
102
103 echo '<div class="spf--inputs">';
104 if ( ! empty( $args['all'] ) ) {
105
106 $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . $args['all_placeholder'] . '"' : '';
107
108 echo '<div class="spf--input">';
109 echo ( ! empty( $args['all_icon'] ) ) ? '<span class="spf--label spf--icon">' . wp_kses_post( $args['all_icon'] ) . '</span>' : '';
110 echo '<input type="number" disabled="disabled" 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 ) . '" />';
111 echo ( $unit ) ? '<span class="spf--label spf--unit">' . esc_html( $args['units'][0] ) . '</span>' : '';
112 echo '</div>';
113
114 } else {
115
116 $properties = array();
117
118 foreach ( array( 'top', 'right', 'bottom', 'left' ) as $prop ) {
119 if ( ! empty( $args[ $prop ] ) ) {
120 $properties[] = $prop;
121 }
122 }
123
124 $properties = ( array( 'right', 'left' ) === $properties ) ? array_reverse( $properties ) : $properties;
125
126 foreach ( $properties as $property ) {
127
128 $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . $args[ $property . '_placeholder' ] . '"' : '';
129
130 echo '<div class="spf--input">';
131 echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '<span class="spf--label spf--icon">' . wp_kses_post( $args[ $property . '_icon' ] ) . '</span>' : '';
132 echo '<input type="number" disabled="disabled" 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 ) . '" />';
133 echo ( $unit ) ? '<span class="spf--label spf--unit">' . esc_html( $args['units'][0] ) . '</span>' : '';
134 echo '</div>';
135
136 }
137 }
138
139 if ( ! empty( $args['style'] ) ) {
140 echo '<div class="spf--input">';
141 echo '<select disabled="disabled" name="' . esc_attr( $this->field_name( '[style]' ) ) . '">';
142 foreach ( $args['styles'] as $style_prop ) {
143 $selected = ( $value['style'] === $style_prop ) ? ' selected' : '';
144 echo '<option value="' . esc_attr( $style_prop ) . '"' . esc_attr( $selected ) . '>' . esc_html( $style_prop ) . '</option>';
145 }
146 echo '</select>';
147 echo '</div>';
148 }
149
150 if ( ! empty( $args['color'] ) ) {
151 $default_color_attr = ( ! empty( $default_values['color'] ) ) ? ' data-default-color="' . $default_values['color'] . '"' : '';
152 echo '<div class="spf--left spf-field-color">';
153 echo '<input type="text" disabled="disabled" name="' . esc_attr( $this->field_name( '[color]' ) ) . '" value="' . esc_attr( $value['color'] ) . '" class="spf-color"' . wp_kses_post( $default_color_attr ) . ' />';
154 echo '</div>';
155 }
156
157 echo '</div>';
158
159 echo wp_kses_post( $this->field_after() );
160
161 }
162 }
163 }
164