PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.3
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.3
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 4.0.3, at admin/views/sp-framework/fields/spacing/spacing.php

169 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The framework spacing fields file.
4 *
5 * @package Smart_Post_Show
6 * @subpackage Smart_Post_Show/admin
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12
13 if ( ! class_exists( 'SP_PC_Field_spacing' ) ) {
14
15 /**
16 *
17 * Field: spacing
18 *
19 * @since 1.0.0
20 * @version 1.0.0
21 */
22 class SP_PC_Field_spacing extends SP_PC_Fields {
23
24 /**
25 * Spacing 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 /**
38 * Function to render the field.
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 'bottom_icon' => '<i class="fa fa-long-arrow-down"></i>',
50 'left_icon' => '<i class="fa fa-long-arrow-left"></i>',
51 'all_icon' => '<i class="fa fa-arrows-alt"></i>',
52 'arrow_v' => '<i class="fa fa-arrows-v"></i>',
53 'arrow_h' => '<i class="fa fa-arrows-h"></i>',
54 'top_placeholder' => esc_html__( 'top', 'post-carousel' ),
55 'right_placeholder' => esc_html__( 'right', 'post-carousel' ),
56 'bottom_placeholder' => esc_html__( 'bottom', 'post-carousel' ),
57 'left_placeholder' => esc_html__( 'left', 'post-carousel' ),
58 'all_placeholder' => esc_html__( 'all', 'post-carousel' ),
59 'top_bottom_title' => esc_html__( 'Vertical Gap', 'post-carousel' ),
60 'left_right_title' => esc_html__( 'Gap', 'post-carousel' ),
61 'all_placeholder' => esc_html__( 'all', 'post-carousel' ),
62 'top' => true,
63 'left' => true,
64 'bottom' => true,
65 'right' => true,
66 'unit' => true,
67 'show_units' => true,
68 'all' => false,
69 'gap_between' => false,
70 'units' => array( 'px', '%', 'em' ),
71 )
72 );
73
74 $default_values = array(
75 'top' => '',
76 'right' => '',
77 'bottom' => '',
78 'left' => '',
79 'all' => '',
80 'top-bottom' => '',
81 'left-right' => '',
82 'unit' => 'px',
83 );
84
85 $value = wp_parse_args( $this->value, $default_values );
86 $unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
87 $is_unit = ( ! empty( $unit ) ) ? ' spf--is-unit' : '';
88
89 echo wp_kses_post( $this->field_before() );
90
91 echo '<div class="spf--inputs">';
92
93 if ( ! empty( $args['all'] ) ) {
94
95 $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . esc_attr( $args['all_placeholder'] ) . '"' : '';
96
97 echo '<div class="spf--input">';
98 echo ( ! empty( $args['all_icon'] ) ) ? '<span class="spf--label spf--icon">' . wp_kses_post( $args['all_icon'] ) . '</span>' : '';
99 echo '<input type="number" name="' . esc_attr( $this->field_name( '[all]' ) ) . '" value="' . esc_attr( $value['all'] ) . '"' . wp_kses_post( $placeholder ) . ' class="spf-input-number' . esc_attr( $is_unit ) . '" step="any" />';
100 echo ( $unit ) ? '<span class="spf--label spf--unit">' . esc_attr( $args['units'][0] ) . '</span>' : '';
101 echo '</div>';
102
103 } elseif ( $args['gap_between'] ) {
104
105 foreach ( array( 'left-right', 'top-bottom' ) as $prop ) {
106
107 $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . esc_attr( $args['all_placeholder'] ) . '"' : '';
108
109 $icon = ( 'top-bottom' === $prop ) ? 'arrow_v' : 'arrow_h';
110 $name = ( 'top-bottom' === $prop ) ? 'top-bottom' : 'left-right';
111 $title = ( 'top-bottom' === $prop ) ? esc_attr( $args['top_bottom_title'] ) : esc_attr( $args['left_right_title'] );
112
113 echo '<div class="spf--spacing">';
114 echo '<div class="spf--title">' . esc_html( $title ) . '</div>';
115 echo '<div class="spf--input">';
116 echo ( ! empty( $args[ $icon ] ) ) ? '<span class="spf--label spf--icon">' . wp_kses_post( $args[ $icon ] ) . '</span>' : '';
117 echo '<input type="number" name="' . esc_attr( $this->field_name( '[' . $name . ']' ) ) . '" value="' . esc_attr( $value[ $name ] ) . '"' . wp_kses_post( $placeholder ) . ' class="spf-input-number' . esc_attr( $is_unit ) . '" step="any" />';
118 echo ( $unit ) ? '<span class="spf--label spf--unit">' . esc_attr( $args['units'][0] ) . '</span>' : '';
119 echo '</div>';
120 echo '</div>';
121 }
122 } else {
123
124 $properties = array();
125
126 foreach ( array( 'top', 'right', 'bottom', 'left' ) as $prop ) {
127 if ( ! empty( $args[ $prop ] ) ) {
128 $properties[] = $prop;
129 }
130 }
131
132 $properties = ( array( 'right', 'left' ) === $properties ) ? array_reverse( $properties ) : $properties;
133
134 foreach ( $properties as $property ) {
135
136 echo '<div class="spf--spacing-input">';
137 echo '<div class="spf--title">' . esc_html( $property ) . '</div>';
138 echo '<div class="spf--input">';
139 echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '<span class="spf--label spf--icon">' . wp_kses_post( $args[ $property . '_icon' ] ) . '</span>' : '';
140 echo '<input type="number" name="' . esc_attr( $this->field_name( '[' . $property . ']' ) ) . '" value="' . esc_attr( $value[ $property ] ) . '" class="spf-input-number' . esc_attr( $is_unit ) . '" step="any" />';
141 echo ( $unit ) ? '<span class="spf--label spf--unit">' . esc_attr( $args['units'][0] ) . '</span>' : '';
142 echo '</div>';
143 echo '</div>';
144
145 }
146 }
147
148 if ( ! empty( $args['unit'] ) && ! empty( $args['show_units'] ) && count( $args['units'] ) > 1 ) {
149 echo '<div class="spf--spacing pcp-units">';
150 echo '<div class="spf--input">';
151 echo '<select name="' . esc_attr( $this->field_name( '[unit]' ) ) . '">';
152 foreach ( $args['units'] as $unit ) {
153 $selected = ( $value['unit'] === $unit ) ? ' selected' : '';
154 echo '<option value="' . esc_attr( $unit ) . '"' . esc_attr( $selected ) . '>' . esc_attr( $unit ) . '</option>';
155 }
156 echo '</select>';
157 echo '</div>';
158 echo '</div>';
159 }
160
161 echo '</div>';
162
163 echo wp_kses_post( $this->field_after() );
164
165 }
166
167 }
168 }
169