Make WordPress Core

Changeset 26114


Ignore:
Timestamp:
11/13/2013 02:31:15 AM (12 years ago)
Author:
SergeyBiryukov
Message:

Avoid PHP notices in wp_notify_postauthor() when using a custom comment type.
Use a switch statement for consistency with wp_notify_moderator().

fixes #25880.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r26000 r26114  
    10441044    if ( empty( $comment_type ) ) $comment_type = 'comment';
    10451045
    1046     if ('comment' == $comment_type) {
    1047         $notify_message  = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
    1048         /* translators: 1: comment author, 2: author IP, 3: author domain */
    1049         $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1050         $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
    1051         $notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
    1052         $notify_message .= sprintf( __('Whois  : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n";
    1053         $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
    1054         $notify_message .= __('You can see all comments on this post here: ') . "\r\n";
    1055         /* translators: 1: blog name, 2: post title */
    1056         $subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
    1057     } elseif ('trackback' == $comment_type) {
    1058         $notify_message  = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n";
    1059         /* translators: 1: website name, 2: author IP, 3: author domain */
    1060         $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1061         $notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
    1062         $notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
    1063         $notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n";
    1064         /* translators: 1: blog name, 2: post title */
    1065         $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
    1066     } elseif ('pingback' == $comment_type) {
    1067         $notify_message  = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n";
    1068         /* translators: 1: comment author, 2: author IP, 3: author domain */
    1069         $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1070         $notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
    1071         $notify_message .= __('Excerpt: ') . "\r\n" . sprintf('[...] %s [...]', $comment->comment_content ) . "\r\n\r\n";
    1072         $notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n";
    1073         /* translators: 1: blog name, 2: post title */
    1074         $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
     1046    switch ( $comment_type ) {
     1047        case 'trackback':
     1048            $notify_message  = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n";
     1049            /* translators: 1: website name, 2: author IP, 3: author domain */
     1050            $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
     1051            $notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
     1052            $notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
     1053            $notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n";
     1054            /* translators: 1: blog name, 2: post title */
     1055            $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
     1056            break;
     1057        case 'pingback':
     1058            $notify_message  = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n";
     1059            /* translators: 1: comment author, 2: author IP, 3: author domain */
     1060            $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
     1061            $notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
     1062            $notify_message .= __('Excerpt: ') . "\r\n" . sprintf('[...] %s [...]', $comment->comment_content ) . "\r\n\r\n";
     1063            $notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n";
     1064            /* translators: 1: blog name, 2: post title */
     1065            $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
     1066            break;
     1067        default: // Comments
     1068            $notify_message  = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
     1069            /* translators: 1: comment author, 2: author IP, 3: author domain */
     1070            $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
     1071            $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
     1072            $notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
     1073            $notify_message .= sprintf( __('Whois  : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n";
     1074            $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
     1075            $notify_message .= __('You can see all comments on this post here: ') . "\r\n";
     1076            /* translators: 1: blog name, 2: post title */
     1077            $subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
     1078            break;
    10751079    }
    10761080    $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
     
    11491153    $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    11501154
    1151     switch ($comment->comment_type)
    1152     {
     1155    switch ( $comment->comment_type ) {
    11531156        case 'trackback':
    11541157            $notify_message  = sprintf( __('A new trackback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
     
    11651168            $notify_message .= __('Pingback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
    11661169            break;
    1167         default: //Comments
     1170        default: // Comments
    11681171            $notify_message  = sprintf( __('A new comment on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
    11691172            $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
Note: See TracChangeset for help on using the changeset viewer.