WordPress.org

Make WordPress Core

Ticket #33717: 33717.6.diff

File 33717.6.diff, 4.3 KB (added by swissspidy, 6 years ago)
  • src/wp-includes/class-walker-comment.php

    diff --git src/wp-includes/class-walker-comment.php src/wp-includes/class-walker-comment.php
    index e0150b3..913d13f 100644
    class Walker_Comment extends Walker { 
    264264                        <?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>' ), get_comment_author_link( $comment ) ); ?>
    265265                </div>
    266266                <?php if ( '0' == $comment->comment_approved ) : ?>
    267                 <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ) ?></em>
     267                <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation. You will receive an email when it gets approved.' ) ?></em>
    268268                <br />
    269269                <?php endif; ?>
    270270
    class Walker_Comment extends Walker { 
    329329                                        </div><!-- .comment-metadata -->
    330330
    331331                                        <?php if ( '0' == $comment->comment_approved ) : ?>
    332                                         <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></p>
     332                                        <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation. You will receive an email when it gets approved.' ); ?></p>
    333333                                        <?php endif; ?>
    334334                                </footer><!-- .comment-meta -->
    335335
  • src/wp-includes/comment-functions.php

    diff --git src/wp-includes/comment-functions.php src/wp-includes/comment-functions.php
    index f953a9e..d632fba 100644
    function _close_comments_for_old_post( $open, $post_id ) { 
    23912391
    23922392        return $open;
    23932393}
     2394
     2395
     2396/**
     2397 * Notify a comment author when his comment gets approved.
     2398 *
     2399 * This notification is only sent when the comment status
     2400 * changes from unapproved to approved.
     2401 *
     2402 * @since 4.4.0
     2403 *
     2404 * @param WP_Comment $comment Comment object.
     2405 * @return bool Whether the email was sent successfully.
     2406 */
     2407function wp_notify_commenter( $comment ) {
     2408        $post = get_post( $comment->comment_post_ID );
     2409        $comment_author = get_user_by( 'email', $comment->comment_author_email );
     2410
     2411        if ( ! $post ) {
     2412                return false;
     2413        }
     2414
     2415        // The comment was left by the post author.
     2416        if ( $comment->user_id === $post->post_author || $comment_author === get_userdata( $post->post_author ) ) {
     2417                return false;
     2418        }
     2419
     2420        /*
     2421         * The blogname option is escaped with esc_html
     2422         * on the way into the database in sanitize_option.
     2423         * We want to reverse this for the plain text arena of emails.
     2424         */
     2425        $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
     2426
     2427        /* translators: 1: blog name, 2: post title */
     2428        $subject = sprintf( __( '[%1$s] Your comment on "%2$s" got approved' ), $blogname, $post->post_title );
     2429
     2430        $notify_message = sprintf( __( 'Howdy %s,' ), $comment->comment_author ) . "\r\n\r\n";
     2431        $notify_message .= sprintf( __( 'Your comment on the post "%1$s" got approved.' ), $post->post_title ) . "\r\n\r\n";
     2432        /* translators: 1: comment author, 2: author IP, 3: author domain */
     2433        $notify_message .= sprintf( __( 'View comment: %s' ), get_comment_link( $comment ) ) . "\r\n";
     2434
     2435        /**
     2436         * Filter the comment approval notification email text.
     2437         *
     2438         * @since 4.4.0
     2439         *
     2440         * @param string     $notify_message The comment notification email text.
     2441         * @param WP_Comment $comment        Comment object.
     2442         */
     2443        $notify_message = apply_filters( 'comment_approval_notification_text', $notify_message, $comment );
     2444
     2445        /**
     2446         * Filter the comment approval notification email subject.
     2447         *
     2448         * @since 4.4.0
     2449         *
     2450         * @param string     $subject The comment notification email subject.
     2451         * @param WP_Comment $comment Comment object.
     2452         */
     2453        $subject = apply_filters( 'comment_approval_notification_subject', $subject, $comment );
     2454
     2455        return wp_mail( $comment->comment_author_email, wp_specialchars_decode( $subject ), $notify_message );
     2456}
  • src/wp-includes/default-filters.php

    diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
    index b6f0ce3..9c38bb4 100644
    add_action( 'split_shared_term', '_wp_check_split_terms_in_menus', 10, 4 ); 
    334334add_action( 'split_shared_term', '_wp_check_split_nav_menu_terms', 10, 4 );
    335335add_action( 'wp_split_shared_term_batch', '_wp_batch_split_terms' );
    336336
     337// Comments.
     338add_action( 'comment_unapproved_to_approved', 'wp_notify_commenter', 10, 3 );
     339
    337340/**
    338341 * Filters formerly mixed into wp-includes
    339342 */