SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | /* | |
| 3 | Plugin Name: Remove Angle Brackets | |
| 4 | Plugin URI: http://milordk.ru/r-lichnoe/opyt/cms/ispravlyaem-ssylku-dlya-vosstanovleniya-parolya-v-wordpres-3-1-3.html | |
| 5 | - | Version: 0.1 |
| 5 | + | Version: 0.2 |
| 6 | - | Description: Removes angle brackets from a password reset link. |
| 6 | + | Description: Removes angle brackets from a password reset link for Mail.Ru service. |
| 7 | Author: Sergey Biryukov | |
| 8 | Author URI: http://sergeybiryukov.ru/ | |
| 9 | */ | |
| 10 | ||
| 11 | function remove_angle_brackets($message) {
| |
| 12 | - | return preg_replace('/<(https?):\/\/(.*)>/', '$1://$2', $message);
|
| 12 | + | if ( empty( $_POST['user_login'] ) ) |
| 13 | return $message; | |
| 14 | ||
| 15 | if ( strpos( $_POST['user_login'], '@' ) ) {
| |
| 16 | $user_data = get_user_by( 'email', trim( $_POST['user_login'] ) ); | |
| 17 | } else {
| |
| 18 | $login = trim($_POST['user_login']); | |
| 19 | $user_data = get_user_by('login', $login);
| |
| 20 | } | |
| 21 | ||
| 22 | if ( !empty( $user_data ) && strpos( $user_data->user_email, '@mail.ru' ) ) | |
| 23 | $message = preg_replace('/<(https?):\/\/(.*)>/', '$1://$2', $message);
| |
| 24 | ||
| 25 | return $message; | |
| 26 | } | |
| 27 | add_filter('retrieve_password_message', 'remove_angle_brackets');
| |
| 28 | ?> |