PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / trunk
Strong Testimonials vtrunk
3.3.1 trunk 1.0.1 2.30.9 2.31.10 2.32 2.32.1 2.32.2 2.32.3 2.32.4 2.33 2.34 2.35 2.36 2.37 2.38 2.38.1 2.39 2.39.1 2.39.2 2.39.3 2.40.0 2.40.1 2.40.2 2.40.3 2.40.4 2.40.5 2.40.6 2.40.7 2.41.0 2.41.1 2.50.0 2.50.1 2.50.2 2.50.3 2.50.4 2.51.0 2.51.1 2.51.2 2.51.3 2.51.4 2.51.5 2.51.6 2.51.7 2.51.8 2.51.9 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.17 3.2.18 3.2.19 3.2.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0
strong-testimonials / admin / custom-fields.php
strong-testimonials / admin Last commit date
challenge 1 year ago css 1 month ago img 1 year ago js 1 month ago menu 1 month ago partials 2 days ago rest-api 2 days ago scss 1 year ago settings 1 month ago uninstall 1 year ago wpchill 1 month ago admin-notices.php 5 months ago admin.php 1 month ago class-strong-testimonials-addons.php 1 month ago class-strong-testimonials-admin-category-list.php 1 year ago class-strong-testimonials-admin-list.php 1 year ago class-strong-testimonials-admin-scripts.php 1 month ago class-strong-testimonials-admin.php 1 month ago class-strong-testimonials-debug.php 5 months ago class-strong-testimonials-exporter.php 1 year ago class-strong-testimonials-help.php 1 year ago class-strong-testimonials-helper.php 1 month ago class-strong-testimonials-list-table.php 1 year ago class-strong-testimonials-lite-vs-pro-page.php 1 month ago class-strong-testimonials-post-editor.php 6 months ago class-strong-testimonials-review.php 1 year ago class-strong-testimonials-updater.php 1 month ago class-strong-testimonials-upsell.php 1 month ago class-strong-views-list-table.php 1 month ago class-walker-strong-category-checklist.php 1 year ago class-walker-strong-form-category-checklist.php 1 year ago class-wpmtst-onboarding.php 1 year ago compat.php 1 year ago custom-fields-ajax.php 1 year ago custom-fields.php 2 days ago form-preview.php 1 year ago view-list-order.php 1 year ago views-ajax.php 1 month ago views-validate.php 1 year ago views.php 1 month ago
custom-fields.php
532 lines
1 <?php
2 /**
3 * Strong Testimonials - Custom fields admin functions
4 */
5
6 function wpmtst_form_admin() {
7 do_action( 'wpmtst_form_admin' );
8 }
9
10 function wpmtst_form_admin2() {
11 wpmtst_settings_custom_fields( 1 );
12 }
13
14 add_action( 'wpmtst_form_admin', 'wpmtst_form_admin2' );
15
16 /**
17 * Save changes to custom fields.
18 *
19 * @since 2.28.5 As separate function on custom action.
20 */
21 function wpmtst_update_custom_fields() {
22 $goback = wp_get_referer();
23 $goback = apply_filters( 'wpmtst_form_goback', $goback );
24
25 if ( ! isset( $_POST['wpmtst_form_submitted'] ) ) {
26 wp_redirect( $goback );
27 exit;
28 }
29
30 if ( ! wp_verify_nonce( $_POST['wpmtst_form_submitted'], 'wpmtst_custom_fields_form' ) ) {
31 wp_redirect( $goback );
32 exit;
33 }
34
35 $form_id = absint( $_POST['form_id'] );
36 $forms = get_option( 'wpmtst_custom_forms' );
37 $field_options = apply_filters( 'wpmtst_fields', get_option( 'wpmtst_fields' ) );
38
39 $notice = array(
40 'status' => 'success',
41 'source' => array(
42 'slug' => 'strong-testimonials',
43 'name' => 'Strong Testimonials',
44 ),
45 'timed' => 5000,
46 );
47
48 if ( isset( $_POST['reset'] ) ) {
49
50 // Undo changes
51 $notice['title'] = esc_html__( 'Changes cancelled', 'strong-testimonials' );
52 $notice['message'] = esc_html__( 'The form changes have not been saved.', 'strong-testimonials' );
53 } elseif ( isset( $_POST['restore-defaults'] ) ) {
54
55 // Restore defaults
56 $default_forms = Strong_Testimonials_Defaults::get_base_forms();
57 $fields = $default_forms['default']['fields'];
58 $forms[ $form_id ]['fields'] = $fields;
59 update_option( 'wpmtst_custom_forms', $forms );
60 do_action( 'wpmtst_fields_updated', $fields );
61
62 $notice['title'] = esc_html__( 'Defaults restored', 'strong-testimonials' );
63 $notice['message'] = esc_html__( 'The form fields have been restored to the default state.', 'strong-testimonials' );
64 } else {
65
66 // Save changes
67 $fields = array();
68 $new_key = 0;
69
70 /**
71 * Strip the dang slashes from the dang magic quotes.
72 *
73 * @since 2.0.0
74 */
75 $post_fields = isset( $_POST['fields'] ) ? stripslashes_deep( $_POST['fields'] ) : array();
76
77 foreach ( $post_fields as $key => $field ) {
78
79 /*
80 * Before merging onto base field, catch fields that are "off"
81 * which the form does not submit. Otherwise, the default "on"
82 * would override the requested (but not submitted) "off".
83 */
84 $field['show_label'] = isset( $field['show_label'] ) ? 1 : 0;
85 $field['required'] = isset( $field['required'] ) ? 1 : 0;
86
87 $field = array_merge( $field_options['field_base'], $field );
88
89 $field['name'] = sanitize_text_field( $field['name'] );
90 $field['label'] = sanitize_text_field( $field['label'] );
91 $field['text'] = sanitize_text_field( $field['text'] );
92
93 // TODO Replace this special handling
94 if ( 'checkbox' === $field['input_type'] ) {
95 $field['default_form_value'] = wpmtst_sanitize_checkbox( $field, 'default_form_value' );
96 } else {
97 $field['default_form_value'] = sanitize_text_field( $field['default_form_value'] );
98 }
99 $field['action_input'] = isset( $field['action_input'] ) ? sanitize_text_field( $field['action_input'] ) : '';
100 $field['action_output'] = isset( $field['action_output'] ) ? sanitize_text_field( $field['action_output'] ) : '';
101
102 $field['default_display_value'] = sanitize_text_field( $field['default_display_value'] );
103
104 $field['placeholder'] = sanitize_text_field( $field['placeholder'] );
105
106 $field['before'] = sanitize_text_field( $field['before'] );
107 $field['after'] = sanitize_text_field( $field['after'] );
108
109 $field['shortcode_on_form'] = sanitize_text_field( $field['shortcode_on_form'] );
110 $field['shortcode_on_display'] = sanitize_text_field( $field['shortcode_on_display'] );
111 $field['show_shortcode_options'] = $field['show_shortcode_options'] ? 1 : 0;
112
113 // Hidden options (no need to check if isset)
114 $field['admin_table'] = $field['admin_table'] ? 1 : 0;
115 $field['show_admin_table_option'] = $field['show_admin_table_option'] ? 1 : 0;
116 $field['show_text_option'] = $field['show_text_option'] ? 1 : 0;
117 $field['show_placeholder_option'] = $field['show_placeholder_option'] ? 1 : 0;
118 $field['show_default_options'] = $field['show_default_options'] ? 1 : 0;
119 $field['show_length_option'] = $field['show_length_option'] ? 1 : 0;
120
121 $field = apply_filters( 'wpmtst_sanitize_form_field_options', $field );
122
123 // add to fields array in display order
124 $fields[ $new_key++ ] = $field;
125 }
126
127 $forms[ $form_id ]['fields'] = $fields;
128
129 if ( isset( $_POST['field_group_label'] ) ) {
130 // TODO Catch if empty.
131 $new_label = sanitize_text_field( wp_unslash( $_POST['field_group_label'] ) );
132 $forms[ $form_id ]['label'] = $new_label;
133 }
134
135 update_option( 'wpmtst_custom_forms', $forms );
136 do_action( 'wpmtst_fields_updated', $fields );
137
138 $notice['title'] = esc_html__( 'Fields saved', 'strong-testimonials' );
139 $notice['message'] = esc_html__( 'The changes to the form fields have been successfully saved.', 'strong-testimonials' );
140 }
141
142 WPChill_Notifications::add_notification( 'wpmtst-update-custom-fields-notice', $notice );
143
144 wp_safe_redirect( $goback );
145 exit;
146 }
147
148 add_action( 'admin_post_wpmtst_update_custom_fields', 'wpmtst_update_custom_fields' );
149
150 /**
151 * Custom Fields form
152 *
153 * @param int $form_id
154 */
155 function wpmtst_settings_custom_fields( $form_id = 1 ) {
156 if ( ! current_user_can( 'strong_testimonials_fields' ) ) {
157 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'strong-testimonials' ) );
158 }
159
160 if ( ! $form_id ) {
161 echo '<div class="wrap wpmtst"><p>' . esc_html__( 'No fields selected.', 'strong-testimonials' ) . '</p></div>';
162 return;
163 }
164
165 $forms = get_option( 'wpmtst_custom_forms' );
166 $fields = apply_filters( 'wpmtst_form_fields', $forms[ $form_id ]['fields'] );
167 ?>
168
169 <div class="wrap wpmtst">
170 <?php do_action( 'wpmtst_fields_editor_before_fields_intro' ); ?>
171
172 <div id="left-col">
173 <div>
174 <h3><?php esc_html_e( 'Editor', 'strong-testimonials' ); ?></h3>
175 <p>
176 <?php esc_html_e( 'Click a field to open its options panel.', 'strong-testimonials' ); ?>
177 <a class="open-help-tab" href="#tab-panel-wpmtst-help"><?php esc_html_e( 'Help', 'strong-testimonials' ); ?></a>
178 </p>
179 <?php do_action( 'wpmtst_before_fields_settings', 'form-fields' ); ?>
180 </div>
181
182 <form id="wpmtst-custom-fields-form" method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" autocomplete="off">
183 <?php wp_nonce_field( 'wpmtst_custom_fields_form', 'wpmtst_form_submitted' ); ?>
184 <input type="hidden" name="action" value="wpmtst_update_custom_fields">
185 <input type="hidden" name="form_id" value="<?php echo esc_attr( $form_id ); ?>">
186
187 <?php do_action( 'wpmtst_fields_editor_before_fields_editor', $forms[ $form_id ] ); ?>
188
189 <ul id="custom-field-list">
190 <?php
191 foreach ( $fields as $key => $field ) {
192 echo '<li id="field-' . esc_attr( $key ) . '">' . wpmtst_show_field( $key, $field, false ) . '</li>' . "\n";
193 }
194 ?>
195 </ul>
196
197 <div id="add-field-bar">
198 <input id="add-field" type="button" class="button" name="add-field" value="<?php esc_attr_e( 'Add New Field', 'strong-testimonials' ); ?>">
199 </div>
200
201 <?php do_action( 'wpmtst_admin_after_form_fields' ); ?>
202
203 <div id="field-group-actions">
204 <div><?php submit_button( '', 'primary', 'submit-form', false ); ?></div>
205 <div><?php submit_button( esc_html__( 'Cancel Changes', 'strong-testimonials' ), 'secondary', 'reset', false ); ?></div>
206 <div><?php submit_button( esc_html__( 'Restore Defaults', 'strong-testimonials' ), 'secondary', 'restore-defaults', false ); ?></div>
207 </div>
208 </form>
209 </div><!-- #left-col -->
210
211 <div id="right-col">
212 <div class="intro">
213 <h3><?php esc_html_e( 'Basic Preview', 'strong-testimonials' ); ?></h3>
214 <p><?php esc_html_e( 'Only to demonstrate the fields. May look different in your theme.', 'strong-testimonials' ); ?></p>
215 </div>
216 <?php do_action( 'wpmtst_fields_before_fields_editor_preview' ); ?>
217 <div id="fields-editor-preview">
218 <div><!-- placeholder --></div>
219 </div>
220 </div><!-- #right-col -->
221
222 </div><!-- .wrap -->
223 <?php
224 }
225
226 /**
227 * Add a field to the form
228 *
229 * @param $key
230 * @param $field
231 * @param $adding
232 *
233 * @return string
234 */
235 function wpmtst_show_field( $key, $field, $adding ) {
236 $fields = apply_filters( 'wpmtst_fields', get_option( 'wpmtst_fields' ) );
237 $field_types = $fields['field_types'];
238
239 ob_start();
240
241 include 'partials/fields/field-header.php';
242 ?>
243 <div class="custom-field" style="display: none;">
244
245 <table class="field-table">
246 <?php
247 include 'partials/fields/field-type.php';
248 include 'partials/fields/field-label.php';
249 include 'partials/fields/field-name.php';
250
251 if ( ! $adding ) {
252 echo wpmtst_show_field_secondary( $key, $field );
253 echo wpmtst_show_field_admin_table( $key, $field );
254 }
255
256 ?>
257 </table>
258
259 <?php
260 if ( ! $adding ) {
261 echo wp_kses_post( wpmtst_show_field_hidden( $key, $field ) );
262 }
263 include 'partials/fields/field-controls.php';
264 ?>
265 </div><!-- .custom-field -->
266
267 <?php
268 $html = ob_get_contents();
269 ob_end_clean();
270
271 return $html;
272 }
273
274
275 /**
276 * Create the secondary inputs for a new custom field.
277 * Called after field type is chosen (Post or Custom).
278 *
279 * @param $key
280 * @param $field
281 *
282 * @return string
283 */
284 function wpmtst_show_field_secondary( $key, $field ) {
285 $html = '';
286
287 /*
288 * Required
289 */
290 if ( isset( $field['show_required_option'] ) && $field['show_required_option'] ) {
291 // Disable option if this is a core field like post_content.
292 if ( isset( $field['core'] ) && $field['core'] ) {
293 $disabled = ' disabled="disabled"';
294 } else {
295 $disabled = '';
296 }
297
298 $html .= '<tr class="field-secondary">' . "\n";
299 $html .= '<th>' . esc_html__( 'Required', 'strong-testimonials' ) . '</th>' . "\n";
300 $html .= '<td>' . "\n";
301 if ( $disabled ) {
302 $html .= '<input type="hidden" name="fields[' . esc_attr( $key ) . '][required]" value="' . esc_attr( $field['required'] ) . '">';
303 $html .= '<input type="checkbox" ' . checked( $field['required'], true, false ) . $disabled . '>';
304 } else {
305 $html .= '<input type="checkbox" name="fields[' . esc_attr( $key ) . '][required]" ' . checked( $field['required'], true, false ) . '>';
306 }
307 $html .= '</td>' . "\n";
308 $html .= '</tr>' . "\n";
309 }
310
311 /*
312 * Placeholder
313 */
314 if ( $field['show_placeholder_option'] ?? false ) {
315 if ( isset( $field['placeholder'] ) ) {
316 $html .= '<tr class="field-secondary">' . "\n";
317 $html .= '<th>' . esc_html__( 'Placeholder', 'strong-testimonials' ) . '</th>' . "\n";
318 $html .= '<td><input type="text" name="fields[' . esc_attr( $key ) . '][placeholder]" value="' . esc_attr( $field['placeholder'] ) . '"></td>' . "\n";
319 $html .= '</tr>' . "\n";
320 }
321 }
322
323 /*
324 * Length
325 */
326 if ( $field['show_length_option'] ?? false ) {
327 if ( isset( $field['max_length'] ) ) {
328 $html .= '<tr class="field-secondary">' . "\n";
329 $html .= '<th>' . esc_html__( 'Maximum Length', 'strong-testimonials' ) . '</th>' . "\n";
330 $html .= '<td><input type="number" name="fields[' . esc_attr( $key ) . '][max_length]" value="' . esc_attr( $field['max_length'] ) . '"><span> ' . esc_html__( 'Limit the user imput to a certain number of characters', 'strong-testimonials' ) . '</span></td>' . "\n";
331 $html .= '</tr>' . "\n";
332 }
333 }
334
335 /**
336 * Text (checkbox, radio)
337 *
338 * @since 2.23.0
339 */
340 if ( $field['show_text_option'] ?? false ) {
341 if ( isset( $field['text'] ) ) {
342 $html .= '<tr class="field-secondary">' . "\n";
343 $html .= '<th>' . esc_html__( 'Checked value', 'strong-testimonials' ) . '</th>' . "\n";
344 $html .= '<td><input type="text" name="fields[' . esc_attr( $key ) . '][text]" value="' . esc_attr( $field['text'] ) . '" placeholder="' . esc_html__( 'next to the checkbox', 'strong-testimonials' ) . '"></td>' . "\n";
345 $html .= '</tr>' . "\n";
346 }
347 }
348
349 /*
350 * Before
351 */
352 $html .= '<tr class="field-secondary">' . "\n";
353 $html .= '<th>' . esc_html__( 'Before', 'strong-testimonials' ) . '</th>' . "\n";
354 $html .= '<td><input type="text" name="fields[' . esc_attr( $key ) . '][before]" value="' . esc_attr( $field['before'] ?? '' ) . '"></td>' . "\n";
355 $html .= '</tr>' . "\n";
356
357 /*
358 * After
359 */
360 $html .= '<tr class="field-secondary">' . "\n";
361 $html .= '<th>' . esc_html__( 'After', 'strong-testimonials' ) . '</th>' . "\n";
362 $html .= '<td><input type="text" name="fields[' . esc_attr( $key ) . '][after]" value="' . esc_attr( $field['after'] ?? '' ) . '"></td>' . "\n";
363 $html .= '</tr>' . "\n";
364
365 /*
366 * Default Form Value
367 */
368 if ( $field['show_default_options'] ?? false ) {
369 if ( isset( $field['default_form_value'] ) ) {
370 $html .= '<tr class="field-secondary">' . "\n";
371 $html .= '<th>' . esc_html__( 'Default Form Value', 'strong-testimonials' ) . '</th>' . "\n";
372 $html .= '<td>' . "\n";
373
374 // TODO Replace this special handling
375 if ( 'rating' === $field['input_type'] ) {
376 $html .= '<input type="text" name="fields[' . esc_attr( $key ) . '][default_form_value]" value="' . esc_attr( $field['default_form_value'] ) . '" class="as-number">';
377 $html .= '<span class="help inline">' . esc_html__( 'stars', 'strong-testimonials' ) . '</span>';
378 $html .= '<span class="help">' . esc_html__( 'Populate the field with this value.', 'strong-testimonials' ) . '</span>';
379
380 } elseif ( 'checkbox' === $field['input_type'] ) {
381 $html .= '<label>';
382 $html .= '<input type="checkbox" name="fields[' . esc_attr( $key ) . '][default_form_value]" ' . checked( $field['default_form_value'], true, false ) . '>';
383 $html .= '<span class="help inline">' . esc_html__( 'Checked by default.', 'strong-testimonials' ) . '</span>';
384 $html .= '</label>';
385 } else {
386 $html .= '<input type="text" name="fields[' . esc_attr( $key ) . '][default_form_value]" value="' . esc_attr( $field['default_form_value'] ) . '">';
387 $html .= '<span class="help">' . wp_kses_post( __( 'Populate the field with this custom value or use <code>{user_name}</code>, <code>{user_first_name}</code>, <code>{user_last_name}</code>, <code>{user_email}</code> placeholders.', 'strong-testimonials' ) ) . '</span>';
388 }
389
390 $html .= '</td>' . "\n";
391 $html .= '</tr>' . "\n";
392 }
393 }
394
395 /*
396 * Default Display Value
397 */
398 if ( $field['show_default_options'] ?? false ) {
399 // TODO Replace this special handling for checkbox type
400 if ( 'checkbox' !== $field['input_type'] ) {
401 if ( isset( $field['default_display_value'] ) ) {
402 $html .= '<tr class="field-secondary">' . "\n";
403 $html .= '<th>' . esc_html__( 'Default Display Value', 'strong-testimonials' ) . '</th>' . "\n";
404 $html .= '<td>' . "\n";
405
406 // TODO Replace this special handling
407 if ( 'rating' === $field['input_type'] ) {
408 $html .= '<input type="text" name="fields[' . esc_attr( $key ) . '][default_display_value]" value="' . esc_attr( $field['default_display_value'] ) . '" class="as-number">';
409 $html .= '<span class="help inline">' . esc_html__( 'stars', 'strong-testimonials' ) . '</span>';
410 } else {
411 $html .= '<input type="text" name="fields[' . esc_attr( $key ) . '][default_display_value]" value="' . esc_attr( $field['default_display_value'] ) . '">';
412 }
413
414 $html .= '<span class="help">' . esc_html__( 'Display this on the testimonial if no value is submitted.', 'strong-testimonials' ) . '</span>';
415 $html .= '</td>' . "\n";
416 $html .= '</tr>' . "\n";
417 }
418 }
419 }
420
421 /*
422 * Shortcode Options
423 */
424 if ( $field['show_shortcode_options'] ?? false ) {
425 if ( isset( $field['shortcode_on_form'] ) ) {
426 $html .= '<tr class="field-secondary">' . "\n";
427 $html .= '<th>' . esc_html__( 'Shortcode on form', 'strong-testimonials' ) . '</th>' . "\n";
428 $html .= '<td>' . "\n";
429 $html .= '<input type="text" name="fields[' . esc_attr( $key ) . '][shortcode_on_form]" value="' . esc_attr( $field['shortcode_on_form'] ) . '">';
430 $html .= '</td>' . "\n";
431 $html .= '</tr>' . "\n";
432 }
433 if ( isset( $field['shortcode_on_display'] ) ) {
434 $html .= '<tr class="field-secondary">' . "\n";
435 $html .= '<th>' . esc_html__( 'Shortcode on display', 'strong-testimonials' ) . '</th>' . "\n";
436 $html .= '<td>' . "\n";
437 $html .= '<input type="text" name="fields[' . esc_attr( $key ) . '][shortcode_on_display]" value="' . esc_attr( $field['shortcode_on_display'] ) . '">';
438 $html .= '</td>' . "\n";
439 $html .= '</tr>' . "\n";
440 }
441 }
442
443 $html = apply_filters( 'wpmtst_fields_secondary', $html, $key, $field );
444
445 return $html;
446 }
447
448
449 /**
450 * Add type-specific [Admin Table] setting to form.
451 */
452 function wpmtst_show_field_admin_table( $key, $field ) {
453 // -------------------
454 // Show in Admin Table
455 // -------------------
456 if ( ! ( $field['show_admin_table_option'] ?? false ) ) {
457 $html = '<input type="hidden" name="fields[' . esc_attr( $key ) . '][show_admin_table_option]" value="' . esc_attr( $field['show_admin_table_option'] ?? '' ) . '">';
458 return $html;
459 }
460
461 $html = '<tr class="field-admin-table">' . "\n";
462 $html .= '<th>' . esc_html__( 'Admin List', 'strong-testimonials' ) . '</th>' . "\n";
463 $html .= '<td>' . "\n";
464 if ( $field['admin_table_option'] ) {
465 $html .= '<label><input type="checkbox" class="field-admin-table" name="fields[' . esc_attr( $key ) . '][admin_table]" ' . checked( $field['admin_table'], 1, false ) . '>';
466 } else {
467 $html .= '<input type="checkbox" ' . checked( $field['admin_table'], 1, false ) . ' disabled="disabled"> <em>' . esc_html__( 'required', 'strong-testimonials' ) . '</em>';
468 $html .= '<input type="hidden" name="fields[' . esc_attr( $key ) . '][admin_table]" value="' . esc_attr( $field['admin_table'] ) . '">';
469 }
470 $html .= '<span class="help inline">' . esc_html__( 'Show this field in the admin list table.', 'strong-testimonials' ) . '</span>';
471 $html .= '</label>';
472 $html .= '</td>' . "\n";
473 $html .= '</tr>' . "\n";
474
475 return $html;
476 }
477
478
479 /**
480 * Add type-specific select options field
481 */
482 function wpmtst_show_field_select_options( $key, $field ) {
483
484 if ( 'select' !== $field['input_type'] ) {
485 return;
486 }
487
488 ob_start();
489 include 'partials/fields/field-select-options.php';
490 return ob_get_clean();
491 }
492
493
494 /**
495 * Add hidden fields to form.
496 *
497 * @param $key
498 * @param $field
499 *
500 * @return string
501 */
502 function wpmtst_show_field_hidden( $key, $field ) {
503 $pattern = '<input type="hidden" name="fields[%s][%s]" value="%s">';
504
505 $html = sprintf( $pattern, $key, 'record_type', $field['record_type'] ) . "\n";
506 $html .= sprintf( $pattern, $key, 'input_type', $field['input_type'] ) . "\n";
507 if ( isset( $field['action_input'] ) ) {
508 $html .= sprintf( $pattern, $key, 'action_input', $field['action_input'] ) . "\n";
509 }
510 if ( isset( $field['action_output'] ) ) {
511 $html .= sprintf( $pattern, $key, 'action_output', $field['action_output'] ) . "\n";
512 }
513 $html .= sprintf( $pattern, $key, 'name_mutable', $field['name_mutable'] ) . "\n";
514 $html .= sprintf( $pattern, $key, 'show_text_option', $field['show_text_option'] ) . "\n";
515 $html .= sprintf( $pattern, $key, 'show_placeholder_option', $field['show_placeholder_option'] ) . "\n";
516 $html .= sprintf( $pattern, $key, 'show_default_options', $field['show_default_options'] ) . "\n";
517 $html .= sprintf( $pattern, $key, 'admin_table_option', $field['admin_table_option'] ) . "\n";
518 $html .= sprintf( $pattern, $key, 'show_admin_table_option', $field['show_admin_table_option'] ) . "\n";
519 $html .= sprintf( $pattern, $key, 'show_shortcode_options', $field['show_shortcode_options'] ) . "\n";
520 $html .= sprintf( $pattern, $key, 'show_length_option', $field['show_length_option'] ) . "\n";
521
522 if ( isset( $field['map'] ) ) {
523 $html .= sprintf( $pattern, $key, 'map', $field['map'] ) . "\n";
524 }
525
526 if ( isset( $field['core'] ) ) {
527 $html .= sprintf( $pattern, $key, 'core', $field['core'] ) . "\n";
528 }
529
530 return $html;
531 }
532