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
← All changes | admin/views/sp-framework/fields/spacing/spacing.php +74 -73 4.0.7 → 2.2.10 View file →
@@ -1,25 +1,14 @@
1 -<?php
1 +<?php if ( ! defined( 'ABSPATH' ) ) {
2 + die; } // Cannot access directly.
2 3 /**
3 - * The framework spacing fields file.
4 4 *
5 - * @package Smart_Post_Show
6 - * @subpackage Smart_Post_Show/admin
5 + * Field: spacing
6 + *
7 + * @since 1.0.0
8 + * @version 1.0.0
7 9 */
8 -
9 -if ( ! defined( 'ABSPATH' ) ) {
10 - exit; // Exit if accessed directly.
11 -}
12 -
13 10 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 11 class SP_PC_Field_spacing extends SP_PC_Fields {
23 12
24 13 /**
25 14 * Spacing field constructor.
@@ -47,40 +36,34 @@
47 36 'top_icon' => '<i class="fa fa-long-arrow-up"></i>',
48 37 'right_icon' => '<i class="fa fa-long-arrow-right"></i>',
49 38 'bottom_icon' => '<i class="fa fa-long-arrow-down"></i>',
50 39 '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' ),
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' ),
62 46 'top' => true,
63 47 'left' => true,
64 48 'bottom' => true,
65 49 'right' => true,
66 50 'unit' => true,
51 + 'min' => '0',
67 52 'show_units' => true,
68 53 'all' => false,
69 - 'gap_between' => false,
70 54 'units' => array( 'px', '%', 'em' ),
71 55 )
72 56 );
73 57
74 58 $default_values = array(
75 - 'top' => '',
76 - 'right' => '',
77 - 'bottom' => '',
78 - 'left' => '',
79 - 'all' => '',
80 - 'top-bottom' => '',
81 - 'left-right' => '',
82 - 'unit' => 'px',
59 + 'top' => '',
60 + 'right' => '',
61 + 'bottom' => '',
62 + 'left' => '',
63 + 'all' => '',
64 + 'unit' => 'px',
65 + 'min' => '',
83 66 );
84 67
85 68 $value = wp_parse_args( $this->value, $default_values );
86 69 $unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
@@ -85,41 +68,24 @@
85 68 $value = wp_parse_args( $this->value, $default_values );
86 69 $unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
87 70 $is_unit = ( ! empty( $unit ) ) ? ' spf--is-unit' : '';
88 71
89 - echo wp_kses_post( $this->field_before() );
72 + echo $this->field_before();
90 73
74 + $min = ( isset( $args['min'] ) ) ? ' min="' . $args['min'] . '"' : '';
75 +
91 76 echo '<div class="spf--inputs">';
92 77
93 78 if ( ! empty( $args['all'] ) ) {
94 79
95 - $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . esc_attr( $args['all_placeholder'] ) . '"' : '';
80 + $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . $args['all_placeholder'] . '"' : '';
96 81
97 82 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>' : '';
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>' : '';
101 86 echo '</div>';
102 87
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 88 } else {
123 89
124 90 $properties = array();
125 91
@@ -128,40 +94,75 @@
128 94 $properties[] = $prop;
129 95 }
130 96 }
131 97
132 - $properties = ( array( 'right', 'left' ) === $properties ) ? array_reverse( $properties ) : $properties;
98 + $properties = ( $properties === array( 'right', 'left' ) ) ? array_reverse( $properties ) : $properties;
133 99
134 100 foreach ( $properties as $property ) {
135 101
136 - echo '<div class="spf--spacing-input">';
137 - echo '<div class="spf--title">' . esc_html( $property ) . '</div>';
102 + $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . $args[ $property . '_placeholder' ] . '"' : '';
103 +
138 104 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>' : '';
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>' : '';
142 108 echo '</div>';
143 - echo '</div>';
144 109
145 110 }
146 111 }
147 112
148 113 if ( ! empty( $args['unit'] ) && ! empty( $args['show_units'] ) && count( $args['units'] ) > 1 ) {
149 - echo '<div class="spf--spacing pcp-units">';
150 114 echo '<div class="spf--input">';
151 - echo '<select name="' . esc_attr( $this->field_name( '[unit]' ) ) . '">';
115 + echo '<select name="' . $this->field_name( '[unit]' ) . '">';
152 116 foreach ( $args['units'] as $unit ) {
153 117 $selected = ( $value['unit'] === $unit ) ? ' selected' : '';
154 - echo '<option value="' . esc_attr( $unit ) . '"' . esc_attr( $selected ) . '>' . esc_attr( $unit ) . '</option>';
118 + echo '<option value="' . $unit . '"' . $selected . '>' . $unit . '</option>';
155 119 }
156 120 echo '</select>';
157 121 echo '</div>';
158 - echo '</div>';
159 122 }
160 123
161 124 echo '</div>';
162 125
163 - echo wp_kses_post( $this->field_after() );
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;
164 165
165 166 }
166 167
167 168 }