Make WordPress Core

Ticket #761: 761.4.diff

File 761.4.diff, 3.6 KB (added by adamsilverstein, 10 years ago)
  • src/wp-includes/comment-functions.php

     
    16311631         *
    16321632         * @since 1.2.0
    16331633         *
     1634         * @uses apply_filters()        Calls 'wp_notify_post_author' to determine if post
     1635         *                              author should be notified. Calls 'wp_notify_moderator'
     1636         *                              to determine if blog moderator should be notified.
     1637         *
    16341638         * @param int $comment_ID       The comment ID.
    16351639         * @param int $comment_approved 1 (true) if the comment is approved, 0 (false) if not.
    16361640         */
     
    16381642
    16391643        if ( 'spam' !== $commentdata['comment_approved'] ) { // If it's spam save it silently for later crunching
    16401644                if ( '0' == $commentdata['comment_approved'] ) {
    1641                         wp_notify_moderator( $comment_ID );
     1645
     1646                        $maybe_notify = get_option( 'moderation_notify' );
     1647                        /**
     1648                         * Filter the blog moderator email notification setting.
     1649                         *
     1650                         * @since 4.4.0
     1651                         *
     1652                         * @param bool $maybe_notify Whether to notify blog moderator.
     1653                         * @param int  $comment_ID   The id of the comment for the notification.
     1654                         */
     1655                        if ( apply_filters( 'wp_notify_moderator', $maybe_notify, $comment_ID ) ) {
     1656                                wp_notify_moderator( $comment_ID );
     1657                        }
    16421658                }
    16431659
     1660                $maybe_notify = get_option( 'comments_notify' ) && $commentdata['comment_approved'];
     1661
     1662                /**
     1663                 * Filter the post author email notification setting.
     1664                 *
     1665                 * @since 4.4.0
     1666                 *
     1667                 * @param bool $maybe_notify Whether to notify post author.
     1668                 * @param int  $comment_ID   The id of the comment for the notification.
     1669                 */
     1670                $maybe_notify = apply_filters( 'wp_notify_post_author', $maybe_notify, $comment_ID );
    16441671                // wp_notify_postauthor() checks if notifying the author of their own comment.
    16451672                // By default, it won't, but filters can override this.
    1646                 if ( get_option( 'comments_notify' ) && $commentdata['comment_approved'] ) {
     1673                if ( $maybe_notify ) {
    16471674                        wp_notify_postauthor( $comment_ID );
    16481675                }
    16491676        }
     
    16591686 *
    16601687 * @since 1.0.0
    16611688 *
     1689 * @uses apply_filters()        Calls 'wp_notify_post_author' to determine if post
     1690 *                              author should be notified.
     1691 *
    16621692 * global wpdb $wpdb
    16631693 *
    16641694 * @param int $comment_id Comment ID.
     
    16771707                case 'approve':
    16781708                case '1':
    16791709                        $status = '1';
    1680                         if ( get_option('comments_notify') ) {
     1710                        $maybe_notify = get_option( 'comments_notify' );
     1711
     1712                        /** This filter is documented in wp-includes/comment-functions.php */
     1713                        $maybe_notify = apply_filters( 'wp_notify_post_author', $maybe_notify, $comment_id );
     1714                        if ( $maybe_notify ) {
    16811715                                wp_notify_postauthor( $comment_id );
    16821716                        }
    16831717                        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);