*/
$from_name = apply_filters( 'wp_mail_from_name', $from_name );
- $phpmailer->setFrom( $from_email, $from_name );
+ $phpmailer->setFrom( $from_email, $from_name, false );
// Set destination addresses
if ( !is_array( $to ) )
} catch ( phpmailerException $e ) {
$mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
+ $mail_error_data['phpmailer_exception_code'] = $e->getCode();
/**
* Fires after a phpmailerException is caught.
*
* @since 4.4.0
*
- * @param WP_Error $error A WP_Error object with the phpmailerException code, message, and an array
+ * @param WP_Error $error A WP_Error object with the phpmailerException message, and an array
* containing the mail recipient, subject, message, headers, and attachments.
*/
- do_action( 'wp_mail_failed', new WP_Error( $e->getCode(), $e->getMessage(), $mail_error_data ) );
+ do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) );
return false;
}
$expired = $expiration = $cookie_elements['expiration'];
// Allow a grace period for POST and Ajax requests
- if ( defined('DOING_AJAX') || 'POST' == $_SERVER['REQUEST_METHOD'] ) {
+ if ( wp_doing_ajax() || 'POST' == $_SERVER['REQUEST_METHOD'] ) {
$expired += HOUR_IN_SECONDS;
}
* 0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
*/
function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) {
+ if ( -1 == $action ) {
+ _doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '4.7' );
+ }
+
$nonce = '';
if ( $query_arg && isset( $_REQUEST[ $query_arg ] ) )
do_action( 'check_ajax_referer', $action, $result );
if ( $die && false === $result ) {
- if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
- wp_die( -1 );
+ if ( wp_doing_ajax() ) {
+ wp_die( -1, 403 );
} else {
die( '-1' );
}
* Exiting can also be selectively manipulated by using wp_redirect() as a conditional
* in conjunction with the {@see 'wp_redirect'} and {@see 'wp_redirect_location'} hooks:
*
- * if ( wp_redirect( $url ) {
+ * if ( wp_redirect( $url ) ) {
* exit;
* }
*
$emails = array_flip( $emails );
}
+ $switched_locale = switch_to_locale( get_locale() );
+
$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
switch ( $comment->comment_type ) {
case 'trackback':
+ /* translators: 1: Post title */
$notify_message = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n";
- /* translators: 1: website name, 2: website IP, 3: website hostname */
+ /* translators: 1: Trackback/pingback website name, 2: website IP, 3: website hostname */
$notify_message .= sprintf( __('Website: %1$s (IP: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
$notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
$subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
break;
case 'pingback':
+ /* translators: 1: Post title */
$notify_message = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n";
- /* translators: 1: website name, 2: website IP, 3: website hostname */
+ /* translators: 1: Trackback/pingback website name, 2: website IP, 3: website hostname */
$notify_message .= sprintf( __('Website: %1$s (IP: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
$notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
@wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers );
}
+ if ( $switched_locale ) {
+ restore_previous_locale();
+ }
+
return true;
}
endif;
$emails[] = $user->user_email;
}
+ $switched_locale = switch_to_locale( get_locale() );
+
$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
$comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");
switch ( $comment->comment_type ) {
case 'trackback':
+ /* translators: 1: Post title */
$notify_message = sprintf( __('A new trackback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
- /* translators: 1: website name, 2: website IP, 3: website hostname */
+ /* translators: 1: Trackback/pingback website name, 2: website IP, 3: website hostname */
$notify_message .= sprintf( __( 'Website: %1$s (IP: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+ /* translators: 1: Trackback/pingback/comment author URL */
$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
$notify_message .= __('Trackback excerpt: ') . "\r\n" . $comment_content . "\r\n\r\n";
break;
case 'pingback':
+ /* translators: 1: Post title */
$notify_message = sprintf( __('A new pingback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
- /* translators: 1: website name, 2: website IP, 3: website hostname */
+ /* translators: 1: Trackback/pingback website name, 2: website IP, 3: website hostname */
$notify_message .= sprintf( __( 'Website: %1$s (IP: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+ /* translators: 1: Trackback/pingback/comment author URL */
$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
$notify_message .= __('Pingback excerpt: ') . "\r\n" . $comment_content . "\r\n\r\n";
break;
default: // Comments
+ /* translators: 1: Post title */
$notify_message = sprintf( __('A new comment on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
+ /* translators: 1: Comment author name, 2: comment author's IP, 3: comment author IP's hostname */
$notify_message .= sprintf( __( 'Author: %1$s (IP: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+ /* translators: 1: Comment author URL */
$notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
+ /* translators: 1: Trackback/pingback/comment author URL */
$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
+ /* translators: 1: Comment text */
$notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
break;
}
+ /* translators: Comment moderation. 1: Comment action URL */
$notify_message .= sprintf( __( 'Approve it: %s' ), admin_url( "comment.php?action=approve&c={$comment_id}#wpbody-content" ) ) . "\r\n";
- if ( EMPTY_TRASH_DAYS )
+ if ( EMPTY_TRASH_DAYS ) {
+ /* translators: Comment moderation. 1: Comment action URL */
$notify_message .= sprintf( __( 'Trash it: %s' ), admin_url( "comment.php?action=trash&c={$comment_id}#wpbody-content" ) ) . "\r\n";
- else
+ } else {
+ /* translators: Comment moderation. 1: Comment action URL */
$notify_message .= sprintf( __( 'Delete it: %s' ), admin_url( "comment.php?action=delete&c={$comment_id}#wpbody-content" ) ) . "\r\n";
+ }
+ /* translators: Comment moderation. 1: Comment action URL */
$notify_message .= sprintf( __( 'Spam it: %s' ), admin_url( "comment.php?action=spam&c={$comment_id}#wpbody-content" ) ) . "\r\n";
+ /* translators: Comment moderation. 1: Number of comments awaiting approval */
$notify_message .= sprintf( _n('Currently %s comment is waiting for approval. Please visit the moderation panel:',
'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n";
$notify_message .= admin_url( "edit-comments.php?comment_status=moderated#wpbody-content" ) . "\r\n";
+ /* translators: Comment moderation notification email subject. 1: Site name, 2: Post title */
$subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), $blogname, $post->post_title );
$message_headers = '';
@wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers );
}
+ if ( $switched_locale ) {
+ restore_previous_locale();
+ }
+
return true;
}
endif;
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
if ( 'user' !== $notify ) {
+ $switched_locale = switch_to_locale( get_locale() );
$message = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
$message .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
$message .= sprintf( __( 'Email: %s' ), $user->user_email ) . "\r\n";
@wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] New User Registration' ), $blogname ), $message );
+
+ if ( $switched_locale ) {
+ restore_previous_locale();
+ }
}
- // `$deprecated was pre-4.3 `$plaintext_pass`. An empty `$plaintext_pass` didn't sent a user notifcation.
+ // `$deprecated was pre-4.3 `$plaintext_pass`. An empty `$plaintext_pass` didn't sent a user notification.
if ( 'admin' === $notify || ( empty( $deprecated ) && empty( $notify ) ) ) {
return;
}
// Now insert the key, hashed, into the DB.
if ( empty( $wp_hasher ) ) {
- require_once ABSPATH . WPINC . '/class-phpass.php';
$wp_hasher = new PasswordHash( 8, true );
}
$hashed = time() . ':' . $wp_hasher->HashPassword( $key );
$wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) );
+ $switched_locale = switch_to_locale( get_user_locale( $user ) );
+
$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
$message .= __('To set your password, visit the following address:') . "\r\n\r\n";
$message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login') . ">\r\n\r\n";
$message .= wp_login_url() . "\r\n";
wp_mail($user->user_email, sprintf(__('[%s] Your username and password info'), $blogname), $message);
+
+ if ( $switched_locale ) {
+ restore_previous_locale();
+ }
}
endif;
global $wp_hasher;
if ( empty($wp_hasher) ) {
- require_once( ABSPATH . WPINC . '/class-phpass.php');
// By default, use the portable hash from phpass
$wp_hasher = new PasswordHash(8, true);
}
// If the stored hash is longer than an MD5, presume the
// new style phpass portable hash.
if ( empty($wp_hasher) ) {
- require_once( ABSPATH . WPINC . '/class-phpass.php');
// By default, use the portable hash from phpass
$wp_hasher = new PasswordHash(8, true);
}