about
7 years ago
css
7 years ago
img
7 years ago
js
7 years ago
menu
7 years ago
partials
7 years ago
scss
7 years ago
settings
7 years ago
admin-notices.php
7 years ago
admin.php
7 years ago
class-strong-testimonials-addons.php
7 years ago
class-strong-testimonials-admin-category-list.php
7 years ago
class-strong-testimonials-admin-list.php
7 years ago
class-strong-testimonials-admin-scripts.php
7 years ago
class-strong-testimonials-defaults.php
7 years ago
class-strong-testimonials-exporter.php
7 years ago
class-strong-testimonials-help.php
7 years ago
class-strong-testimonials-list-table.php
7 years ago
class-strong-testimonials-page-shortcodes.php
7 years ago
class-strong-testimonials-post-editor.php
7 years ago
class-strong-testimonials-updater.php
7 years ago
class-strong-testimonials-upsell.php
7 years ago
class-strong-views-list-table.php
7 years ago
class-walker-strong-category-checklist.php
7 years ago
class-walker-strong-form-category-checklist.php
7 years ago
compat.php
7 years ago
custom-fields-ajax.php
7 years ago
custom-fields.php
7 years ago
form-preview.php
7 years ago
view-list-order.php
7 years ago
views-ajax.php
7 years ago
views-validate.php
7 years ago
views.php
7 years ago
form-preview.php
52 lines
| 1 | <?php |
| 2 | |
| 3 | function wpmtst_get_form_preview() { |
| 4 | if ( ! isset( $_POST['fields'] ) ) exit; |
| 5 | |
| 6 | // parse_str decodes too; no need to use urldecode |
| 7 | parse_str( stripslashes_deep( $_POST['fields'] ), $preview ); |
| 8 | |
| 9 | $new_fields = array(); |
| 10 | $fields = apply_filters( 'wpmtst_fields', get_option( 'wpmtst_fields' ) ); |
| 11 | |
| 12 | foreach ( $preview['fields'] as $key => $field ) { |
| 13 | /* |
| 14 | * Before merging onto base field, catch fields that are "off" |
| 15 | * which the form does not submit. Otherwise, the default "on" |
| 16 | * would override the requested (but not submitted) "off". |
| 17 | */ |
| 18 | $field['show_label'] = isset( $field['show_label'] ) ? 1 : 0; |
| 19 | $field['required'] = isset( $field['required'] ) ? 1 : 0; |
| 20 | |
| 21 | $field = array_merge( $fields['field_base'], $field ); |
| 22 | |
| 23 | if ( 'none' == $field['input_type'] ) { |
| 24 | $field['input_type'] = 'text'; |
| 25 | } |
| 26 | |
| 27 | $field['name'] = sanitize_text_field( $field['name'] ); |
| 28 | $field['label'] = sanitize_text_field( $field['label'] ); |
| 29 | // TODO Replace this special handling |
| 30 | if ( 'checkbox' == $field['input_type'] ) { |
| 31 | $field['default_form_value'] = wpmtst_sanitize_checkbox( $field, 'default_form_value' ); |
| 32 | } else { |
| 33 | $field['default_form_value'] = sanitize_text_field( $field['default_form_value'] ); |
| 34 | } |
| 35 | $field['placeholder'] = sanitize_text_field( $field['placeholder'] ); |
| 36 | $field['before'] = sanitize_text_field( $field['before'] ); |
| 37 | $field['after'] = sanitize_text_field( $field['after'] ); |
| 38 | |
| 39 | // add to fields array in display order |
| 40 | $new_fields[] = $field; |
| 41 | } |
| 42 | |
| 43 | ob_start(); |
| 44 | include WPMTST_ADMIN . 'partials/templates/form-preview-template.php'; |
| 45 | $html = ob_get_contents(); |
| 46 | ob_end_clean(); |
| 47 | echo $html; |
| 48 | |
| 49 | exit; |
| 50 | } |
| 51 | add_action( 'wp_ajax_wpmtst_get_form_preview', 'wpmtst_get_form_preview' ); |
| 52 |