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
3978
3979      /**
3980       * Filters the post statuses for updating the term count.
3981       *
3982       * @since 5.7.0
3983       *
3984       * @param string[]    $post_statuses List of post statuses to include in the count. Default is 'publish'.
3985       * @param WP_Taxonomy $taxonomy      Current taxonomy object.
3986       */
3987      $post_statuses = esc_sql( apply_filters( 'update_post_term_count_statuses', $post_statuses, $taxonomy ) );
3988
3989      foreach ( (array) $terms as $term ) {
3990           $count = 0;
3991
3992           // Attachments can be 'inherit' status, we need to base count off the parent's status if so.
3993           if ( $check_attachments ) {
3994                // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.QuotedDynamicPlaceholderGeneration
3995                $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 ) );
3996           }