PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 2.4.2
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v2.4.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 / column / column.php

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

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