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