| @@ -46,11 +46,11 @@ | ||
| 46 | 46 | * |
| 47 | 47 | * @param array $post_data $_POST |
| 48 | 48 | * |
| 49 | 49 | */ |
| 50 | -function wppb_create_recover_password_form( $user, $post_data ){ | |
| 50 | +function wppb_create_recover_password_form( $user, $post_data, $is_ajax_form = false ){ | |
| 51 | 51 | ?> |
| 52 | - <form enctype="multipart/form-data" method="post" id="wppb-recover-password" class="wppb-user-forms" action="<?php echo esc_url( wppb_curpageurl() ); ?>"> | |
| 52 | + <form enctype="multipart/form-data" method="post" novalidate id="wppb-recover-password" class="wppb-user-forms<?php echo ($is_ajax_form ? ' wppb-ajax-form' : ''); ?>" action="<?php echo esc_url( wppb_curpageurl() ); ?>"> | |
| 53 | 53 | <ul> |
| 54 | 54 | <?php |
| 55 | 55 | |
| 56 | 56 | if( !empty( $post_data['passw1'] ) ) |
| @@ -68,10 +68,12 @@ | ||
| 68 | 68 | |
| 69 | 69 | $recover_inputPassword = ' |
| 70 | 70 | <li class="wppb-form-field passw1'. apply_filters( 'wppb_recover_field_extra_css_class', '', 'passw1') .'"> |
| 71 | 71 | <label for="passw1">'. esc_html( $password_label ) .'</label> |
| 72 | - <input class="password" name="passw1" type="password" id="passw1" value="" autocomplete="off" title="'. esc_attr( wppb_password_length_text() ).'" '. apply_filters( 'wppb_recover_password_extra_attr', '', esc_html( $password_label ), 'password' ) .' /> | |
| 73 | - '. wppb_password_visibility_toggle_html() .' | |
| 72 | + <span class="wppb-password-field-container"> | |
| 73 | + <input class="password" name="passw1" type="password" id="passw1" value="" autocomplete="off" title="'. esc_attr( wppb_password_length_text() ).'" '. apply_filters( 'wppb_recover_password_extra_attr', '', esc_html( $password_label ), 'password' ) .' /> | |
| 74 | + '. wppb_password_visibility_toggle_html() .' | |
| 75 | + </span> | |
| 74 | 76 | <span class="wppb-description-delimiter">'. wppb_password_length_text() .' '. wppb_password_strength_description() .'</span>'. |
| 75 | 77 | /* if we have active the password strength checker */ |
| 76 | 78 | wppb_password_strength_checker_html().' |
| 77 | 79 | </li><!-- .passw1 --> |
| @@ -77,10 +79,12 @@ | ||
| 77 | 79 | </li><!-- .passw1 --> |
| 78 | 80 | <input type="hidden" name="userData" value="'. esc_attr( $user->ID ).'"/> |
| 79 | 81 | <li class="wppb-form-field passw2'. apply_filters( 'wppb_recover_field_extra_css_class', '', 'passw2') .'"> |
| 80 | 82 | <label for="passw2">'. esc_html( $repeat_password_label ) .'</label> |
| 81 | - <input class="password" name="passw2" type="password" id="passw2" value="" autocomplete="off" '. apply_filters( 'wppb_recover_password_extra_attr', '', esc_html( $repeat_password_label ), 'repeat_password' ) .' /> | |
| 82 | - '. wppb_password_visibility_toggle_html() .' | |
| 83 | + <span class="wppb-password-field-container"> | |
| 84 | + <input class="password" name="passw2" type="password" id="passw2" value="" autocomplete="off" '. apply_filters( 'wppb_recover_password_extra_attr', '', esc_html( $repeat_password_label ), 'repeat_password' ) .' /> | |
| 85 | + '. wppb_password_visibility_toggle_html() .' | |
| 86 | + </span> | |
| 83 | 87 | </li><!-- .passw2 -->'; |
| 84 | 88 | |
| 85 | 89 | echo apply_filters( 'wppb_recover_password_form_input', $recover_inputPassword, $passw_one, $passw_two, $user->ID ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 86 | 90 | ?> |
| @@ -103,11 +107,11 @@ | ||
| 103 | 107 | * @param WP_User $user the user object |
| 104 | 108 | * @param array $post_data $_POST |
| 105 | 109 | * |
| 106 | 110 | */ |
| 107 | - function wppb_create_generate_password_form( $post_data ){ | |
| 111 | + function wppb_create_generate_password_form( $post_data, $is_ajax_form = false ){ | |
| 108 | 112 | ?> |
| 109 | - <form enctype="multipart/form-data" method="post" id="wppb-recover-password" class="wppb-user-forms" action="<?php echo esc_url( wppb_curpageurl() ); ?>"> | |
| 113 | + <form enctype="multipart/form-data" method="post" novalidate id="wppb-recover-password" class="wppb-user-forms<?php echo ($is_ajax_form ? ' wppb-ajax-form' : ''); ?>" action="<?php echo esc_url( wppb_curpageurl() ); ?>"> | |
| 110 | 114 | <?php |
| 111 | 115 | $wppb_generalSettings = get_option( 'wppb_general_settings' ); |
| 112 | 116 | |
| 113 | 117 | if( !empty( $wppb_generalSettings['loginWith'] ) && $wppb_generalSettings['loginWith'] == 'email' ){ |
| @@ -126,14 +130,14 @@ | ||
| 126 | 130 | |
| 127 | 131 | $recover_input = '<ul> |
| 128 | 132 | <li class="wppb-form-field wppb-username-email'. apply_filters( 'wppb_recover_field_extra_css_class', '', 'username_email') .'"> |
| 129 | 133 | <label for="username_email">'. esc_html( $username_email_label ) .'</label> |
| 130 | - <input class="text-input" name="username_email" type="text" id="username_email" value="'.esc_attr( trim( $username_email ) ).'" '. apply_filters( 'wppb_recover_password_extra_attr', '', esc_html( $username_email_label ), 'username_email' ) .' /> | |
| 134 | + <input class="text-input" name="username_email" type="text" id="username_email" value="'.esc_attr( trim( $username_email ) ).'" required '. apply_filters( 'wppb_recover_password_extra_attr', '', esc_html( $username_email_label ), 'username_email' ) .' /> | |
| 131 | 135 | </li><!-- .username_email --></ul>'; |
| 132 | 136 | echo apply_filters( 'wppb_recover_password_generate_password_input', $recover_input, trim( $username_email ) ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 133 | 137 | ?> |
| 134 | 138 | <p class="form-submit"> |
| 135 | - <?php $button_name = __('Get New Password', 'profile-builder'); ?> | |
| 139 | + <?php $button_name = __('Get Reset Link', 'profile-builder'); ?> | |
| 136 | 140 | <input name="recover_password" type="submit" id="wppb-recover-password-button" class="<?php echo esc_attr( apply_filters( 'wppb_recover_submit_class', "submit button" ) );?>" value="<?php echo esc_attr( apply_filters('wppb_recover_password_button_name3', $button_name) ); ?>" /> |
| 137 | 141 | <input name="action" type="hidden" id="action" value="recover_password" /> |
| 138 | 142 | </p> |
| 139 | 143 | <?php wp_nonce_field( 'verify_true_password_recovery', 'password_recovery_nonce_field' ); ?> |
| @@ -164,9 +168,9 @@ | ||
| 164 | 168 | * @return bool|string|void |
| 165 | 169 | */ |
| 166 | 170 | function wppb_send_recovery_email( $user, $success ){ |
| 167 | 171 | |
| 168 | - if ( $success == 'wppb_recaptcha_error') | |
| 172 | + if ( $success == 'wppb_recaptcha_error' || $success == 'wppb_turnstile_error' || $success == 'wppb_captcha_error' ) | |
| 169 | 173 | return false; |
| 170 | 174 | |
| 171 | 175 | $user_object = new WP_User( $user->ID ); |
| 172 | 176 | |
| @@ -182,9 +186,9 @@ | ||
| 182 | 186 | |
| 183 | 187 | $display_username_email = wppb_get_email_display_username($user); |
| 184 | 188 | |
| 185 | 189 | //send primary email message |
| 186 | - $recovery_email_message = sprintf( __('Someone requested that the password be reset for the following account: <b>%1$s</b><br/>If this was a mistake, just ignore this email and nothing will happen.<br/>To reset your password, visit the following link:%2$s', 'profile-builder'), $display_username_email, '<a href="'.esc_url( add_query_arg( array( 'key' => $key, 'login' => $requested_user_login ), wppb_curpageurl() ) ).'">'.esc_url( add_query_arg( array( 'key' => $key, 'login' => $requested_user_login ), wppb_curpageurl() ) ).'</a>' ); | |
| 190 | + $recovery_email_message = sprintf( __('Someone requested that the password be reset for the following account: <b>%1$s</b><br/>If this was a mistake, just ignore this email and nothing will happen.<br/>To reset your password, visit the following link:%2$s', 'profile-builder'), $display_username_email, '<a href="'.esc_url( add_query_arg( array( 'key' => $key, 'login' => urlencode( $requested_user_login ) ), wppb_curpageurl() ) ).'">'.esc_url( add_query_arg( array( 'key' => $key, 'login' => urlencode( $requested_user_login ) ), wppb_curpageurl() ) ).'</a>' ); | |
| 187 | 191 | $recovery_email_message = apply_filters( 'wppb_recover_password_message_content_sent_to_user1', $recovery_email_message, $requested_user_id, $requested_user_login, $requested_user_email ); |
| 188 | 192 | |
| 189 | 193 | $recovery_email_message_title = sprintf(__('Password Reset from %1$s', 'profile-builder'), $blogname = get_option('blogname') ); |
| 190 | 194 | $recovery_email_message_title = apply_filters('wppb_recover_password_message_title_sent_to_user1', $recovery_email_message_title, $requested_user_login); |
| @@ -256,21 +260,35 @@ | ||
| 256 | 260 | $wppb_password_recovery_shortcode_on_front = true; |
| 257 | 261 | $password_email_sent = false; |
| 258 | 262 | $password_changed_success = false; |
| 259 | 263 | |
| 260 | - extract( shortcode_atts( array( 'block' => false ), $atts ) ); | |
| 264 | + $atts = shortcode_atts( array( | |
| 265 | + 'block' => false, | |
| 266 | + 'ajax' => false, | |
| 267 | + ), $atts, 'wppb-recover-password' ); | |
| 261 | 268 | |
| 269 | + $is_ajax_form = false; | |
| 270 | + if( defined( 'WPPB_PAID_PLUGIN_DIR' ) && $atts['ajax'] === 'true' && file_exists( WPPB_PAID_PLUGIN_DIR . '/features/ajax/assets/forms-ajax-validation.js' ) ) { | |
| 271 | + wp_enqueue_script( 'wppb-forms-ajax-validation-script', WPPB_PAID_PLUGIN_URL . 'features/ajax/assets/forms-ajax-validation.js', array( 'jquery' ), PROFILE_BUILDER_VERSION, true ); | |
| 272 | + wp_localize_script( 'wppb-forms-ajax-validation-script', 'submitButtonData', array( 'processingText' => __('Processing...', 'profile-builder') ) ); | |
| 273 | + $is_ajax_form = true; | |
| 274 | + } | |
| 275 | + | |
| 262 | 276 | $output = '<div class="wppb_holder" id="wppb-recover-password-container">'; |
| 263 | 277 | |
| 264 | 278 | global $wpdb; |
| 265 | 279 | |
| 266 | 280 | // check if the form is being displayed in the Elementor editor |
| 267 | - $is_elementor_edit_mode = false; | |
| 281 | + $is_elementor_edit_mode_or_divi_ajax = false; | |
| 268 | 282 | if( class_exists ( '\Elementor\Plugin' ) ){ |
| 269 | - $is_elementor_edit_mode = \Elementor\Plugin::$instance->editor->is_edit_mode(); | |
| 283 | + $is_elementor_edit_mode_or_divi_ajax = \Elementor\Plugin::$instance->editor->is_edit_mode(); | |
| 270 | 284 | } |
| 271 | 285 | |
| 272 | - if( is_user_logged_in() && !( $is_elementor_edit_mode || $block ) ) { | |
| 286 | + if ( is_array( $_POST ) && array_key_exists( 'action', $_POST ) && $_POST['action'] === 'wppb_divi_extension_ajax' ) { | |
| 287 | + $is_elementor_edit_mode_or_divi_ajax = true; | |
| 288 | + } | |
| 289 | + | |
| 290 | + if( is_user_logged_in() && !( $is_elementor_edit_mode_or_divi_ajax || $atts['block'] ) ) { | |
| 273 | 291 | return apply_filters('wppb_recover_password_already_logged_in', __('You are already logged in. You can change your password on the edit profile form.', 'profile-builder')); |
| 274 | 292 | } |
| 275 | 293 | |
| 276 | 294 | //Get general settings |
| @@ -286,23 +304,57 @@ | ||
| 286 | 304 | $username_email = ''; |
| 287 | 305 | |
| 288 | 306 | //check to see if it's an e-mail (and if this is valid/present in the database) or is a username |
| 289 | 307 | |
| 290 | - // if we do not have an email in the posted date we try to get the email for that user | |
| 291 | - if( !is_email( $username_email ) ){ | |
| 292 | - /* make sure it is a username */ | |
| 293 | - $username = sanitize_user( $username_email ); | |
| 294 | - if ( username_exists($username) ){ | |
| 295 | - $query = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE user_login= %s", $username ) ); | |
| 296 | - if( !empty( $query[0] ) ){ | |
| 297 | - $username_email = $query[0]->user_email; | |
| 308 | + if( $username_email === '' ){ | |
| 309 | + if( !empty( $wppb_generalSettings['loginWith'] ) && $wppb_generalSettings['loginWith'] == 'email' ) | |
| 310 | + $warning = __( 'Please enter your email address.', 'profile-builder' ); | |
| 311 | + else | |
| 312 | + $warning = __( 'Please enter your username or email address.', 'profile-builder' ); | |
| 313 | + $warning = apply_filters( 'wppb_recover_password_sent_message_empty', $warning ); | |
| 314 | + $output .= wppb_password_recovery_warning( $warning, 'wppb_recover_password_displayed_message1' ); | |
| 315 | + } elseif ( !is_email( $username_email ) ){ | |
| 316 | + // if we do not have an email in the posted date we try to get the email for that user | |
| 317 | + // When filter is enabled and login is set to email only, do not allow username for password reset | |
| 318 | + if ( apply_filters( 'wppb_recover_password_require_email_when_login_with_email', false ) && !empty( $wppb_generalSettings['loginWith'] ) && $wppb_generalSettings['loginWith'] == 'email' ) { | |
| 319 | + $warning = __( 'Please enter your email address to request a password reset.', 'profile-builder' ); | |
| 320 | + $warning = apply_filters( 'wppb_recover_password_sent_message_username_not_allowed', $warning ); | |
| 321 | + $output .= wppb_password_recovery_warning( $warning, 'wppb_recover_password_displayed_message1' ); | |
| 322 | + } else { | |
| 323 | + /* make sure it is a username */ | |
| 324 | + $username = sanitize_user( $username_email ); | |
| 325 | + if ( username_exists($username) ){ | |
| 326 | + $query = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE user_login= %s", $username ) ); | |
| 327 | + if( !empty( $query[0] ) ){ | |
| 328 | + $username_email = $query[0]->user_email; | |
| 329 | + } | |
| 330 | + } else { | |
| 331 | + if( apply_filters( 'wppb_recover_password_use_old_error_messages', false ) ) { | |
| 332 | + | |
| 333 | + if( !empty( $wppb_generalSettings['loginWith'] ) ){ | |
| 334 | + if( $wppb_generalSettings['loginWith'] == 'email' ){ | |
| 335 | + $warning = __( 'The email entered wasn\'t found in the database!', 'profile-builder').'<br/>'.__('Please check that you entered the correct email.', 'profile-builder' ); | |
| 336 | + | |
| 337 | + } | |
| 338 | + else if( $wppb_generalSettings['loginWith'] == 'username' ) { | |
| 339 | + $warning = __( 'The username entered wasn\'t found in the database!', 'profile-builder').'<br/>'.__('Please check that you entered the correct username.', 'profile-builder' ); | |
| 340 | + } | |
| 341 | + else{ | |
| 342 | + $warning = __( 'The email/username entered wasn\'t found in the database!', 'profile-builder').'<br/>'.__('Please check that you entered the correct email/username.', 'profile-builder' ); | |
| 343 | + } | |
| 344 | + } | |
| 345 | + $warning = apply_filters( 'wppb_recover_password_sent_message4', $warning ); | |
| 346 | + | |
| 347 | + $output .= wppb_password_recovery_warning( $warning, 'wppb_recover_password_displayed_message1' ); | |
| 348 | + | |
| 349 | + } else { | |
| 350 | + $warning = __( 'If your information matches an account, a confirmation link will be sent to your email address.', 'profile-builder' ); | |
| 351 | + $warning = apply_filters( 'wppb_recover_password_sent_message4', $warning ); | |
| 352 | + $output .= wppb_password_recovery_success( $warning, 'wppb_recover_password_displayed_message1' ); | |
| 353 | + $password_email_sent = true; | |
| 354 | + } | |
| 298 | 355 | } |
| 299 | 356 | } |
| 300 | - else{ | |
| 301 | - $warning = __( 'The username entered wasn\'t found in the database!', 'profile-builder').'<br/>'.__('Please check that you entered the correct username.', 'profile-builder' ); | |
| 302 | - $warning = apply_filters( 'wppb_recover_password_sent_message4', $warning ); | |
| 303 | - $output .= wppb_password_recovery_warning( $warning, 'wppb_recover_password_displayed_message1' ); | |
| 304 | - } | |
| 305 | 357 | } |
| 306 | 358 | |
| 307 | 359 | // we should have an email by this point |
| 308 | 360 | if ( is_email( $username_email ) ){ |
| @@ -307,16 +359,25 @@ | ||
| 307 | 359 | // we should have an email by this point |
| 308 | 360 | if ( is_email( $username_email ) ){ |
| 309 | 361 | if ( email_exists( $username_email ) ){ |
| 310 | 362 | $warning = wppb_check_for_unapproved_user($username_email, 'user_email'); |
| 311 | - if ($warning != ''){ | |
| 363 | + if ( $warning != '' ){ | |
| 312 | 364 | $output .= wppb_password_recovery_warning( $warning, 'wppb_recover_password_displayed_message1' ); |
| 313 | - }else{ | |
| 314 | - $success = sprintf( __( 'Check your email for the confirmation link.', 'profile-builder'), $username_email ); | |
| 365 | + } else { | |
| 366 | + | |
| 367 | + if( apply_filters( 'wppb_recover_password_use_old_error_messages', false ) ) { | |
| 368 | + $success = __( 'Check your email for the confirmation link.', 'profile-builder' ); | |
| 369 | + } else { | |
| 370 | + $success = __( 'If your information matches an account, a confirmation link will be sent to your email address.', 'profile-builder' ); | |
| 371 | + } | |
| 372 | + | |
| 315 | 373 | $success = apply_filters( 'wppb_recover_password_sent_message1', $success, $username_email ); |
| 316 | 374 | |
| 317 | - if ( $success != 'wppb_recaptcha_error') | |
| 375 | + if ( $success != 'wppb_recaptcha_error' && $success != 'wppb_turnstile_error' && $success != 'wppb_captcha_error' ) { | |
| 318 | 376 | $output .= wppb_password_recovery_success( $success, 'wppb_recover_password_displayed_message2' ); |
| 377 | + } else { | |
| 378 | + $output .= wppb_password_recovery_warning( $success, 'wppb_recover_password_displayed_message1' ); | |
| 379 | + } | |
| 319 | 380 | |
| 320 | 381 | //verify e-mail validity |
| 321 | 382 | $query = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE user_email= %s", sanitize_email( $username_email ) ) ); |
| 322 | 383 | if( !empty( $query[0] ) ){ |
| @@ -323,20 +384,29 @@ | ||
| 323 | 384 | $user = $query[0]; |
| 324 | 385 | |
| 325 | 386 | //send mail to the user notifying him of the reset request |
| 326 | 387 | $sent = wppb_send_recovery_email( $user, $success ); |
| 327 | - if ($sent === false){ | |
| 328 | - $warning = '<strong>'. __( 'ERROR:', 'profile-builder' ) .'</strong>' . sprintf( __( 'There was an error while trying to send the activation link to %1$s!', 'profile-builder' ), $username_email ); | |
| 388 | + | |
| 389 | + if ( $sent === false ){ | |
| 390 | + $warning = '<strong>'. __( 'ERROR:', 'profile-builder' ) .'</strong>' . __( 'There was an error while trying to send the activation link!', 'profile-builder' ); | |
| 329 | 391 | $warning = apply_filters( 'wppb_recover_password_sent_message_error_sending', $warning ); |
| 330 | 392 | $output .= wppb_password_recovery_warning( $warning, 'wppb_recover_password_displayed_message1' ); |
| 393 | + } else { | |
| 394 | + $password_email_sent = true; | |
| 331 | 395 | } |
| 332 | - else | |
| 333 | - $password_email_sent = true; | |
| 334 | 396 | |
| 397 | + if( !apply_filters( 'wppb_recover_password_use_old_error_messages', false ) ) { | |
| 398 | + // We want to set this to true regardless of the email result, so we can hide the form (to prevent user enumeration). | |
| 399 | + // But ONLY if the captcha was solved successfully. | |
| 400 | + if ( $success != 'wppb_recaptcha_error' && $success != 'wppb_turnstile_error' && $success != 'wppb_captcha_error' ) { | |
| 401 | + $password_email_sent = true; | |
| 402 | + } | |
| 403 | + } | |
| 404 | + | |
| 335 | 405 | } |
| 336 | 406 | |
| 337 | 407 | } |
| 338 | - }elseif ( !email_exists( $username_email ) ){ | |
| 408 | + } elseif ( !email_exists( $username_email ) ){ | |
| 339 | 409 | // check reCAPTCHA |
| 340 | 410 | $warning = wppb_password_recovery_warning( '', 'wppb_recover_password_displayed_message1' ); |
| 341 | 411 | |
| 342 | 412 | // if there is no reCAPTCHA error show the invalid email address error |
| @@ -342,9 +412,9 @@ | ||
| 342 | 412 | // if there is no reCAPTCHA error show the invalid email address error |
| 343 | 413 | if( $warning === '' ) { |
| 344 | 414 | $warning = __('The email address entered wasn\'t found in the database!', 'profile-builder').'<br/>'.__('Please check that you entered the correct email address.', 'profile-builder'); |
| 345 | 415 | $warning = apply_filters('wppb_recover_password_sent_message2', $warning); |
| 346 | - $output .= '<p class="wppb-warning">'.$warning.'</p>'; | |
| 416 | + $output .= '<p class="wppb-warning" role="alert">'.$warning.'</p>'; | |
| 347 | 417 | } else { |
| 348 | 418 | $output .= $warning; |
| 349 | 419 | } |
| 350 | 420 | } |
| @@ -400,8 +470,14 @@ | ||
| 400 | 470 | $output .= wppb_password_recovery_error( $password_change_message, 'wppb_recover_password_password_changed_message2' ); |
| 401 | 471 | } |
| 402 | 472 | } |
| 403 | 473 | |
| 474 | + $password_change_message = apply_filters( 'wppb_recover_password_extra_validation', $password_change_message, $user ); | |
| 475 | + | |
| 476 | + if( !empty( $password_change_message ) ){ | |
| 477 | + $output .= wppb_password_recovery_error( $password_change_message, 'wppb_custom_recover_password_validation_message' ); | |
| 478 | + } | |
| 479 | + | |
| 404 | 480 | if( empty($password_change_message) ){ |
| 405 | 481 | |
| 406 | 482 | $password_change_message = __( 'Your password has been successfully changed!', 'profile-builder' ); |
| 407 | 483 | $output .= wppb_password_recovery_success( $password_change_message, 'wppb_recover_password_password_changed_message1' ); |
| @@ -430,10 +506,8 @@ | ||
| 430 | 506 | $redirect_url = wppb_get_redirect_url( 'normal', 'after_success_password_reset', '', sanitize_user( $user_info->user_login ) ); |
| 431 | 507 | |
| 432 | 508 | //log the user in if the option was selected |
| 433 | 509 | if ( apply_filters( 'wppb_recover_password_autologin', false ) ){ |
| 434 | - $nonce = wp_create_nonce( 'autologin-'. sanitize_user( $user_info->ID ) .'-'. (int)( time() / 60 ) ); | |
| 435 | - | |
| 436 | 510 | //use the after_login redirect if no after_success_password_reset redirect is set |
| 437 | 511 | if( empty( $redirect_url ) ) { |
| 438 | 512 | $redirect_url = wppb_get_redirect_url( 'normal', 'after_login', '', sanitize_user( $user_info->user_login ) ); |
| 439 | 513 | $redirect_url = apply_filters( 'wppb_after_recover_and_login', $redirect_url ); |
| @@ -441,9 +515,9 @@ | ||
| 441 | 515 | if( empty( $redirect_url ) ) { |
| 442 | 516 | $redirect_url = remove_query_arg( 'key', wppb_curpageurl() ); |
| 443 | 517 | } |
| 444 | 518 | |
| 445 | - $redirect_url = add_query_arg( array( 'autologin' => 'true', 'uid' => sanitize_user( $user_info->ID ), '_wpnonce' => $nonce ), $redirect_url ); | |
| 519 | + $redirect_url = add_query_arg( wppb_get_autologin_query_args( $user_info->ID ), $redirect_url ); | |
| 446 | 520 | } |
| 447 | 521 | |
| 448 | 522 | $redirect_delay = apply_filters( 'wppb_success_password_reset_redirect_delay', 3, sanitize_user( $user_info->user_login ) ); |
| 449 | 523 | $redirect_message = wppb_build_redirect( $redirect_url, $redirect_delay, 'after_success_password_reset' ); |
| @@ -475,9 +549,9 @@ | ||
| 475 | 549 | |
| 476 | 550 | if( !is_wp_error( $user ) ){ |
| 477 | 551 | |
| 478 | 552 | ob_start(); |
| 479 | - wppb_create_recover_password_form( $user, $_POST ); | |
| 553 | + wppb_create_recover_password_form( $user, $_POST, $is_ajax_form ); | |
| 480 | 554 | $output .= ob_get_contents(); |
| 481 | 555 | ob_end_clean(); |
| 482 | 556 | } |
| 483 | 557 | else { |
| @@ -485,9 +559,9 @@ | ||
| 485 | 559 | } |
| 486 | 560 | |
| 487 | 561 | } elseif ( !$password_changed_success && !$password_email_sent ) { |
| 488 | 562 | ob_start(); |
| 489 | - wppb_create_generate_password_form($_POST); | |
| 563 | + wppb_create_generate_password_form($_POST, $is_ajax_form); | |
| 490 | 564 | $output .= ob_get_contents(); |
| 491 | 565 | ob_end_clean(); |
| 492 | 566 | } |
| 493 | 567 | |
| @@ -493,9 +567,9 @@ | ||
| 493 | 567 | |
| 494 | 568 | } else { |
| 495 | 569 | if( !$password_email_sent ) { |
| 496 | 570 | ob_start(); |
| 497 | - wppb_create_generate_password_form($_POST); | |
| 571 | + wppb_create_generate_password_form($_POST, $is_ajax_form); | |
| 498 | 572 | $output .= ob_get_contents(); |
| 499 | 573 | ob_end_clean(); |
| 500 | 574 | } |
| 501 | 575 | } |
| @@ -508,15 +582,15 @@ | ||
| 508 | 582 | } |
| 509 | 583 | |
| 510 | 584 | /* function for displaying success messages on the recover password page */ |
| 511 | 585 | function wppb_password_recovery_success( $message, $filter ){ |
| 512 | - return apply_filters( $filter, '<p class="wppb-success">'.$message.'</p>', $message ); | |
| 586 | + return apply_filters( $filter, '<p class="wppb-success" role="alert">'.$message.'</p>', $message ); | |
| 513 | 587 | } |
| 514 | 588 | |
| 515 | 589 | /* function for displaying warning messages on the recover password page */ |
| 516 | 590 | function wppb_password_recovery_warning( $message, $filter ){ |
| 517 | 591 | if( $message !== '' ) { |
| 518 | - return apply_filters( $filter, '<p class="wppb-warning">'.$message.'</p>', $message ); | |
| 592 | + return apply_filters( $filter, '<p class="wppb-warning" role="alert">'.$message.'</p>', $message ); | |
| 519 | 593 | } else { |
| 520 | 594 | return apply_filters( $filter, '', $message ); |
| 521 | 595 | } |
| 522 | 596 | } |
| @@ -522,6 +596,14 @@ | ||
| 522 | 596 | } |
| 523 | 597 | |
| 524 | 598 | /* function for displaying error messages on the recover password page */ |
| 525 | 599 | function wppb_password_recovery_error( $message, $filter ){ |
| 526 | - return apply_filters( $filter, '<p class="wppb-error">'.$message.'</p>', $message ); | |
| 600 | + return apply_filters( $filter, '<p class="wppb-error" role="alert">'.$message.'</p>', $message ); | |
| 527 | 601 | } |
| 602 | + | |
| 603 | + | |
| 604 | +// include missing scripts needed on Elementor Pages (Form inside an Elementor Popup) | |
| 605 | +function wppb_recover_password_scripts_and_styles() { | |
| 606 | + if ( is_plugin_active('elementor-pro/elementor-pro.php') && defined( 'WPPB_PAID_PLUGIN_URL' ) ) | |
| 607 | + wp_enqueue_script( 'wppb_elementor_popup_script', WPPB_PAID_PLUGIN_URL . 'features/elementor-pro/assets/js/elementor-popup.js', array('jquery') ); | |
| 608 | +} | |
| 609 | +add_action( 'elementor/frontend/after_enqueue_scripts', 'wppb_recover_password_scripts_and_styles' ); | |