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

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

174 lines 6.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The framework group fields file.
4 *
5 * @package Smart_Post_Show
6 * @subpackage Smart_Post_Show/admin
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 die;
11 } // Cannot access directly.
12
13
14 if ( ! class_exists( 'SP_PC_Field_group' ) ) {
15 /**
16 * SP_PC_Field_group
17 */
18 class SP_PC_Field_group extends SP_PC_Fields {
19 /**
20 * Field constructor.
21 *
22 * @param array $field The field type.
23 * @param string $value The values of the field.
24 * @param string $unique The unique ID for the field.
25 * @param string $where To where show the output CSS.
26 * @param string $parent The parent args.
27 */
28 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
29 parent::__construct( $field, $value, $unique, $where, $parent );
30 }
31
32 /**
33 * The render method.
34 *
35 * @return void
36 */
37 public function render() {
38
39 $args = wp_parse_args(
40 $this->field,
41 array(
42 'max' => 0,
43 'min' => 0,
44 'fields' => array(),
45 'button_title' => esc_html__( 'Add New', 'post-carousel' ),
46 'accordion_title_prefix' => '',
47 'accordion_title_number' => false,
48 'accordion_title_auto' => true,
49 )
50 );
51
52 $title_prefix = ( ! empty( $args['accordion_title_prefix'] ) ) ? $args['accordion_title_prefix'] : '';
53 $title_number = ( ! empty( $args['accordion_title_number'] ) ) ? true : false;
54 $title_auto = ( ! empty( $args['accordion_title_auto'] ) ) ? true : false;
55
56 if ( ! empty( $this->parent ) && preg_match( '/' . preg_quote( '[' . $this->field['id'] . ']' ) . '/', $this->parent ) ) {
57
58 echo '<div class="spf-notice spf-notice-danger">' . esc_html__( 'Error: Nested field id can not be same with another nested field id.', 'post-carousel' ) . '</div>';
59
60 } else {
61
62 echo wp_kses_post( $this->field_before() );
63
64 echo '<div class="spf-cloneable-item spf-cloneable-hidden">';
65
66 echo '<div class="spf-cloneable-helper">';
67 echo '<i class="spf-cloneable-sort fa fa-arrows"></i>';
68 echo '<i class="spf-cloneable-clone fa fa-clone"></i>';
69 echo '<i class="spf-cloneable-remove spf-confirm fa fa-times" data-confirm="' . esc_html__( 'Are you sure to delete this item?', 'post-carousel' ) . '"></i>';
70 echo '</div>';
71
72 echo '<h4 class="spf-cloneable-title">';
73 echo '<span class="spf-cloneable-text">';
74 echo ( $title_number ) ? '<span class="spf-cloneable-title-number"></span>' : '';
75 echo ( $title_prefix ) ? '<span class="spf-cloneable-title-prefix">' . esc_html( $title_prefix ) . '</span>' : '';
76 echo ( $title_auto ) ? '<span class="spf-cloneable-value"><span class="spf-cloneable-placeholder"></span></span>' : '';
77 echo '</span>';
78 echo '</h4>';
79
80 echo '<div class="spf-cloneable-content">';
81 foreach ( $this->field['fields'] as $field ) {
82
83 $field_parent = $this->parent . '[' . $this->field['id'] . ']';
84 $field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
85
86 SP_PC::field( $field, $field_default, '_nonce', 'field/group', $field_parent );
87
88 }
89 echo '</div>';
90
91 echo '</div>';
92
93 echo '<div class="spf-cloneable-wrapper spf-data-wrapper" data-title-number="' . esc_attr( $title_number ) . '" data-unique-id="' . esc_attr( $this->unique ) . '" data-field-id="[' . esc_attr( $this->field['id'] ) . ']" data-max="' . esc_attr( $args['max'] ) . '" data-min="' . esc_attr( $args['min'] ) . '">';
94
95 if ( ! empty( $this->value ) ) {
96
97 $num = 0;
98
99 foreach ( $this->value as $value ) {
100
101 $first_id = ( isset( $this->field['fields'][0]['id'] ) ) ? $this->field['fields'][0]['id'] : '';
102
103 $first_value = ( isset( $value[ $first_id ] ) ) ? $value[ $first_id ] : '';
104
105 echo '<div class="spf-cloneable-item">';
106
107 echo '<div class="spf-cloneable-helper">';
108 echo '<i class="spf-cloneable-sort fa fa-arrows"></i>';
109 echo '<i class="spf-cloneable-clone fa fa-clone"></i>';
110 echo '<i class="spf-cloneable-remove spf-confirm fa fa-times" data-confirm="' . esc_html__( 'Are you sure to delete this item?', 'post-carousel' ) . '"></i>';
111 echo '</div>';
112
113 echo '<h4 class="spf-cloneable-title">';
114 echo '<span class="spf-cloneable-text">';
115 echo ( $title_number ) ? '<span class="spf-cloneable-title-number">' . esc_html( ( $num + 1 ) ) . ' . </span>' : '';
116 echo ( $title_prefix ) ? '<span class="spf-cloneable-title-prefix">' . esc_html( $title_prefix ) . '</span>' : '';
117 echo ( $title_auto ) ? '<span class="spf-cloneable-value">' . esc_html( $first_value ) . '</span>' : '';
118 echo '</span>';
119 echo '</h4>';
120
121 echo '<div class="spf-cloneable-content">';
122
123 foreach ( $this->field['fields'] as $field ) {
124
125 $field_parent = $this->parent . '[' . $this->field['id'] . ']';
126 $field_unique = ( ! empty( $this->unique ) ) ? $this->unique . '[' . $this->field['id'] . '][' . $num . ']' : $this->field['id'] . '[' . $num . ']';
127 $field_value = ( isset( $field['id'] ) && isset( $value[ $field['id'] ] ) ) ? $value[ $field['id'] ] : '';
128
129 SP_PC::field( $field, $field_value, $field_unique, 'field/group', $field_parent );
130
131 }
132
133 echo '</div>';
134
135 echo '</div>';
136
137 $num++;
138
139 }
140 }
141
142 echo '</div>';
143
144 echo '<div class="spf-cloneable-alert spf-cloneable-max">' . esc_html__( 'You can not add more than', 'post-carousel' ) . ' ' . esc_html( $args['max'] ) . '</div>';
145 echo '<div class="spf-cloneable-alert spf-cloneable-min">' . esc_html__( 'You can not remove less than', 'post-carousel' ) . ' ' . esc_html( $args['min'] ) . '</div>';
146
147 echo '<a href="#" class="button button-primary spf-cloneable-add">' . esc_html( $args['button_title'] ) . '</a>';
148
149 echo wp_kses_post( $this->field_after() );
150
151 }
152
153 }
154
155 /**
156 * Enqueue Accordion UI.
157 *
158 * @return void
159 */
160 public function enqueue() {
161
162 if ( ! wp_script_is( 'jquery-ui-accordion' ) ) {
163 wp_enqueue_script( 'jquery-ui-accordion' );
164 }
165
166 if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
167 wp_enqueue_script( 'jquery-ui-sortable' );
168 }
169
170 }
171
172 }
173 }
174