Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: update_post_term_count_statuses

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
3902
3903      /**
3904       * Filters the post statuses for updating the term count.
3905       *
3906       * @since 5.7.0
3907       *
3908       * @param string[]    $post_statuses List of post statuses to include in the count. Default is 'publish'.
3909       * @param WP_Taxonomy $taxonomy      Current taxonomy object.
3910       */
3911      $post_statuses = esc_sql( apply_filters( 'update_post_term_count_statuses', $post_statuses, $taxonomy ) );
3912
3913      foreach ( (array) $terms as $term ) {
3914           $count = 0;
3915
3916           // Attachments can be 'inherit' status, we need to base count off the parent's status if so.
3917           if ( $check_attachments ) {
3918                // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.QuotedDynamicPlaceholderGeneration
3919                $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 IN ('" . implode( "', '", $post_statuses ) . "') OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) IN ('" . implode( "', '", $post_statuses ) . "') ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) );
3920           }