Plugin Directory

Changeset 761460

Timestamp:
08/23/2013 08:31:42 PM (11 years ago)
Author:
tmoorewp
Message:

Subscriptions: Modify syncing of comments. We don't want held, unapproved, or spam comments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • jetpack/trunk/modules/subscriptions.php

    r754110 r761460  
    7474        add_action( 'comment_form', array( $this, 'comment_subscribe_init' ) );
    7575
    76         // Catch comment posts and check for subscriptions.
    77         add_action( 'comment_post', array( $this, 'comment_subscribe_submit' ), 50, 2 );
     76        // Catch comment posts or approvals; check for subscriptions.
     77        add_action( 'comment_post',                   array( $this, 'comment_subscribe_submit' ),        50, 2 );
     78        add_action( 'comment_unapproved_to_approved', array( $this, 'comment_subscribe_on_transition' ), 50, 2 );
    7879    }
    7980
     
    463464
    464465    /**
    465      * Jetpack_Subscriptions::comment_subscribe_init()
    466      *
    467      * When a user checks the comment subscribe box and submits a comment, subscribe them to the comment thread.
    468      */
    469      function comment_subscribe_submit( $comment_id, $approved ) {
    470         if ( 'spam' === $approved ) {
     466    it()
     467    *
     468    * When a user checks the comment subscribe box and submits a comment, subscribe them to the comment thread.
     469    */
     470    function comment_subscribe_submit( $comment_id, $approved ) {
     471        if (
    471472            return;
    472473        }
     
    475476        $this->set_cookies( isset( $_REQUEST['subscribe_comments'] ), isset( $_REQUEST['subscribe_blog'] ) );
    476477
    477         if ( !isset( $_REQUEST['subscribe_comments'] ) && !isset( $_REQUEST['subscribe_blog'] ) )
     478        if ( !isset( $_REQUEST['subscribe_comments'] ) && !isset( $_REQUEST['subscribe_blog'] ) )
    478479            return;
    479480
     
    488489
    489490        Jetpack_Subscriptions::subscribe( $comment->comment_author_email, $post_ids );
    490      }
     491    }
     492
     493    function comment_subscribe_on_transition( $comment_id, $comment ) {
     494        if ( ! is_object( $comment ) )
     495            return;
     496           
     497        Jetpack_Subscriptions::comment_subscribe_submit( (int) $comment_id, $comment->comment_approved );
     498    }
    491499
    492500    /**
Note: See TracChangeset for help on using the changeset viewer.