Plugin Directory

Changeset 606991

Timestamp:
10/02/2012 02:24:11 PM (12 years ago)
Author:
daniloercoli
Message:

Synch comments with the backend even if the Subscriptions module is not active. We need to synch them for mobile push notifications.

Location:
jetpack/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • jetpack/trunk/jetpack.php

    r605350 r606991  
    204204        add_action( 'customize_controls_enqueue_scripts', array( $this, 'devicepx' ) );
    205205        add_action( 'admin_enqueue_scripts', array( $this, 'devicepx' ) );
    206     }
    207 
     206       
     207        //Mobile comment push notifications
     208        add_action( 'wp_insert_comment', array( $this, 'save_comment' ) , 10, 2  );
     209    }
     210   
     211    /**
     212     *  Synch comment with the .COM backend.
     213     */
     214    function save_comment( $id, $comment ) {
     215       
     216        $post = $this->get_post( $comment->comment_post_ID );
     217
     218        if ( $this->is_post_public( $post ) === false )
     219            return;
     220
     221        /*if ( ! Jetpack_Subscriptions::post_is_public( $comment->comment_post_ID ) ) {
     222            return;
     223        }*/
     224       
     225        if ( 'spam' === $comment->comment_approved ) {
     226            return;
     227        }
     228       
     229        $this->sync->comment( $id );
     230    }
     231   
    208232    /**
    209233     * Device Pixels support
  • jetpack/trunk/modules/subscriptions.php

    r603548 r606991  
    5656
    5757        // Handle Comments
    58         add_action( 'wp_insert_comment', array( $this, 'save_comment' ), 10, 2 );
    5958        add_action( 'transition_comment_status', array( $this, 'transition_comment_status' ), 10, 3 );
    6059        add_action( 'trashed_comment', array( $this, 'delete_comment' ) );
     
    121120        if ( 'post' == $the_post->post_type || 'page' == $the_post->post_type )
    122121            $this->jetpack->sync->delete_post( $id );
    123     }
    124 
    125     function save_comment( $id, $comment ) {
    126         if ( !$this->post_is_public( $comment->comment_post_ID ) ) {
    127             return;
    128         }
    129 
    130         if ( 'spam' === $comment->comment_approved ) {
    131             return;
    132         }
    133        
    134         $this->jetpack->sync->comment( $id );
    135122    }
    136123
Note: See TracChangeset for help on using the changeset viewer.