Make WordPress Core

Ticket #17548: 17548-2.diff

File 17548-2.diff, 2.3 KB (added by joehoyle, 13 years ago)
  • wp-includes/default-filters.php

     
    252252add_action( 'publish_post',               '_publish_post_hook',       5, 1 );
    253253add_action( 'save_post',                  '_save_post_hook',          5, 2 );
    254254add_action( 'transition_post_status',     '_transition_post_status',  5, 3 );
     255add_action( 'transition_post_status',     '_update_term_count_on_transition_post_status',  10, 3 );
    255256add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce'        );
    256257add_action( 'wp_scheduled_delete',        'wp_scheduled_delete'            );
    257258add_action( 'admin_init',                 'send_frame_options_header', 10, 0 );
  • wp-includes/post.php

     
    27262726        $post->post_status = 'publish';
    27272727        wp_transition_post_status('publish', $old_status, $post);
    27282728
    2729         // Update counts for the post's terms.
    2730         foreach ( (array) get_object_taxonomies('post') as $taxonomy ) {
    2731                 $tt_ids = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'tt_ids'));
    2732                 wp_update_term_count($tt_ids, $taxonomy);
    2733         }
    2734 
    27352729        do_action('edit_post', $post_id, $post);
    27362730        do_action('save_post', $post_id, $post);
    27372731        do_action('wp_insert_post', $post_id, $post);
     
    52935287}
    52945288add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' );
    52955289
     5290/**
     5291 * Update the custom taxonomies' term counts when a post's status is changed. For example, default posts term counts (for custom taxonomies) don't include private / draft posts.
     5292 *
     5293 * @access private
     5294 * @param string $new_status
     5295 * @param string $old_status
     5296 * @param object $post
     5297 */
     5298function _update_term_count_on_transition_post_status( $new_status, $old_status, $post ) {
     5299        exit;
     5300        // Update counts for the post's terms.
     5301        foreach ( (array) get_object_taxonomies( $post->post_type ) as $taxonomy ) {
     5302                if( empty( get_taxonomy( $taxonomy )->update_count_callback ) )
     5303                        continue;
     5304       
     5305                $tt_ids = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'tt_ids ') );
     5306                wp_update_term_count( $tt_ids, $taxonomy );
     5307        }
     5308
     5309}
    52965310?>