PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / 3.3.2
Strong Testimonials v3.3.2
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 day ago img 1 year ago js 1 month ago menu 1 month ago partials 1 week ago rest-api 1 day ago scss 1 year ago settings 1 day 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 day 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 1 day 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
550 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 ob_start();
169 do_action( 'wpmtst_fields_editor_upsell_col' );
170 $upsell_col = trim( ob_get_clean() );
171 ?>
172
173 <div class="wrap wpmtst">
174 <?php do_action( 'wpmtst_fields_editor_before_fields_intro' ); ?>
175
176 <div id="fields-columns">
177
178 <div id="fields-main">
179
180 <div id="left-col">
181 <div>
182 <h3><?php esc_html_e( 'Editor', 'strong-testimonials' ); ?></h3>
183 <p>
184 <?php esc_html_e( 'Click a field to open its options panel.', 'strong-testimonials' ); ?>
185 <a class="open-help-tab" href="#tab-panel-wpmtst-help"><?php esc_html_e( 'Help', 'strong-testimonials' ); ?></a>
186 </p>
187 <?php do_action( 'wpmtst_before_fields_settings', 'form-fields' ); ?>
188 </div>
189
190 <form id="wpmtst-custom-fields-form" method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" autocomplete="off">
191 <?php wp_nonce_field( 'wpmtst_custom_fields_form', 'wpmtst_form_submitted' ); ?>
192 <input type="hidden" name="action" value="wpmtst_update_custom_fields">
193 <input type="hidden" name="form_id" value="<?php echo esc_attr( $form_id ); ?>">
194
195 <?php do_action( 'wpmtst_fields_editor_before_fields_editor', $forms[ $form_id ] ); ?>
196
197 <ul id="custom-field-list">
198 <?php
199 foreach ( $fields as $key => $field ) {
200 echo '<li id="field-' . esc_attr( $key ) . '">' . wpmtst_show_field( $key, $field, false ) . '</li>' . "\n";
201 }
202 ?>
203 </ul>
204
205 <div id="add-field-bar">
206 <input id="add-field" type="button" class="button" name="add-field" value="<?php esc_attr_e( 'Add New Field', 'strong-testimonials' ); ?>">
207 </div>
208
209 <?php do_action( 'wpmtst_admin_after_form_fields' ); ?>
210
211 <div id="field-group-actions">
212 <div><?php submit_button( '', 'primary', 'submit-form', false ); ?></div>
213 <div><?php submit_button( esc_html__( 'Cancel Changes', 'strong-testimonials' ), 'secondary', 'reset', false ); ?></div>
214 <div><?php submit_button( esc_html__( 'Restore Defaults', 'strong-testimonials' ), 'secondary', 'restore-defaults', false ); ?></div>
215 </div>
216 </form>
217 </div><!-- #left-col -->
218
219 <div id="right-col">
220 <div class="intro">
221 <h3><?php esc_html_e( 'Basic Preview', 'strong-testimonials' ); ?></h3>
222 <p><?php esc_html_e( 'Only to demonstrate the fields. May look different in your theme.', 'strong-testimonials' ); ?></p>
223 </div>
224 <?php do_action( 'wpmtst_fields_before_fields_editor_preview' ); ?>
225 <div id="fields-editor-preview">
226 <div><!-- placeholder --></div>
227 </div>
228 </div><!-- #right-col -->
229
230 </div><!-- #fields-main -->
231
232 <?php if ( $upsell_col ) : ?>
233 <div id="upsell-col">
234 <?php echo $upsell_col; ?>
235 </div><!-- #upsell-col -->
236 <?php endif; ?>
237
238 </div><!-- #fields-columns -->
239
240 </div><!-- .wrap -->
241 <?php
242 }
243
244 /**
245 * Add a field to the form
246 *
247 * @param $key
248 * @param $field
249 * @param $adding
250 *
251 * @return string
252 */
253 function wpmtst_show_field( $key, $field, $adding ) {
254 $fields = apply_filters( 'wpmtst_fields', get_option( 'wpmtst_fields' ) );
255 $field_types = $fields['field_types'];
256
257 ob_start();
258
259 include 'partials/fields/field-header.php';
260 ?>
261 <div class="custom-field" style="display: none;">
262
263 <table class="field-table">
264 <?php
265 include 'partials/fields/field-type.php';
266 include 'partials/fields/field-label.php';
267 include 'partials/fields/field-name.php';
268
269 if ( ! $adding ) {
270 echo wpmtst_show_field_secondary( $key, $field );
271 echo wpmtst_show_field_admin_table( $key, $field );
272 }
273
274 ?>
275 </table>
276
277 <?php
278 if ( ! $adding ) {
279 echo wp_kses_post( wpmtst_show_field_hidden( $key, $field ) );
280 }
281 include 'partials/fields/field-controls.php';
282 ?>
283 </div><!-- .custom-field -->
284
285 <?php
286 $html = ob_get_contents();
287 ob_end_clean();
288
289 return $html;
290 }
291
292
293 /**
294 * Create the secondary inputs for a new custom field.
295 * Called after field type is chosen (Post or Custom).
296 *
297 * @param $key
298 * @param $field
299 *
300 * @return string
301 */
302 function wpmtst_show_field_secondary( $key, $field ) {
303 $html = '';
304
305 /*
306 * Required
307 */
308 if ( isset( $field['show_required_option'] ) && $field['show_required_option'] ) {
309 // Disable option if this is a core field like post_content.
310 if ( isset( $field['core'] ) && $field['core'] ) {
311 $disabled = ' disabled="disabled"';
312 } else {
313 $disabled = '';
314 }
315
316 $html .= '<tr class="field-secondary">' . "\n";
317 $html .= '<th>' . esc_html__( 'Required', 'strong-testimonials' ) . '</th>' . "\n";
318 $html .= '<td>' . "\n";
319 if ( $disabled ) {
320 $html .= '<input type="hidden" name="fields[' . esc_attr( $key ) . '][required]" value="' . esc_attr( $field['required'] ) . '">';
321 $html .= '<input type="checkbox" ' . checked( $field['required'], true, false ) . $disabled . '>';
322 } else {
323 $html .= '<input type="checkbox" name="fields[' . esc_attr( $key ) . '][required]" ' . checked( $field['required'], true, false ) . '>';
324 }
325 $html .= '</td>' . "\n";
326 $html .= '</tr>' . "\n";
327 }
328
329 /*
330 * Placeholder
331 */
332 if ( $field['show_placeholder_option'] ?? false ) {
333 if ( isset( $field['placeholder'] ) ) {
334 $html .= '<tr class="field-secondary">' . "\n";
335 $html .= '<th>' . esc_html__( 'Placeholder', 'strong-testimonials' ) . '</th>' . "\n";
336 $html .= '<td><input type="text" name="fields[' . esc_attr( $key ) . '][placeholder]" value="' . esc_attr( $field['placeholder'] ) . '"></td>' . "\n";
337 $html .= '</tr>' . "\n";
338 }
339 }
340
341 /*
342 * Length
343 */
344 if ( $field['show_length_option'] ?? false ) {
345 if ( isset( $field['max_length'] ) ) {
346 $html .= '<tr class="field-secondary">' . "\n";
347 $html .= '<th>' . esc_html__( 'Maximum Length', 'strong-testimonials' ) . '</th>' . "\n";
348 $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";
349 $html .= '</tr>' . "\n";
350 }
351 }
352
353 /**
354 * Text (checkbox, radio)
355 *
356 * @since 2.23.0
357 */
358 if ( $field['show_text_option'] ?? false ) {
359 if ( isset( $field['text'] ) ) {
360 $html .= '<tr class="field-secondary">' . "\n";
361 $html .= '<th>' . esc_html__( 'Checked value', 'strong-testimonials' ) . '</th>' . "\n";
362 $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";
363 $html .= '</tr>' . "\n";
364 }
365 }
366
367 /*
368 * Before
369 */
370 $html .= '<tr class="field-secondary">' . "\n";
371 $html .= '<th>' . esc_html__( 'Before', 'strong-testimonials' ) . '</th>' . "\n";
372 $html .= '<td><input type="text" name="fields[' . esc_attr( $key ) . '][before]" value="' . esc_attr( $field['before'] ?? '' ) . '"></td>' . "\n";
373 $html .= '</tr>' . "\n";
374
375 /*
376 * After
377 */
378 $html .= '<tr class="field-secondary">' . "\n";
379 $html .= '<th>' . esc_html__( 'After', 'strong-testimonials' ) . '</th>' . "\n";
380 $html .= '<td><input type="text" name="fields[' . esc_attr( $key ) . '][after]" value="' . esc_attr( $field['after'] ?? '' ) . '"></td>' . "\n";
381 $html .= '</tr>' . "\n";
382
383 /*
384 * Default Form Value
385 */
386 if ( $field['show_default_options'] ?? false ) {
387 if ( isset( $field['default_form_value'] ) ) {
388 $html .= '<tr class="field-secondary">' . "\n";
389 $html .= '<th>' . esc_html__( 'Default Form Value', 'strong-testimonials' ) . '</th>' . "\n";
390 $html .= '<td>' . "\n";
391
392 // TODO Replace this special handling
393 if ( 'rating' === $field['input_type'] ) {
394 $html .= '<input type="text" name="fields[' . esc_attr( $key ) . '][default_form_value]" value="' . esc_attr( $field['default_form_value'] ) . '" class="as-number">';
395 $html .= '<span class="help inline">' . esc_html__( 'stars', 'strong-testimonials' ) . '</span>';
396 $html .= '<span class="help">' . esc_html__( 'Populate the field with this value.', 'strong-testimonials' ) . '</span>';
397
398 } elseif ( 'checkbox' === $field['input_type'] ) {
399 $html .= '<label>';
400 $html .= '<input type="checkbox" name="fields[' . esc_attr( $key ) . '][default_form_value]" ' . checked( $field['default_form_value'], true, false ) . '>';
401 $html .= '<span class="help inline">' . esc_html__( 'Checked by default.', 'strong-testimonials' ) . '</span>';
402 $html .= '</label>';
403 } else {
404 $html .= '<input type="text" name="fields[' . esc_attr( $key ) . '][default_form_value]" value="' . esc_attr( $field['default_form_value'] ) . '">';
405 $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>';
406 }
407
408 $html .= '</td>' . "\n";
409 $html .= '</tr>' . "\n";
410 }
411 }
412
413 /*
414 * Default Display Value
415 */
416 if ( $field['show_default_options'] ?? false ) {
417 // TODO Replace this special handling for checkbox type
418 if ( 'checkbox' !== $field['input_type'] ) {
419 if ( isset( $field['default_display_value'] ) ) {
420 $html .= '<tr class="field-secondary">' . "\n";
421 $html .= '<th>' . esc_html__( 'Default Display Value', 'strong-testimonials' ) . '</th>' . "\n";
422 $html .= '<td>' . "\n";
423
424 // TODO Replace this special handling
425 if ( 'rating' === $field['input_type'] ) {
426 $html .= '<input type="text" name="fields[' . esc_attr( $key ) . '][default_display_value]" value="' . esc_attr( $field['default_display_value'] ) . '" class="as-number">';
427 $html .= '<span class="help inline">' . esc_html__( 'stars', 'strong-testimonials' ) . '</span>';
428 } else {
429 $html .= '<input type="text" name="fields[' . esc_attr( $key ) . '][default_display_value]" value="' . esc_attr( $field['default_display_value'] ) . '">';
430 }
431
432 $html .= '<span class="help">' . esc_html__( 'Display this on the testimonial if no value is submitted.', 'strong-testimonials' ) . '</span>';
433 $html .= '</td>' . "\n";
434 $html .= '</tr>' . "\n";
435 }
436 }
437 }
438
439 /*
440 * Shortcode Options
441 */
442 if ( $field['show_shortcode_options'] ?? false ) {
443 if ( isset( $field['shortcode_on_form'] ) ) {
444 $html .= '<tr class="field-secondary">' . "\n";
445 $html .= '<th>' . esc_html__( 'Shortcode on form', 'strong-testimonials' ) . '</th>' . "\n";
446 $html .= '<td>' . "\n";
447 $html .= '<input type="text" name="fields[' . esc_attr( $key ) . '][shortcode_on_form]" value="' . esc_attr( $field['shortcode_on_form'] ) . '">';
448 $html .= '</td>' . "\n";
449 $html .= '</tr>' . "\n";
450 }
451 if ( isset( $field['shortcode_on_display'] ) ) {
452 $html .= '<tr class="field-secondary">' . "\n";
453 $html .= '<th>' . esc_html__( 'Shortcode on display', 'strong-testimonials' ) . '</th>' . "\n";
454 $html .= '<td>' . "\n";
455 $html .= '<input type="text" name="fields[' . esc_attr( $key ) . '][shortcode_on_display]" value="' . esc_attr( $field['shortcode_on_display'] ) . '">';
456 $html .= '</td>' . "\n";
457 $html .= '</tr>' . "\n";
458 }
459 }
460
461 $html = apply_filters( 'wpmtst_fields_secondary', $html, $key, $field );
462
463 return $html;
464 }
465
466
467 /**
468 * Add type-specific [Admin Table] setting to form.
469 */
470 function wpmtst_show_field_admin_table( $key, $field ) {
471 // -------------------
472 // Show in Admin Table
473 // -------------------
474 if ( ! ( $field['show_admin_table_option'] ?? false ) ) {
475 $html = '<input type="hidden" name="fields[' . esc_attr( $key ) . '][show_admin_table_option]" value="' . esc_attr( $field['show_admin_table_option'] ?? '' ) . '">';
476 return $html;
477 }
478
479 $html = '<tr class="field-admin-table">' . "\n";
480 $html .= '<th>' . esc_html__( 'Admin List', 'strong-testimonials' ) . '</th>' . "\n";
481 $html .= '<td>' . "\n";
482 if ( $field['admin_table_option'] ) {
483 $html .= '<label><input type="checkbox" class="field-admin-table" name="fields[' . esc_attr( $key ) . '][admin_table]" ' . checked( $field['admin_table'], 1, false ) . '>';
484 } else {
485 $html .= '<input type="checkbox" ' . checked( $field['admin_table'], 1, false ) . ' disabled="disabled"> <em>' . esc_html__( 'required', 'strong-testimonials' ) . '</em>';
486 $html .= '<input type="hidden" name="fields[' . esc_attr( $key ) . '][admin_table]" value="' . esc_attr( $field['admin_table'] ) . '">';
487 }
488 $html .= '<span class="help inline">' . esc_html__( 'Show this field in the admin list table.', 'strong-testimonials' ) . '</span>';
489 $html .= '</label>';
490 $html .= '</td>' . "\n";
491 $html .= '</tr>' . "\n";
492
493 return $html;
494 }
495
496
497 /**
498 * Add type-specific select options field
499 */
500 function wpmtst_show_field_select_options( $key, $field ) {
501
502 if ( 'select' !== $field['input_type'] ) {
503 return;
504 }
505
506 ob_start();
507 include 'partials/fields/field-select-options.php';
508 return ob_get_clean();
509 }
510
511
512 /**
513 * Add hidden fields to form.
514 *
515 * @param $key
516 * @param $field
517 *
518 * @return string
519 */
520 function wpmtst_show_field_hidden( $key, $field ) {
521 $pattern = '<input type="hidden" name="fields[%s][%s]" value="%s">';
522
523 $html = sprintf( $pattern, $key, 'record_type', $field['record_type'] ) . "\n";
524 $html .= sprintf( $pattern, $key, 'input_type', $field['input_type'] ) . "\n";
525 if ( isset( $field['action_input'] ) ) {
526 $html .= sprintf( $pattern, $key, 'action_input', $field['action_input'] ) . "\n";
527 }
528 if ( isset( $field['action_output'] ) ) {
529 $html .= sprintf( $pattern, $key, 'action_output', $field['action_output'] ) . "\n";
530 }
531 $html .= sprintf( $pattern, $key, 'name_mutable', $field['name_mutable'] ) . "\n";
532 $html .= sprintf( $pattern, $key, 'show_text_option', $field['show_text_option'] ) . "\n";
533 $html .= sprintf( $pattern, $key, 'show_placeholder_option', $field['show_placeholder_option'] ) . "\n";
534 $html .= sprintf( $pattern, $key, 'show_default_options', $field['show_default_options'] ) . "\n";
535 $html .= sprintf( $pattern, $key, 'admin_table_option', $field['admin_table_option'] ) . "\n";
536 $html .= sprintf( $pattern, $key, 'show_admin_table_option', $field['show_admin_table_option'] ) . "\n";
537 $html .= sprintf( $pattern, $key, 'show_shortcode_options', $field['show_shortcode_options'] ) . "\n";
538 $html .= sprintf( $pattern, $key, 'show_length_option', $field['show_length_option'] ) . "\n";
539
540 if ( isset( $field['map'] ) ) {
541 $html .= sprintf( $pattern, $key, 'map', $field['map'] ) . "\n";
542 }
543
544 if ( isset( $field['core'] ) ) {
545 $html .= sprintf( $pattern, $key, 'core', $field['core'] ) . "\n";
546 }
547
548 return $html;
549 }
550