← All changes
|
classes/controllers/FrmEntriesAJAXSubmitController.php
+3
-8
6.27
→
6.19
View file →
| @@ -40,9 +40,8 @@ | ||
| 40 | 40 | 'pass' => false, |
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 44 | - | |
| 45 | 44 | if ( ! $form_id ) { |
| 46 | 45 | echo json_encode( $response ); |
| 47 | 46 | wp_die(); |
| 48 | 47 | } |
| @@ -47,9 +46,8 @@ | ||
| 47 | 46 | wp_die(); |
| 48 | 47 | } |
| 49 | 48 | |
| 50 | 49 | $form = FrmForm::getOne( $form_id ); |
| 51 | - | |
| 52 | 50 | if ( ! $form ) { |
| 53 | 51 | echo json_encode( $response ); |
| 54 | 52 | wp_die(); |
| 55 | 53 | } |
| @@ -54,9 +52,8 @@ | ||
| 54 | 52 | wp_die(); |
| 55 | 53 | } |
| 56 | 54 | |
| 57 | 55 | $is_ajax_on = FrmForm::is_ajax_on( $form ); |
| 58 | - | |
| 59 | 56 | if ( ! $is_ajax_on ) { |
| 60 | 57 | // This continues in the Pro version as it is required for other features including in-place edit. |
| 61 | 58 | // In Lite, if AJAX submit is not on, just exit early as this function is getting called incorrectly. |
| 62 | 59 | echo json_encode( $response ); |
| @@ -79,9 +76,10 @@ | ||
| 79 | 76 | // Trigger the footer scripts if there is a form to show. |
| 80 | 77 | if ( ! empty( $frm_vars['forms_loaded'] ) ) { |
| 81 | 78 | ob_start(); |
| 82 | 79 | self::print_ajax_scripts(); |
| 83 | - $response['content'] .= ob_get_clean(); | |
| 80 | + $response['content'] .= ob_get_contents(); | |
| 81 | + ob_end_clean(); | |
| 84 | 82 | |
| 85 | 83 | // Mark the end of added footer content. |
| 86 | 84 | $response['content'] .= '<span class="frm_end_ajax_' . $form->id . '"></span>'; |
| 87 | 85 | } |
| @@ -86,9 +84,8 @@ | ||
| 86 | 84 | $response['content'] .= '<span class="frm_end_ajax_' . $form->id . '"></span>'; |
| 87 | 85 | } |
| 88 | 86 | } else { |
| 89 | 87 | $obj = array(); |
| 90 | - | |
| 91 | 88 | foreach ( $errors as $field => $error ) { |
| 92 | 89 | $field_id = str_replace( 'field', '', $field ); |
| 93 | 90 | $error = self::maybe_modify_ajax_error( $error, $field_id, $form, $errors ); |
| 94 | 91 | $obj[ $field_id ] = $error; |
| @@ -162,9 +159,8 @@ | ||
| 162 | 159 | * @param string $error |
| 163 | 160 | * @param string $field_id |
| 164 | 161 | * @param stdClass $form the form being submitted (not necessarily the field's form when embedded/repeated). |
| 165 | 162 | * @param array $errors all errors that were caught in this form submission, passed into the frm_before_replace_shortcodes filter for reference. |
| 166 | - * | |
| 167 | 163 | * @return string |
| 168 | 164 | */ |
| 169 | 165 | private static function maybe_modify_ajax_error( $error, $field_id, $form, $errors ) { |
| 170 | 166 | if ( ! is_numeric( $field_id ) ) { |
| @@ -195,15 +191,14 @@ | ||
| 195 | 191 | * @since 6.2 |
| 196 | 192 | * |
| 197 | 193 | * @param array $response |
| 198 | 194 | * @param int|string $form_id |
| 199 | - * | |
| 200 | 195 | * @return array |
| 201 | 196 | */ |
| 202 | 197 | private static function check_for_failed_form_submission( $response, $form_id ) { |
| 203 | 198 | $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form_id ) ); |
| 204 | 199 | |
| 205 | - if ( str_contains( $response['content'], $frm_settings->failed_msg ) ) { | |
| 200 | + if ( false !== strpos( $response['content'], $frm_settings->failed_msg ) ) { | |
| 206 | 201 | $response['errors']['failed'] = $frm_settings->failed_msg; |
| 207 | 202 | $response['content'] = ''; |
| 208 | 203 | } |
| 209 | 204 | |