--- a/wp/wp-mail.php Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-mail.php Tue Dec 15 13:49:49 2020 +0100
@@ -8,7 +8,7 @@
*/
/** Make sure that the WordPress bootstrap has run before continuing. */
-require( dirname( __FILE__ ) . '/wp-load.php' );
+require __DIR__ . '/wp-load.php';
/** This filter is documented in wp-admin/options.php */
if ( ! apply_filters( 'enable_post_by_email_configuration', true ) ) {
@@ -26,14 +26,14 @@
*
* @since 2.9.0
*/
-do_action( 'wp-mail.php' );
+do_action( 'wp-mail.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
/** Get the POP3 class with which to access the mailbox. */
-require_once( ABSPATH . WPINC . '/class-pop3.php' );
+require_once ABSPATH . WPINC . '/class-pop3.php';
/** Only check at this interval for new messages. */
if ( ! defined( 'WP_MAIL_INTERVAL' ) ) {
- define( 'WP_MAIL_INTERVAL', 300 ); // 5 minutes
+ define( 'WP_MAIL_INTERVAL', 5 * MINUTE_IN_SECONDS );
}
$last_checked = get_transient( 'mailserver_last_checked' );
@@ -101,7 +101,7 @@
$content_transfer_encoding = explode( ';', $content_transfer_encoding );
$content_transfer_encoding = $content_transfer_encoding[0];
}
- if ( ( $content_type == 'multipart/alternative' ) && ( false !== strpos( $line, 'boundary="' ) ) && ( '' == $boundary ) ) {
+ if ( ( 'multipart/alternative' === $content_type ) && ( false !== strpos( $line, 'boundary="' ) ) && ( '' === $boundary ) ) {
$boundary = trim( $line );
$boundary = explode( '"', $boundary );
$boundary = $boundary[1];
@@ -109,7 +109,7 @@
if ( preg_match( '/Subject: /i', $line ) ) {
$subject = trim( $line );
$subject = substr( $subject, 9, strlen( $subject ) - 9 );
- // Captures any text in the subject before $phone_delim as the subject
+ // Captures any text in the subject before $phone_delim as the subject.
if ( function_exists( 'iconv_mime_decode' ) ) {
$subject = iconv_mime_decode( $subject, 2, get_option( 'blog_charset' ) );
} else {
@@ -131,7 +131,7 @@
}
$author = sanitize_email( $author );
if ( is_email( $author ) ) {
- /* translators: Post author email address */
+ /* translators: %s: Post author email address. */
echo '<p>' . sprintf( __( 'Author is %s' ), $author ) . '</p>';
$userdata = get_user_by( 'email', $author );
if ( ! empty( $userdata ) ) {
@@ -141,17 +141,18 @@
}
}
- if ( preg_match( '/Date: /i', $line ) ) { // of the form '20 Mar 2002 20:32:37 +0100'
- $ddate = str_replace( 'Date: ', '', trim( $line ) );
- $ddate = preg_replace( '!\s*\(.+\)\s*$!', '', $ddate ); // remove parenthesised timezone string if it exists, as this confuses strtotime
- $ddate_U = strtotime( $ddate );
- $post_date = gmdate( 'Y-m-d H:i:s', $ddate_U + $time_difference );
- $post_date_gmt = gmdate( 'Y-m-d H:i:s', $ddate_U );
+ if ( preg_match( '/Date: /i', $line ) ) { // Of the form '20 Mar 2002 20:32:37 +0100'.
+ $ddate = str_replace( 'Date: ', '', trim( $line ) );
+ // Remove parenthesised timezone string if it exists, as this confuses strtotime().
+ $ddate = preg_replace( '!\s*\(.+\)\s*$!', '', $ddate );
+ $ddate_timestamp = strtotime( $ddate );
+ $post_date = gmdate( 'Y-m-d H:i:s', $ddate_timestamp + $time_difference );
+ $post_date_gmt = gmdate( 'Y-m-d H:i:s', $ddate_timestamp );
}
}
}
- // Set $post_status based on $author_found and on author's publish_posts capability
+ // Set $post_status based on $author_found and on author's publish_posts capability.
if ( $author_found ) {
$user = new WP_User( $post_author );
$post_status = ( $user->has_cap( 'publish_posts' ) ) ? 'publish' : 'pending';
@@ -162,7 +163,7 @@
$subject = trim( $subject );
- if ( $content_type == 'multipart/alternative' ) {
+ if ( 'multipart/alternative' === $content_type ) {
$content = explode( '--' . $boundary, $content );
$content = $content[2];
@@ -195,7 +196,7 @@
$content = iconv( $charset, get_option( 'blog_charset' ), $content );
}
- // Captures any text in the body after $phone_delim as the body
+ // Captures any text in the body after $phone_delim as the body.
$content = explode( $phone_delim, $content );
$content = empty( $content[1] ) ? $content[0] : $content[1];
@@ -212,7 +213,7 @@
$post_title = xmlrpc_getposttitle( $content );
- if ( $post_title == '' ) {
+ if ( '' === trim( $post_title ) ) {
$post_title = $subject;
}
@@ -245,7 +246,7 @@
if ( ! $pop3->delete( $i ) ) {
echo '<p>' . sprintf(
- /* translators: %s: POP3 error */
+ /* translators: %s: POP3 error. */
__( 'Oops: %s' ),
esc_html( $pop3->ERROR )
) . '</p>';
@@ -253,7 +254,7 @@
exit;
} else {
echo '<p>' . sprintf(
- /* translators: %s: the message ID */
+ /* translators: %s: The message ID. */
__( 'Mission complete. Message %s deleted.' ),
'<strong>' . $i . '</strong>'
) . '</p>';