Make WordPress Core

Ticket #38843: 38843.patch

File 38843.patch, 1.9 KB (added by GunGeekATX, 8 years ago)

Proposed patch with filter

  • wp-includes/taxonomy.php

     
    33753375                $check_attachments = true;
    33763376        }
    33773377
     3378        $post_statuses = array( 'publish' );
     3379
     3380        /**
     3381         * Filters the post statuses for updating the term count.
     3382         *
     3383         * @param array $post_statuses List of post statuses.
     3384         * @param int   $taxonomy      Current taxonomy object.
     3385         */
     3386        $post_statuses = esc_sql( apply_filters( 'update_post_term_count_statuses', $post_statuses, $taxonomy ) );
     3387
    33783388        if ( $object_types )
    33793389                $object_types = esc_sql( array_filter( $object_types, 'post_type_exists' ) );
    33803390
     
    33863396                        $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish' ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) );
    33873397
    33883398                if ( $object_types )
    3389                         $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type IN ('" . implode("', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) );
     3399                        $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status IN ('" . implode("', '", $post_statuses ) . "') AND post_type IN ('" . implode("', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) );
    33903400
    33913401                /** This action is documented in wp-includes/taxonomy.php */
    33923402                do_action( 'edit_term_taxonomy', $term, $taxonomy->name );