PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 2.4.1
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v2.4.1
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.1, at admin/views/sp-framework/fields/group/group.php

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