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