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

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

147 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The framework column 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 *
13 * Field: column
14 *
15 * @since 1.0.0
16 * @version 1.0.0
17 */
18 if ( ! class_exists( 'SP_PC_Field_column' ) ) {
19
20 /**
21 * The column field class.
22 */
23 class SP_PC_Field_column extends SP_PC_Fields {
24
25 /**
26 * Column field constructor.
27 *
28 * @param array $field The field type.
29 * @param string $value The values of the field.
30 * @param string $unique The unique ID for the field.
31 * @param string $where To where show the output CSS.
32 * @param string $parent The parent args.
33 */
34 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
35 parent::__construct( $field, $value, $unique, $where, $parent );
36 }
37
38 /**
39 * Render column function.
40 *
41 * @return void
42 */
43 public function render() {
44
45 $args = wp_parse_args(
46 $this->field,
47 array(
48 'lg_desktop_icon' => '<i class="fa fa-television"></i>',
49 'desktop_icon' => '<i class="fa fa-desktop"></i>',
50 'tablet_icon' => '<i class="fa fa-tablet"></i>',
51 'mobile_landscape_icon' => '<i class="fa fa-mobile"></i>',
52 'mobile_icon' => '<i class="fa fa-mobile"></i>',
53 'all_icon' => '<i class="fa fa-arrows"></i>',
54 'lg_desktop_placeholder' => esc_html__( 'Large Desktop', 'post-carousel' ),
55 'desktop_placeholder' => esc_html__( 'Desktop', 'post-carousel' ),
56 'tablet_placeholder' => esc_html__( 'Tablet', 'post-carousel' ),
57 'mobile_landscape_placeholder' => esc_html__( 'Mobile Landscape', 'post-carousel' ),
58 'mobile_placeholder' => esc_html__( 'Mobile', 'post-carousel' ),
59 'all_placeholder' => esc_html__( 'all', 'post-carousel' ),
60 'lg_desktop' => true,
61 'desktop' => true,
62 'tablet' => true,
63 'mobile_landscape' => true,
64 'mobile' => true,
65 'min' => '1',
66 'unit' => false,
67 'all' => false,
68 'units' => array( 'px', '%', 'em' ),
69 )
70 );
71
72 $default_values = array(
73 'lg_desktop' => '5',
74 'desktop' => '4',
75 'tablet' => '3',
76 'mobile_landscape' => '2',
77 'mobile' => '1',
78 'min' => '',
79 'all' => '',
80 'unit' => 'px',
81 );
82
83 // $value = wp_parse_args( $this->value, $default_values );
84 $value = wp_parse_args( $this->value, $default_values );
85 $unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
86 $is_unit = ( ! empty( $unit ) ) ? ' spf--is-unit' : '';
87
88 echo wp_kses_post( $this->field_before() );
89
90 echo '<div class="spf--inputs">';
91
92 $min = ( isset( $args['min'] ) ) ? ' min="' . $args['min'] . '"' : '';
93 if ( ! empty( $args['all'] ) ) {
94
95 $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . $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 ) . wp_kses_post( $min ) . ' class="spf-number" required/>';
100 echo ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? '<span class="spf--label spf--unit">' . esc_html( $args['units'][0] ) . '</span>' : '';
101 echo '</div>';
102
103 } else {
104
105 $properties = array();
106
107 foreach ( array( 'lg_desktop', 'desktop', 'tablet', 'mobile_landscape', 'mobile' ) as $prop ) {
108 if ( ! empty( $args[ $prop ] ) ) {
109 $properties[] = $prop;
110 }
111 }
112
113 $properties = ( array( 'tablet', 'mobile' ) === $properties ) ? array_reverse( $properties ) : $properties;
114
115 foreach ( $properties as $property ) {
116
117 $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . $args[ $property . '_placeholder' ] . '"' : '';
118
119 echo '<div class="spf--input">';
120 echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '<span class="spf--label spf--icon">' . wp_kses_post( $args[ $property . '_icon' ] ) . '</span>' : '';
121 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" required/>';
122 echo ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? '<span class="spf--label spf--unit">' . esc_html( $args['units'][0] ) . '</span>' : '';
123 echo '</div>';
124
125 }
126 }
127
128 if ( ! empty( $args['unit'] ) && count( $args['units'] ) > 1 ) {
129 echo '<div class="spf--input">';
130
131 echo '<select name="' . esc_attr( $this->field_name( '[unit]' ) ) . '">';
132 foreach ( $args['units'] as $unit ) {
133 $selected = ( $value['unit'] === $unit ) ? ' selected' : '';
134 echo '<option value="' . esc_attr( $unit ) . '"' . esc_attr( $selected ) . '>' . esc_html( $unit ) . '</option>';
135 }
136 echo '</select>';
137 echo '</div>';
138 }
139
140 echo '</div>';
141
142 echo wp_kses_post( $this->field_after() );
143
144 }
145 }
146 }
147