Ticket #9682: 9682.4.diff

File 9682.4.diff, 3.1 KB (added by Denis-de-Bernardy, 4 years ago)

fix the has_filter check

Line 
1Index: wp-login.php
2===================================================================
3--- wp-login.php        (revision 11136)
4+++ wp-login.php        (working copy)
5@@ -147,8 +147,13 @@
6        $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
7        $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
8        $message .= site_url("wp-login.php?action=rp&key=$key", 'login') . "\r\n";
9-
10-       if ( !wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_option('blogname')), $message) )
11+       
12+       $title = sprintf(__('[%s] Password Reset'), get_option('blogname'));
13+       
14+       $title = apply_filters('retrieve_password_title', $title);
15+       $message = apply_filters('retrieve_password_message', $message, $key);
16+       
17+       if ( $message && !wp_mail($user_email, $title, $message) )
18                die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
19 
20        return true;
21@@ -174,16 +179,22 @@
22        if ( empty( $user ) )
23                return new WP_Error('invalid_key', __('Invalid key'));
24 
25-       do_action('password_reset', $user);
26-
27        // Generate something random for a password...
28        $new_pass = wp_generate_password();
29+       
30+       do_action('password_reset', $user, $new_pass);
31+
32        wp_set_password($new_pass, $user->ID);
33        $message  = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
34        $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
35        $message .= site_url('wp-login.php', 'login') . "\r\n";
36+       
37+       $title = sprintf(__('[%s] Your new password'), get_option('blogname'));
38+       
39+       $title = apply_filters('password_reset_title', $title);
40+       $message = apply_filters('password_reset_message', $message, $new_pass);
41 
42-       if (  !wp_mail($user->user_email, sprintf(__('[%s] Your new password'), get_option('blogname')), $message) )
43+       if ( $message && !wp_mail($user->user_email, $title, $message) )
44                die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
45 
46        wp_password_change_notification($user);
47@@ -245,12 +256,19 @@
48 // Main
49 //
50 
51-$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
52+$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login';
53 $errors = new WP_Error();
54 
55 if ( isset($_GET['key']) )
56        $action = 'resetpass';
57 
58+// validate action so as to default to the login screen
59+if ( !in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login', '')) && false === has_filter('login_form_' . $action) )
60+       $action = 'login';
61+
62+// allow plugins to override the wp actions
63+$action = apply_filters('login_form_action', $action);
64+
65 nocache_headers();
66 
67 header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
68@@ -403,7 +421,6 @@
69 break;
70 
71 case 'login' :
72-default:
73        $secure_cookie = '';
74 
75        // If the user wants ssl but the session is not ssl, force a secure cookie.
76@@ -514,5 +531,9 @@
77 <?php
78 
79 break;
80+
81+// allow plugins to add extra actions if they want
82+default:
83+do_action('login_form_' . $action);
84 } // end action switch
85-?>
86+?>
87\ No newline at end of file