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
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.2.10, at admin/views/sp-framework/fields/group/group.php

149 lines 5.3 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 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 parent::__construct( $field, $value, $unique, $where, $parent );
15 }
16
17 public function render() {
18
19 $args = wp_parse_args(
20 $this->field,
21 array(
22 'max' => 0,
23 'min' => 0,
24 'fields' => array(),
25 'button_title' => esc_html__( 'Add New', 'smart-post-show' ),
26 'accordion_title_prefix' => '',
27 'accordion_title_number' => false,
28 'accordion_title_auto' => true,
29 )
30 );
31
32 $title_prefix = ( ! empty( $args['accordion_title_prefix'] ) ) ? $args['accordion_title_prefix'] : '';
33 $title_number = ( ! empty( $args['accordion_title_number'] ) ) ? true : false;
34 $title_auto = ( ! empty( $args['accordion_title_auto'] ) ) ? true : false;
35
36 if ( ! empty( $this->parent ) && preg_match( '/' . preg_quote( '[' . $this->field['id'] . ']' ) . '/', $this->parent ) ) {
37
38 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>';
39
40 } else {
41
42 echo $this->field_before();
43
44 echo '<div class="spf-cloneable-item spf-cloneable-hidden">';
45
46 echo '<div class="spf-cloneable-helper">';
47 echo '<i class="spf-cloneable-sort fa fa-arrows"></i>';
48 echo '<i class="spf-cloneable-clone fa fa-clone"></i>';
49 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>';
50 echo '</div>';
51
52 echo '<h4 class="spf-cloneable-title">';
53 echo '<span class="spf-cloneable-text">';
54 echo ( $title_number ) ? '<span class="spf-cloneable-title-number"></span>' : '';
55 echo ( $title_prefix ) ? '<span class="spf-cloneable-title-prefix">' . $title_prefix . '</span>' : '';
56 echo ( $title_auto ) ? '<span class="spf-cloneable-value"><span class="spf-cloneable-placeholder"></span></span>' : '';
57 echo '</span>';
58 echo '</h4>';
59
60 echo '<div class="spf-cloneable-content">';
61 foreach ( $this->field['fields'] as $field ) {
62
63 $field_parent = $this->parent . '[' . $this->field['id'] . ']';
64 $field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
65
66 SP_PC::field( $field, $field_default, '_nonce', 'field/group', $field_parent );
67
68 }
69 echo '</div>';
70
71 echo '</div>';
72
73 echo '<div class="spf-cloneable-wrapper spf-data-wrapper" data-title-number="' . $title_number . '" data-unique-id="' . $this->unique . '" data-field-id="[' . $this->field['id'] . ']" data-max="' . $args['max'] . '" data-min="' . $args['min'] . '">';
74
75 if ( ! empty( $this->value ) ) {
76
77 $num = 0;
78
79 foreach ( $this->value as $value ) {
80
81 $first_id = ( isset( $this->field['fields'][0]['id'] ) ) ? $this->field['fields'][0]['id'] : '';
82
83 $first_value = ( isset( $value[ $first_id ] ) ) ? $value[ $first_id ] : '';
84
85 echo '<div class="spf-cloneable-item">';
86
87 echo '<div class="spf-cloneable-helper">';
88 echo '<i class="spf-cloneable-sort fa fa-arrows"></i>';
89 echo '<i class="spf-cloneable-clone fa fa-clone"></i>';
90 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>';
91 echo '</div>';
92
93 echo '<h4 class="spf-cloneable-title">';
94 echo '<span class="spf-cloneable-text">';
95 echo ( $title_number ) ? '<span class="spf-cloneable-title-number">' . ( $num + 1 ) . ' . </span>' : '';
96 echo ( $title_prefix ) ? '<span class="spf-cloneable-title-prefix">' . $title_prefix . '</span>' : '';
97 echo ( $title_auto ) ? '<span class="spf-cloneable-value">' . $first_value . '</span>' : '';
98 echo '</span>';
99 echo '</h4>';
100
101 echo '<div class="spf-cloneable-content">';
102
103 foreach ( $this->field['fields'] as $field ) {
104
105 $field_parent = $this->parent . '[' . $this->field['id'] . ']';
106 $field_unique = ( ! empty( $this->unique ) ) ? $this->unique . '[' . $this->field['id'] . '][' . $num . ']' : $this->field['id'] . '[' . $num . ']';
107 $field_value = ( isset( $field['id'] ) && isset( $value[ $field['id'] ] ) ) ? $value[ $field['id'] ] : '';
108
109 SP_PC::field( $field, $field_value, $field_unique, 'field/group', $field_parent );
110
111 }
112
113 echo '</div>';
114
115 echo '</div>';
116
117 $num++;
118
119 }
120 }
121
122 echo '</div>';
123
124 echo '<div class="spf-cloneable-alert spf-cloneable-max">' . esc_html__( 'You can not add more than', 'smart-post-show' ) . ' ' . $args['max'] . '</div>';
125 echo '<div class="spf-cloneable-alert spf-cloneable-min">' . esc_html__( 'You can not remove less than', 'smart-post-show' ) . ' ' . $args['min'] . '</div>';
126
127 echo '<a href="#" class="button button-primary spf-cloneable-add">' . $args['button_title'] . '</a>';
128
129 echo $this->field_after();
130
131 }
132
133 }
134
135 public function enqueue() {
136
137 if ( ! wp_script_is( 'jquery-ui-accordion' ) ) {
138 wp_enqueue_script( 'jquery-ui-accordion' );
139 }
140
141 if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
142 wp_enqueue_script( 'jquery-ui-sortable' );
143 }
144
145 }
146
147 }
148 }
149