Plugin Directory

Changeset 690769


Ignore:
Timestamp:
04/02/2013 07:35:35 PM (13 years ago)
Author:
gibrown
Message:

Notifications: add the post types to sync after WP init.

  • custom post types need to be registered so we can trigger syncing them
  • don't use get_post_types() in a loop since that causes multiple calls.


File:
1 edited

Legend:

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

    r685049 r690769  
    4444
    4545        add_action( 'init', array( &$this, 'action_init' ) );
    46 
    47         //post types that support comments
    48         $filt_post_types = array();
    49         foreach ( get_post_types() as $post_type ) {
    50             if ( post_type_supports( $post_type, 'comments' ) ) {
    51                 $filt_post_types[] = $post_type;
    52             }
    53         }
    54 
    55         Jetpack_Sync::sync_posts( __FILE__, array(
    56             'post_types' => $filt_post_types,
    57             'post_stati' => array( 'publish' ),
    58         ) );
    59         Jetpack_Sync::sync_comments( __FILE__, array(
    60             'post_types' => $filt_post_types,
    61             'post_stati' => array( 'publish' ),
    62             'comment_stati' => array( 'approve', 'approved', '1', 'hold', 'unapproved', 'unapprove', '0', 'spam', 'trash' ),
    63         ) );
    6446    }
    6547
     
    10688
    10789    function action_init() {
     90        //syncing must wait until after init so
     91        //post types that support comments
     92        $filt_post_types = array();
     93        $all_post_types = get_post_types();
     94        foreach ( $all_post_types as $post_type ) {
     95            if ( post_type_supports( $post_type, 'comments' ) ) {
     96                $filt_post_types[] = $post_type;
     97            }
     98        }
     99
     100        Jetpack_Sync::sync_posts( __FILE__, array(
     101            'post_types' => $filt_post_types,
     102            'post_stati' => array( 'publish' ),
     103        ) );
     104        Jetpack_Sync::sync_comments( __FILE__, array(
     105            'post_types' => $filt_post_types,
     106            'post_stati' => array( 'publish' ),
     107            'comment_stati' => array( 'approve', 'approved', '1', 'hold', 'unapproved', 'unapprove', '0', 'spam', 'trash' ),
     108        ) );
     109
    108110        if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
    109111            return;
Note: See TracChangeset for help on using the changeset viewer.