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

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

170 lines 6.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: spacing
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 */
10 if ( ! class_exists( 'SP_PC_Field_spacing' ) ) {
11 class SP_PC_Field_spacing extends SP_PC_Fields {
12
13 /**
14 * Spacing field constructor.
15 *
16 * @param array $field The field type.
17 * @param string $value The values of the field.
18 * @param string $unique The unique ID for the field.
19 * @param string $where To where show the output CSS.
20 * @param string $parent The parent args.
21 */
22 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
23 parent::__construct( $field, $value, $unique, $where, $parent );
24 }
25
26 /**
27 * Function to render the field.
28 *
29 * @return void
30 */
31 public function render() {
32
33 $args = wp_parse_args(
34 $this->field,
35 array(
36 'top_icon' => '<i class="fa fa-long-arrow-up"></i>',
37 'right_icon' => '<i class="fa fa-long-arrow-right"></i>',
38 'bottom_icon' => '<i class="fa fa-long-arrow-down"></i>',
39 'left_icon' => '<i class="fa fa-long-arrow-left"></i>',
40 'all_icon' => '<i class="fa fa-arrows"></i>',
41 'top_placeholder' => esc_html__( 'top', 'smart-post-show' ),
42 'right_placeholder' => esc_html__( 'right', 'smart-post-show' ),
43 'bottom_placeholder' => esc_html__( 'bottom', 'smart-post-show' ),
44 'left_placeholder' => esc_html__( 'left', 'smart-post-show' ),
45 'all_placeholder' => esc_html__( 'all', 'smart-post-show' ),
46 'top' => true,
47 'left' => true,
48 'bottom' => true,
49 'right' => true,
50 'unit' => true,
51 'min' => '0',
52 'show_units' => true,
53 'all' => false,
54 'units' => array( 'px', '%', 'em' ),
55 )
56 );
57
58 $default_values = array(
59 'top' => '',
60 'right' => '',
61 'bottom' => '',
62 'left' => '',
63 'all' => '',
64 'unit' => 'px',
65 'min' => '',
66 );
67
68 $value = wp_parse_args( $this->value, $default_values );
69 $unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
70 $is_unit = ( ! empty( $unit ) ) ? ' spf--is-unit' : '';
71
72 echo $this->field_before();
73
74 $min = ( isset( $args['min'] ) ) ? ' min="' . $args['min'] . '"' : '';
75
76 echo '<div class="spf--inputs">';
77
78 if ( ! empty( $args['all'] ) ) {
79
80 $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . $args['all_placeholder'] . '"' : '';
81
82 echo '<div class="spf--input">';
83 echo ( ! empty( $args['all_icon'] ) ) ? '<span class="spf--label spf--icon">' . $args['all_icon'] . '</span>' : '';
84 echo '<input type="number" name="' . $this->field_name( '[all]' ) . '" value="' . $value['all'] . '"' . $placeholder . $min . ' class="spf-input-number' . $is_unit . '" />';
85 echo ( $unit ) ? '<span class="spf--label spf--unit">' . $args['units'][0] . '</span>' : '';
86 echo '</div>';
87
88 } else {
89
90 $properties = array();
91
92 foreach ( array( 'top', 'right', 'bottom', 'left' ) as $prop ) {
93 if ( ! empty( $args[ $prop ] ) ) {
94 $properties[] = $prop;
95 }
96 }
97
98 $properties = ( $properties === array( 'right', 'left' ) ) ? array_reverse( $properties ) : $properties;
99
100 foreach ( $properties as $property ) {
101
102 $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . $args[ $property . '_placeholder' ] . '"' : '';
103
104 echo '<div class="spf--input">';
105 echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '<span class="spf--label spf--icon">' . $args[ $property . '_icon' ] . '</span>' : '';
106 echo '<input type="number" name="' . $this->field_name( '[' . $property . ']' ) . '" value="' . $value[ $property ] . '"' . $placeholder . $min . ' class="spf-input-number' . $is_unit . '" />';
107 echo ( $unit ) ? '<span class="spf--label spf--unit">' . $args['units'][0] . '</span>' : '';
108 echo '</div>';
109
110 }
111 }
112
113 if ( ! empty( $args['unit'] ) && ! empty( $args['show_units'] ) && count( $args['units'] ) > 1 ) {
114 echo '<div class="spf--input">';
115 echo '<select name="' . $this->field_name( '[unit]' ) . '">';
116 foreach ( $args['units'] as $unit ) {
117 $selected = ( $value['unit'] === $unit ) ? ' selected' : '';
118 echo '<option value="' . $unit . '"' . $selected . '>' . $unit . '</option>';
119 }
120 echo '</select>';
121 echo '</div>';
122 }
123
124 echo '</div>';
125
126 echo $this->field_after();
127
128 }
129
130 public function output() {
131
132 $output = '';
133 $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
134 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
135 $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
136
137 $mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'padding';
138 $mode = ( $mode === 'relative' || $mode === 'absolute' || $mode === 'none' ) ? '' : $mode;
139 $mode = ( ! empty( $mode ) ) ? $mode . '-' : '';
140
141 if ( ! empty( $this->field['all'] ) && isset( $this->value['all'] ) && $this->value['all'] !== '' ) {
142
143 $output = $element . '{';
144 $output .= $mode . 'top:' . $this->value['all'] . $unit . $important . ';';
145 $output .= $mode . 'right:' . $this->value['all'] . $unit . $important . ';';
146 $output .= $mode . 'bottom:' . $this->value['all'] . $unit . $important . ';';
147 $output .= $mode . 'left:' . $this->value['all'] . $unit . $important . ';';
148 $output .= '}';
149
150 } else {
151
152 $top = ( isset( $this->value['top'] ) && $this->value['top'] !== '' ) ? $mode . 'top:' . $this->value['top'] . $unit . $important . ';' : '';
153 $right = ( isset( $this->value['right'] ) && $this->value['right'] !== '' ) ? $mode . 'right:' . $this->value['right'] . $unit . $important . ';' : '';
154 $bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] !== '' ) ? $mode . 'bottom:' . $this->value['bottom'] . $unit . $important . ';' : '';
155 $left = ( isset( $this->value['left'] ) && $this->value['left'] !== '' ) ? $mode . 'left:' . $this->value['left'] . $unit . $important . ';' : '';
156
157 if ( $top !== '' || $right !== '' || $bottom !== '' || $left !== '' ) {
158 $output = $element . '{' . $top . $right . $bottom . $left . '}';
159 }
160 }
161
162 $this->parent->output_css .= $output;
163
164 return $output;
165
166 }
167
168 }
169 }
170