Make WordPress Core

Ticket #761: 761.5.diff

File 761.5.diff, 3.5 KB (added by adamsilverstein, 9 years ago)
  • src/wp-includes/comment-functions.php

     
    16241624         *
    16251625         * @since 1.2.0
    16261626         *
     1627         * Calls {@see 'wp_notify_post_author'} to determine if the post author should be
     1628         * notified. Calls {@see 'wp_notify_moderator'} to determine if the site moderator
     1629         * should be notified.
     1630         *
    16271631         * @param int $comment_ID       The comment ID.
    16281632         * @param int $comment_approved 1 (true) if the comment is approved, 0 (false) if not.
    16291633         */
     
    16311635
    16321636        if ( 'spam' !== $commentdata['comment_approved'] ) { // If it's spam save it silently for later crunching
    16331637                if ( '0' == $commentdata['comment_approved'] ) {
    1634                         wp_notify_moderator( $comment_ID );
     1638
     1639                        $maybe_notify = get_option( 'moderation_notify' );
     1640
     1641                        /**
     1642                         * Filter the blog moderator email notification setting.
     1643                         *
     1644                         * @since 4.4.0
     1645                         *
     1646                         * @param bool $maybe_notify Whether to notify blog moderator.
     1647                         * @param int  $comment_ID   The id of the comment for the notification.
     1648                         */
     1649                        if ( apply_filters( 'wp_notify_moderator', $maybe_notify, $comment_ID ) ) {
     1650                                wp_notify_moderator( $comment_ID );
     1651                        }
    16351652                }
    16361653
     1654                $maybe_notify = get_option( 'comments_notify' ) && $commentdata['comment_approved'];
     1655
     1656                /**
     1657                 * Filter the post author email notification setting.
     1658                 *
     1659                 * @since 4.4.0
     1660                 *
     1661                 * @param bool $maybe_notify Whether to notify post author.
     1662                 * @param int  $comment_ID   The id of the comment for the notification.
     1663                 */
     1664                $maybe_notify = apply_filters( 'wp_notify_post_author', $maybe_notify, $comment_ID );
    16371665                // wp_notify_postauthor() checks if notifying the author of their own comment.
    16381666                // By default, it won't, but filters can override this.
    1639                 if ( get_option( 'comments_notify' ) && $commentdata['comment_approved'] ) {
     1667                if ( $maybe_notify ) {
    16401668                        wp_notify_postauthor( $comment_ID );
    16411669                }
    16421670        }
     
    16521680 *
    16531681 * @since 1.0.0
    16541682 *
     1683 * Calls {@see 'wp_notify_post_author'} to determine if the post author should be
     1684 * notified.
     1685 *
    16551686 * global wpdb $wpdb
    16561687 *
    16571688 * @param int $comment_id Comment ID.
     
    16701701                case 'approve':
    16711702                case '1':
    16721703                        $status = '1';
    1673                         if ( get_option('comments_notify') ) {
     1704                        $maybe_notify = get_option( 'comments_notify' );
     1705
     1706                        /** This filter is documented in wp-includes/comment-functions.php */
     1707                        $maybe_notify = apply_filters( 'wp_notify_post_author', $maybe_notify, $comment_id );
     1708                        if ( $maybe_notify ) {
    16741709                                wp_notify_postauthor( $comment_id );
    16751710                        }
    16761711                        break;
  • src/wp-includes/pluggable.php

     
    15461546 *
    15471547 * @global wpdb $wpdb WordPress database abstraction object.
    15481548 *
     1549 *
     1550 * @uses apply_filters() Calls 'wp_notify_moderator' to determine if blog moderator
     1551 *                       should be notified.
     1552 *
    15491553 * @param int $comment_id Comment ID
    15501554 * @return true Always returns true
    15511555 */
     
    15521556function wp_notify_moderator($comment_id) {
    15531557        global $wpdb;
    15541558
    1555         if ( 0 == get_option( 'moderation_notify' ) )
     1559        $maybe_notify = get_option( 'moderation_notify' );
     1560
     1561        /** This filter is documented in wp-includes/comment-functions.php */
     1562        if ( ! apply_filters( 'wp_notify_moderator', $maybe_notify, $comment_id ) ) {
    15561563                return true;
     1564        }
    15571565
    15581566        $comment = get_comment($comment_id);
    15591567        $post = get_post($comment->comment_post_ID);