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

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

142 lines 4.8 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 die; } // Cannot access directly.
11
12 if ( ! class_exists( 'SP_PC_Field_spacing' ) ) {
13
14 /**
15 *
16 * Field: spacing
17 *
18 * @since 1.0.0
19 * @version 1.0.0
20 */
21 class SP_PC_Field_spacing extends SP_PC_Fields {
22
23 /**
24 * Spacing field constructor.
25 *
26 * @param array $field The field type.
27 * @param string $value The values of the field.
28 * @param string $unique The unique ID for the field.
29 * @param string $where To where show the output CSS.
30 * @param string $parent The parent args.
31 */
32 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
33 parent::__construct( $field, $value, $unique, $where, $parent );
34 }
35
36 /**
37 * Function to render the field.
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 'bottom_icon' => '<i class="fa fa-long-arrow-down"></i>',
49 'left_icon' => '<i class="fa fa-long-arrow-left"></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 'unit' => true,
61 'min' => '-50',
62 'show_units' => true,
63 'all' => false,
64 'units' => array( 'px', '%', 'em' ),
65 )
66 );
67
68 $default_values = array(
69 'top' => '',
70 'right' => '',
71 'bottom' => '',
72 'left' => '',
73 'all' => '',
74 'unit' => 'px',
75 'min' => '',
76 );
77
78 $value = wp_parse_args( $this->value, $default_values );
79 $unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
80 $is_unit = ( ! empty( $unit ) ) ? ' spf--is-unit' : '';
81
82 echo wp_kses_post( $this->field_before() );
83
84 $min = ( isset( $args['min'] ) ) ? ' min="' . $args['min'] . '"' : '';
85
86 echo '<div class="spf--inputs">';
87
88 if ( ! empty( $args['all'] ) ) {
89
90 $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . $args['all_placeholder'] . '"' : '';
91
92 echo '<div class="spf--input">';
93 echo ( ! empty( $args['all_icon'] ) ) ? '<span class="spf--label spf--icon">' . wp_kses_post( $args['all_icon'] ) . '</span>' : '';
94 echo '<input type="number" 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 ) . '" />';
95 echo ( $unit ) ? '<span class="spf--label spf--unit">' . wp_kses_post( $args['units'][0] ) . '</span>' : '';
96 echo '</div>';
97
98 } else {
99
100 $properties = array();
101
102 foreach ( array( 'top', 'right', 'bottom', 'left' ) as $prop ) {
103 if ( ! empty( $args[ $prop ] ) ) {
104 $properties[] = $prop;
105 }
106 }
107
108 $properties = ( array( 'right', 'left' ) === $properties ) ? array_reverse( $properties ) : $properties;
109
110 foreach ( $properties as $property ) {
111
112 $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . $args[ $property . '_placeholder' ] . '"' : '';
113
114 echo '<div class="spf--input">';
115 echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '<span class="spf--label spf--icon">' . wp_kses_post( $args[ $property . '_icon' ] ) . '</span>' : '';
116 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' . esc_attr( $is_unit ) . '" />';
117 echo ( $unit ) ? '<span class="spf--label spf--unit">' . wp_kses_post( $args['units'][0] ) . '</span>' : '';
118 echo '</div>';
119
120 }
121 }
122
123 if ( ! empty( $args['unit'] ) && ! empty( $args['show_units'] ) && count( $args['units'] ) > 1 ) {
124 echo '<div class="spf--input">';
125 echo '<select name="' . esc_attr( $this->field_name( '[unit]' ) ) . '">';
126 foreach ( $args['units'] as $unit ) {
127 $selected = ( $value['unit'] === $unit ) ? ' selected' : '';
128 echo '<option value="' . esc_attr( $unit ) . '"' . esc_attr( $selected ) . '>' . esc_html( $unit ) . '</option>';
129 }
130 echo '</select>';
131 echo '</div>';
132 }
133
134 echo '</div>';
135
136 echo wp_kses_post( $this->field_after() );
137
138 }
139
140 }
141 }
142