Make WordPress Core

Ticket #17548: recount.diff

File recount.diff, 2.4 KB (added by momo360modena, 13 years ago)

Recount all the time !

  • wp-includes/default-filters.php

    ### Eclipse Workspace Patch 1.0
    #P WPtrunk
     
    254254add_action( 'publish_post',               '_publish_post_hook',                       5, 1 );
    255255add_action( 'save_post',                  '_save_post_hook',                          5, 2 );
    256256add_action( 'transition_post_status',     '_transition_post_status',                  5, 3 );
     257add_action( 'transition_post_status',     'wp_recount_term_on_post_transition',      10, 3 );
    257258add_action( 'comment_form',               'wp_comment_form_unfiltered_html_nonce'          );
    258259add_action( 'wp_scheduled_delete',        'wp_scheduled_delete'                            );
    259260add_action( 'admin_init',                 'send_frame_options_header',               10, 0 );
  • wp-includes/post.php

     
    27302730        $old_status = $post->post_status;
    27312731        $post->post_status = 'publish';
    27322732        wp_transition_post_status('publish', $old_status, $post);
    2733 
    2734         // Update counts for the post's terms.
    2735         foreach ( (array) get_object_taxonomies('post') as $taxonomy ) {
    2736                 $tt_ids = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'tt_ids'));
    2737                 wp_update_term_count($tt_ids, $taxonomy);
    2738         }
    2739 
     2733       
    27402734        do_action('edit_post', $post_id, $post);
    27412735        do_action('save_post', $post_id, $post);
    27422736        do_action('wp_insert_post', $post_id, $post);
     
    29792973        do_action("{$new_status}_{$post->post_type}", $post->ID, $post);
    29802974}
    29812975
     2976/**
     2977 * Call update term counter callback for each post transition. (TODO: to improve)
     2978 *
     2979 * @since 3.3
     2980 *
     2981 * @param string $new_status Transition to this post status.
     2982 * @param string $old_status Previous post status.
     2983 * @param object $post Post data.
     2984 */
     2985function wp_recount_term_on_post_transition( $new_status, $old_status, $post ) {
     2986        if ( !apply_filters('recount_term_on_post_transition', true, $new_status, $old_status, $post) ) {
     2987                return false;
     2988        }
     2989       
     2990        foreach ( (array) get_object_taxonomies( $post->post_type ) as $taxonomy ) {
     2991                $tt_ids = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'tt_ids'));
     2992                wp_update_term_count($tt_ids, $taxonomy);
     2993        }
     2994       
     2995        return true;
     2996}
     2997
    29822998//
    29832999// Trackback and ping functions
    29843000//