PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.4.0
StreamCast – bring live radio to your site with a sleek player v2.4.0
2.4.5 2.4.4 trunk 1.0 1.1 2.0.0 2.1.10 2.1.2 2.1.4 2.1.5 2.1.8 2.2.1 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 All 29 releases
← All changes | frameworks/codestar-framework/classes/shortcode-options.class.php +302 -302 2.3.42.4.0 View file →
@@ -1,302 +1,302 @@
1 -<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 -/**
3 - *
4 - * Shortcoder Class
5 - *
6 - * @since 1.0.0
7 - * @version 1.0.0
8 - *
9 - */
10 -if ( ! class_exists( 'CSF_Shortcoder' ) ) {
11 - class CSF_Shortcoder extends CSF_Abstract{
12 -
13 - // constans
14 - public $unique = '';
15 - public $abstract = 'shortcoder';
16 - public $blocks = array();
17 - public $sections = array();
18 - public $pre_tabs = array();
19 - public $pre_sections = array();
20 - public $args = array(
21 - 'button_title' => 'Add Shortcode',
22 - 'select_title' => 'Select a shortcode',
23 - 'insert_title' => 'Insert Shortcode',
24 - 'show_in_editor' => true,
25 - 'show_in_custom' => false,
26 - 'defaults' => array(),
27 - 'class' => '',
28 - 'gutenberg' => array(
29 - 'title' => 'CSF Shortcodes',
30 - 'description' => 'CSF Shortcode Block',
31 - 'icon' => 'screenoptions',
32 - 'category' => 'widgets',
33 - 'keywords' => array( 'shortcode', 'csf', 'insert' ),
34 - 'placeholder' => 'Write shortcode here...',
35 - ),
36 - );
37 -
38 - // run shortcode construct
39 - public function __construct( $key, $params = array() ) {
40 -
41 - $this->unique = $key;
42 - $this->args = apply_filters( "csf_{$this->unique}_args", wp_parse_args( $params['args'], $this->args ), $this );
43 - $this->sections = apply_filters( "csf_{$this->unique}_sections", $params['sections'], $this );
44 - $this->pre_tabs = $this->pre_tabs( $this->sections );
45 - $this->pre_sections = $this->pre_sections( $this->sections );
46 -
47 - add_action( 'admin_footer', array( $this, 'add_footer_modal_shortcode' ) );
48 - add_action( 'customize_controls_print_footer_scripts', array( $this, 'add_footer_modal_shortcode' ) );
49 - add_action( 'wp_ajax_csf-get-shortcode-'. $this->unique, array( $this, 'get_shortcode' ) );
50 -
51 - if ( ! empty( $this->args['show_in_editor'] ) ) {
52 -
53 - $name = str_replace( '_', '-', sanitize_title( $this->unique ) );
54 -
55 - CSF::$shortcode_instances[] = wp_parse_args( array( 'name' => 'csf/'. $name, 'modal_id' => $this->unique ), $this->args );
56 -
57 - // elementor editor support
58 - if ( CSF::is_active_plugin( 'elementor/elementor.php' ) ) {
59 - add_action( 'elementor/editor/before_enqueue_scripts', array( 'CSF', 'add_admin_enqueue_scripts' ) );
60 - add_action( 'elementor/editor/footer', array( 'CSF_Field_icon', 'add_footer_modal_icon' ) );
61 - add_action( 'elementor/editor/footer', array( $this, 'add_footer_modal_shortcode' ) );
62 - }
63 -
64 - }
65 -
66 - }
67 -
68 - // instance
69 - public static function instance( $key, $params = array() ) {
70 - return new self( $key, $params );
71 - }
72 -
73 - // get default value
74 - public function get_default( $field ) {
75 -
76 - $default = ( isset( $field['default'] ) ) ? $field['default'] : '';
77 - $default = ( isset( $this->args['defaults'][$field['id']] ) ) ? $this->args['defaults'][$field['id']] : $default;
78 -
79 - return $default;
80 -
81 - }
82 -
83 - public function add_footer_modal_shortcode() {
84 -
85 - if( ! wp_script_is( 'csf' ) ) {
86 - return;
87 - }
88 -
89 - $class = ( $this->args['class'] ) ? ' '. esc_attr( $this->args['class'] ) : '';
90 - $has_select = ( count( $this->pre_tabs ) > 1 ) ? true : false;
91 - $single_usage = ( ! $has_select ) ? ' csf-shortcode-single' : '';
92 - $hide_header = ( ! $has_select ) ? ' hidden' : '';
93 -
94 - ?>
95 - <div id="csf-modal-<?php echo esc_attr( $this->unique ); ?>" class="wp-core-ui csf-modal csf-shortcode hidden<?php echo esc_attr( $single_usage . $class ); ?>" data-modal-id="<?php echo esc_attr( $this->unique ); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'csf_shortcode_nonce' ) ); ?>">
96 - <div class="csf-modal-table">
97 - <div class="csf-modal-table-cell">
98 - <div class="csf-modal-overlay"></div>
99 - <div class="csf-modal-inner">
100 - <div class="csf-modal-title">
101 - <?php echo $this->args['button_title']; ?>
102 - <div class="csf-modal-close"></div>
103 - </div>
104 - <?php
105 -
106 - echo '<div class="csf-modal-header'. esc_attr( $hide_header ) .'">';
107 - echo '<select>';
108 - echo ( $has_select ) ? '<option value="">'. esc_attr( $this->args['select_title'] ) .'</option>' : '';
109 -
110 - $tab_key = 1;
111 -
112 - foreach ( $this->pre_tabs as $tab ) {
113 -
114 - if ( ! empty( $tab['subs'] ) ) {
115 -
116 - echo '<optgroup label="'. esc_attr( $tab['title'] ) .'">';
117 -
118 - foreach ( $tab['subs'] as $sub ) {
119 -
120 - $view = ( ! empty( $sub['view'] ) ) ? ' data-view="'. esc_attr( $sub['view'] ) .'"' : '';
121 - $shortcode = ( ! empty( $sub['shortcode'] ) ) ? ' data-shortcode="'. esc_attr( $sub['shortcode'] ) .'"' : '';
122 - $group = ( ! empty( $sub['group_shortcode'] ) ) ? ' data-group="'. esc_attr( $sub['group_shortcode'] ) .'"' : '';
123 -
124 - echo '<option value="'. esc_attr( $tab_key ) .'"'. $view . $shortcode . $group .'>'. esc_attr( $sub['title'] ) .'</option>';
125 -
126 - $tab_key++;
127 -
128 - }
129 -
130 - echo '</optgroup>' ;
131 -
132 - } else {
133 -
134 - $view = ( ! empty( $tab['view'] ) ) ? ' data-view="'. esc_attr( $tab['view'] ) .'"' : '';
135 - $shortcode = ( ! empty( $tab['shortcode'] ) ) ? ' data-shortcode="'. esc_attr( $tab['shortcode'] ) .'"' : '';
136 - $group = ( ! empty( $tab['group_shortcode'] ) ) ? ' data-group="'. esc_attr( $tab['group_shortcode'] ) .'"' : '';
137 -
138 - echo '<option value="'. esc_attr( $tab_key ) .'"'. $view . $shortcode . $group .'>'. esc_attr( $tab['title'] ) .'</option>';
139 -
140 - $tab_key++;
141 -
142 - }
143 -
144 - }
145 -
146 - echo '</select>';
147 - echo '</div>';
148 -
149 - ?>
150 - <div class="csf-modal-content">
151 - <div class="csf-modal-loading"><div class="csf-loading"></div></div>
152 - <div class="csf-modal-load"></div>
153 - </div>
154 - <div class="csf-modal-insert-wrapper hidden"><a href="#" class="button button-primary csf-modal-insert"><?php echo $this->args['insert_title']; ?></a></div>
155 - </div>
156 - </div>
157 - </div>
158 - </div>
159 - <?php
160 - }
161 -
162 - public function get_shortcode() {
163 -
164 - ob_start();
165 -
166 - $nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
167 - $shortcode_key = ( ! empty( $_POST[ 'shortcode_key' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'shortcode_key' ] ) ) : '';
168 -
169 - if ( ! empty( $shortcode_key ) && wp_verify_nonce( $nonce, 'csf_shortcode_nonce' ) ) {
170 -
171 - $unallows = array( 'group', 'repeater', 'sorter' );
172 - $section = $this->pre_sections[$shortcode_key-1];
173 - $shortcode = ( ! empty( $section['shortcode'] ) ) ? $section['shortcode'] : '';
174 - $view = ( ! empty( $section['view'] ) ) ? $section['view'] : 'normal';
175 -
176 - if ( ! empty( $section ) ) {
177 -
178 - //
179 - // View: normal
180 - if ( ! empty( $section['fields'] ) && $view !== 'repeater' ) {
181 -
182 - echo '<div class="csf-fields">';
183 -
184 - echo ( ! empty( $section['description'] ) ) ? '<div class="csf-field csf-section-description">'. $section['description'] .'</div>' : '';
185 -
186 - foreach ( $section['fields'] as $field ) {
187 -
188 - if ( in_array( $field['type'], $unallows ) ) { $field['_notice'] = true; }
189 -
190 - // Extra tag improves for spesific fields (border, spacing, dimensions etc...)
191 - $field['tag_prefix'] = ( ! empty( $field['tag_prefix'] ) ) ? $field['tag_prefix'] .'_' : '';
192 -
193 - $field_default = ( isset( $field['id'] ) ) ? $this->get_default( $field ) : '';
194 -
195 - CSF::field( $field, $field_default, $shortcode, 'shortcode' );
196 -
197 - }
198 -
199 - echo '</div>';
200 -
201 - }
202 -
203 - //
204 - // View: group and repeater fields
205 - $repeatable_fields = ( $view === 'repeater' && ! empty( $section['fields'] ) ) ? $section['fields'] : array();
206 - $repeatable_fields = ( $view === 'group' && ! empty( $section['group_fields'] ) ) ? $section['group_fields'] : $repeatable_fields;
207 -
208 - if ( ! empty( $repeatable_fields ) ) {
209 -
210 - $button_title = ( ! empty( $section['button_title'] ) ) ? ' '. $section['button_title'] : esc_html__( 'Add New', 'csf' );
211 - $inner_shortcode = ( ! empty( $section['group_shortcode'] ) ) ? $section['group_shortcode'] : $shortcode;
212 -
213 - echo '<div class="csf--repeatable">';
214 -
215 - echo '<div class="csf--repeat-shortcode">';
216 -
217 - echo '<div class="csf-repeat-remove fas fa-times"></div>';
218 -
219 - echo '<div class="csf-fields">';
220 -
221 - foreach ( $repeatable_fields as $field ) {
222 -
223 - if ( in_array( $field['type'], $unallows ) ) { $field['_notice'] = true; }
224 -
225 - // Extra tag improves for spesific fields (border, spacing, dimensions etc...)
226 - $field['tag_prefix'] = ( ! empty( $field['tag_prefix'] ) ) ? $field['tag_prefix'] .'_' : '';
227 -
228 - $field_default = ( isset( $field['id'] ) ) ? $this->get_default( $field ) : '';
229 -
230 - CSF::field( $field, $field_default, $inner_shortcode.'[0]', 'shortcode' );
231 -
232 - }
233 -
234 - echo '</div>';
235 -
236 - echo '</div>';
237 -
238 - echo '</div>';
239 -
240 - echo '<div class="csf--repeat-button-block"><a class="button csf--repeat-button" href="#"><i class="fas fa-plus-circle"></i> '. $button_title .'</a></div>';
241 -
242 - }
243 -
244 - }
245 -
246 - } else {
247 - echo '<div class="csf-field csf-error-text">'. esc_html__( 'Error: Invalid nonce verification.', 'csf' ) .'</div>';
248 - }
249 -
250 - wp_send_json_success( array( 'content' => ob_get_clean() ) );
251 -
252 - }
253 -
254 - // Once editor setup for gutenberg and media buttons
255 - public static function once_editor_setup() {
256 -
257 - if ( function_exists( 'register_block_type' ) ) {
258 - add_action( 'enqueue_block_editor_assets', array( 'CSF_Shortcoder', 'add_guteberg_blocks' ) );
259 - }
260 -
261 - if ( csf_wp_editor_api() ) {
262 - add_action( 'media_buttons', array( 'CSF_Shortcoder', 'add_media_buttons' ) );
263 - }
264 -
265 - }
266 -
267 - // Add gutenberg blocks.
268 - public static function add_guteberg_blocks() {
269 -
270 - $depends = array( 'wp-blocks', 'wp-element', 'wp-components' );
271 -
272 - if ( wp_script_is( 'wp-edit-widgets' ) ) {
273 - $depends[] = 'wp-edit-widgets';
274 - } else {
275 - $depends[] = 'wp-edit-post';
276 - }
277 -
278 - wp_enqueue_script( 'csf-gutenberg-block', CSF::include_plugin_url( 'assets/js/gutenberg.js' ), $depends );
279 -
280 - wp_localize_script( 'csf-gutenberg-block', 'csf_gutenberg_blocks', CSF::$shortcode_instances );
281 -
282 - foreach ( CSF::$shortcode_instances as $block ) {
283 -
284 - register_block_type( $block['name'], array(
285 - 'editor_script' => 'csf-gutenberg-block',
286 - ) );
287 -
288 - }
289 -
290 - }
291 -
292 - // Add media buttons
293 - public static function add_media_buttons( $editor_id ) {
294 -
295 - foreach ( CSF::$shortcode_instances as $value ) {
296 - echo '<a href="#" class="button button-primary csf-shortcode-button" data-editor-id="'. esc_attr( $editor_id ) .'" data-modal-id="'. esc_attr( $value['modal_id'] ) .'">'. esc_html( $value['button_title'] ) .'</a>';
297 - }
298 -
299 - }
300 -
301 - }
302 -}
1 +<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 +/**
3 + *
4 + * Shortcoder Class
5 + *
6 + * @since 1.0.0
7 + * @version 1.0.0
8 + *
9 + */
10 +if ( ! class_exists( 'CSF_Shortcoder' ) ) {
11 + class CSF_Shortcoder extends CSF_Abstract{
12 +
13 + // constans
14 + public $unique = '';
15 + public $abstract = 'shortcoder';
16 + public $blocks = array();
17 + public $sections = array();
18 + public $pre_tabs = array();
19 + public $pre_sections = array();
20 + public $args = array(
21 + 'button_title' => 'Add Shortcode',
22 + 'select_title' => 'Select a shortcode',
23 + 'insert_title' => 'Insert Shortcode',
24 + 'show_in_editor' => true,
25 + 'show_in_custom' => false,
26 + 'defaults' => array(),
27 + 'class' => '',
28 + 'gutenberg' => array(
29 + 'title' => 'CSF Shortcodes',
30 + 'description' => 'CSF Shortcode Block',
31 + 'icon' => 'screenoptions',
32 + 'category' => 'widgets',
33 + 'keywords' => array( 'shortcode', 'streamcast', 'insert' ),
34 + 'placeholder' => 'Write shortcode here...',
35 + ),
36 + );
37 +
38 + // run shortcode construct
39 + public function __construct( $key, $params = array() ) {
40 +
41 + $this->unique = $key;
42 + $this->args = apply_filters( "csf_{$this->unique}_args", wp_parse_args( $params['args'], $this->args ), $this );
43 + $this->sections = apply_filters( "csf_{$this->unique}_sections", $params['sections'], $this );
44 + $this->pre_tabs = $this->pre_tabs( $this->sections );
45 + $this->pre_sections = $this->pre_sections( $this->sections );
46 +
47 + add_action( 'admin_footer', array( $this, 'add_footer_modal_shortcode' ) );
48 + add_action( 'customize_controls_print_footer_scripts', array( $this, 'add_footer_modal_shortcode' ) );
49 + add_action( 'wp_ajax_csf-get-shortcode-'. $this->unique, array( $this, 'get_shortcode' ) );
50 +
51 + if ( ! empty( $this->args['show_in_editor'] ) ) {
52 +
53 + $name = str_replace( '_', '-', sanitize_title( $this->unique ) );
54 +
55 + CSF::$shortcode_instances[] = wp_parse_args( array( 'name' => 'csf/'. $name, 'modal_id' => $this->unique ), $this->args );
56 +
57 + // elementor editor support
58 + if ( CSF::is_active_plugin( 'elementor/elementor.php' ) ) {
59 + add_action( 'elementor/editor/before_enqueue_scripts', array( 'CSF', 'add_admin_enqueue_scripts' ) );
60 + add_action( 'elementor/editor/footer', array( 'CSF_Field_icon', 'add_footer_modal_icon' ) );
61 + add_action( 'elementor/editor/footer', array( $this, 'add_footer_modal_shortcode' ) );
62 + }
63 +
64 + }
65 +
66 + }
67 +
68 + // instance
69 + public static function instance( $key, $params = array() ) {
70 + return new self( $key, $params );
71 + }
72 +
73 + // get default value
74 + public function get_default( $field ) {
75 +
76 + $default = ( isset( $field['default'] ) ) ? $field['default'] : '';
77 + $default = ( isset( $this->args['defaults'][$field['id']] ) ) ? $this->args['defaults'][$field['id']] : $default;
78 +
79 + return $default;
80 +
81 + }
82 +
83 + public function add_footer_modal_shortcode() {
84 +
85 + if( ! wp_script_is( 'streamcast' ) ) {
86 + return;
87 + }
88 +
89 + $class = ( $this->args['class'] ) ? ' '. esc_attr( $this->args['class'] ) : '';
90 + $has_select = ( count( $this->pre_tabs ) > 1 ) ? true : false;
91 + $single_usage = ( ! $has_select ) ? ' csf-shortcode-single' : '';
92 + $hide_header = ( ! $has_select ) ? ' hidden' : '';
93 +
94 + ?>
95 + <div id="csf-modal-<?php echo esc_attr( $this->unique ); ?>" class="wp-core-ui csf-modal csf-shortcode hidden<?php echo esc_attr( $single_usage . $class ); ?>" data-modal-id="<?php echo esc_attr( $this->unique ); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'csf_shortcode_nonce' ) ); ?>">
96 + <div class="csf-modal-table">
97 + <div class="csf-modal-table-cell">
98 + <div class="csf-modal-overlay"></div>
99 + <div class="csf-modal-inner">
100 + <div class="csf-modal-title">
101 + <?php echo wp_kses_post( $this->args['button_title'] ); ?>
102 + <div class="csf-modal-close"></div>
103 + </div>
104 + <?php
105 +
106 + echo '<div class="csf-modal-header'. esc_attr( $hide_header ) .'">';
107 + echo '<select>';
108 + echo ( $has_select ) ? '<option value="">'. esc_attr( $this->args['select_title'] ) .'</option>' : '';
109 +
110 + $tab_key = 1;
111 +
112 + foreach ( $this->pre_tabs as $tab ) {
113 +
114 + if ( ! empty( $tab['subs'] ) ) {
115 +
116 + echo '<optgroup label="'. esc_attr( $tab['title'] ) .'">';
117 +
118 + foreach ( $tab['subs'] as $sub ) {
119 +
120 + $view = ( ! empty( $sub['view'] ) ) ? ' data-view="'. esc_attr( $sub['view'] ) .'"' : '';
121 + $shortcode = ( ! empty( $sub['shortcode'] ) ) ? ' data-shortcode="'. esc_attr( $sub['shortcode'] ) .'"' : '';
122 + $group = ( ! empty( $sub['group_shortcode'] ) ) ? ' data-group="'. esc_attr( $sub['group_shortcode'] ) .'"' : '';
123 +
124 + echo '<option value="'. esc_attr( $tab_key ) .'"'. $view . $shortcode . $group .'>'. esc_attr( $sub['title'] ) .'</option>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
125 +
126 + $tab_key++;
127 +
128 + }
129 +
130 + echo '</optgroup>' ;
131 +
132 + } else {
133 +
134 + $view = ( ! empty( $tab['view'] ) ) ? ' data-view="'. esc_attr( $tab['view'] ) .'"' : '';
135 + $shortcode = ( ! empty( $tab['shortcode'] ) ) ? ' data-shortcode="'. esc_attr( $tab['shortcode'] ) .'"' : '';
136 + $group = ( ! empty( $tab['group_shortcode'] ) ) ? ' data-group="'. esc_attr( $tab['group_shortcode'] ) .'"' : '';
137 +
138 + echo '<option value="'. esc_attr( $tab_key ) .'"'. $view . $shortcode . $group .'>'. esc_attr( $tab['title'] ) .'</option>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
139 +
140 + $tab_key++;
141 +
142 + }
143 +
144 + }
145 +
146 + echo '</select>';
147 + echo '</div>';
148 +
149 + ?>
150 + <div class="csf-modal-content">
151 + <div class="csf-modal-loading"><div class="csf-loading"></div></div>
152 + <div class="csf-modal-load"></div>
153 + </div>
154 + <div class="csf-modal-insert-wrapper hidden"><a href="#" class="button button-primary csf-modal-insert"><?php echo esc_html( $this->args['insert_title'] ); ?></a></div>
155 + </div>
156 + </div>
157 + </div>
158 + </div>
159 + <?php
160 + }
161 +
162 + public function get_shortcode() {
163 +
164 + ob_start();
165 +
166 + $nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
167 + $shortcode_key = ( ! empty( $_POST[ 'shortcode_key' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'shortcode_key' ] ) ) : '';
168 +
169 + if ( ! empty( $shortcode_key ) && wp_verify_nonce( $nonce, 'csf_shortcode_nonce' ) ) {
170 +
171 + $unallows = array( 'group', 'repeater', 'sorter' );
172 + $section = $this->pre_sections[$shortcode_key-1];
173 + $shortcode = ( ! empty( $section['shortcode'] ) ) ? $section['shortcode'] : '';
174 + $view = ( ! empty( $section['view'] ) ) ? $section['view'] : 'normal';
175 +
176 + if ( ! empty( $section ) ) {
177 +
178 + //
179 + // View: normal
180 + if ( ! empty( $section['fields'] ) && $view !== 'repeater' ) {
181 +
182 + echo '<div class="csf-fields">';
183 +
184 + echo ( ! empty( $section['description'] ) ) ? '<div class="csf-field csf-section-description">'. wp_kses_post( $section['description'] ) .'</div>' : '';
185 +
186 + foreach ( $section['fields'] as $field ) {
187 +
188 + if ( in_array( $field['type'], $unallows ) ) { $field['_notice'] = true; }
189 +
190 + // Extra tag improves for spesific fields (border, spacing, dimensions etc...)
191 + $field['tag_prefix'] = ( ! empty( $field['tag_prefix'] ) ) ? $field['tag_prefix'] .'_' : '';
192 +
193 + $field_default = ( isset( $field['id'] ) ) ? $this->get_default( $field ) : '';
194 +
195 + CSF::field( $field, $field_default, $shortcode, 'shortcode' );
196 +
197 + }
198 +
199 + echo '</div>';
200 +
201 + }
202 +
203 + //
204 + // View: group and repeater fields
205 + $repeatable_fields = ( $view === 'repeater' && ! empty( $section['fields'] ) ) ? $section['fields'] : array();
206 + $repeatable_fields = ( $view === 'group' && ! empty( $section['group_fields'] ) ) ? $section['group_fields'] : $repeatable_fields;
207 +
208 + if ( ! empty( $repeatable_fields ) ) {
209 +
210 + $button_title = ( ! empty( $section['button_title'] ) ) ? ' '. $section['button_title'] : esc_html__( 'Add New', 'streamcast' );
211 + $inner_shortcode = ( ! empty( $section['group_shortcode'] ) ) ? $section['group_shortcode'] : $shortcode;
212 +
213 + echo '<div class="csf--repeatable">';
214 +
215 + echo '<div class="csf--repeat-shortcode">';
216 +
217 + echo '<div class="csf-repeat-remove fas fa-times"></div>';
218 +
219 + echo '<div class="csf-fields">';
220 +
221 + foreach ( $repeatable_fields as $field ) {
222 +
223 + if ( in_array( $field['type'], $unallows ) ) { $field['_notice'] = true; }
224 +
225 + // Extra tag improves for spesific fields (border, spacing, dimensions etc...)
226 + $field['tag_prefix'] = ( ! empty( $field['tag_prefix'] ) ) ? $field['tag_prefix'] .'_' : '';
227 +
228 + $field_default = ( isset( $field['id'] ) ) ? $this->get_default( $field ) : '';
229 +
230 + CSF::field( $field, $field_default, $inner_shortcode.'[0]', 'shortcode' );
231 +
232 + }
233 +
234 + echo '</div>';
235 +
236 + echo '</div>';
237 +
238 + echo '</div>';
239 +
240 + echo '<div class="csf--repeat-button-block"><a class="button csf--repeat-button" href="#"><i class="fas fa-plus-circle"></i> '. wp_kses_post( $button_title ) .'</a></div>';
241 +
242 + }
243 +
244 + }
245 +
246 + } else {
247 + echo '<div class="csf-field csf-error-text">'. esc_html__( 'Error: Invalid nonce verification.', 'streamcast' ) .'</div>';
248 + }
249 +
250 + wp_send_json_success( array( 'content' => ob_get_clean() ) );
251 +
252 + }
253 +
254 + // Once editor setup for gutenberg and media buttons
255 + public static function once_editor_setup() {
256 +
257 + if ( function_exists( 'register_block_type' ) ) {
258 + add_action( 'enqueue_block_editor_assets', array( 'CSF_Shortcoder', 'add_guteberg_blocks' ) );
259 + }
260 +
261 + if ( csf_wp_editor_api() ) {
262 + add_action( 'media_buttons', array( 'CSF_Shortcoder', 'add_media_buttons' ) );
263 + }
264 +
265 + }
266 +
267 + // Add gutenberg blocks.
268 + public static function add_guteberg_blocks() {
269 +
270 + $depends = array( 'wp-blocks', 'wp-element', 'wp-components' );
271 +
272 + if ( wp_script_is( 'wp-edit-widgets' ) ) {
273 + $depends[] = 'wp-edit-widgets';
274 + } else {
275 + $depends[] = 'wp-edit-post';
276 + }
277 +
278 + wp_enqueue_script( 'csf-gutenberg-block', CSF::include_plugin_url( 'assets/js/gutenberg.js' ), $depends, CSF::$version, true );
279 +
280 + wp_localize_script( 'csf-gutenberg-block', 'csf_gutenberg_blocks', CSF::$shortcode_instances );
281 +
282 + foreach ( CSF::$shortcode_instances as $block ) {
283 +
284 + register_block_type( $block['name'], array(
285 + 'editor_script' => 'csf-gutenberg-block',
286 + ) );
287 +
288 + }
289 +
290 + }
291 +
292 + // Add media buttons
293 + public static function add_media_buttons( $editor_id ) {
294 +
295 + foreach ( CSF::$shortcode_instances as $value ) {
296 + echo '<a href="#" class="button button-primary csf-shortcode-button" data-editor-id="'. esc_attr( $editor_id ) .'" data-modal-id="'. esc_attr( $value['modal_id'] ) .'">'. esc_html( $value['button_title'] ) .'</a>';
297 + }
298 +
299 + }
300 +
301 + }
302 +}