Changeset 60711 for trunk/src/wp-includes/taxonomy.php
- Timestamp:
- 09/05/2025 01:28:20 PM (3 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/taxonomy.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r60697 r60711 4176 4176 $post_statuses = esc_sql( apply_filters( 'update_post_term_count_statuses', $post_statuses, $taxonomy ) ); 4177 4177 4178 foreach ( (array) $terms as $t erm) {4178 foreach ( (array) $terms as $tt_id ) { 4179 4179 $count = 0; 4180 4180 … … 4182 4182 if ( $check_attachments ) { 4183 4183 // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.QuotedDynamicPlaceholderGeneration 4184 $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", $t erm) );4184 $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", $tt_id ) ); 4185 4185 } 4186 4186 4187 4187 if ( $object_types ) { 4188 4188 // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.QuotedDynamicPlaceholderGeneration 4189 $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 ) ); 4190 } 4189 $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", $tt_id ) ); 4190 } 4191 4192 /** 4193 * Fires when a term count is calculated, before it is updated in the database. 4194 * 4195 * @since 6.9.0 4196 * 4197 * @param int $tt_id Term taxonomy ID. 4198 * @param string $taxonomy_name Taxonomy slug. 4199 * @param int $count Term count. 4200 */ 4201 do_action( 'update_term_count', $tt_id, $taxonomy->name, $count ); 4191 4202 4192 4203 /** This action is documented in wp-includes/taxonomy.php */ 4193 do_action( 'edit_term_taxonomy', $t erm, $taxonomy->name );4194 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $t erm) );4204 do_action( 'edit_term_taxonomy', $tt_id, $taxonomy->name ); 4205 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $tt_id ) ); 4195 4206 4196 4207 /** This action is documented in wp-includes/taxonomy.php */ 4197 do_action( 'edited_term_taxonomy', $t erm, $taxonomy->name );4208 do_action( 'edited_term_taxonomy', $tt_id, $taxonomy->name ); 4198 4209 } 4199 4210 } … … 4216 4227 foreach ( (array) $terms as $term ) { 4217 4228 $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term ) ); 4229 4230 /** This action is documented in wp-includes/taxonomy.php */ 4231 do_action( 'update_term_count', $term, $taxonomy->name, $count ); 4218 4232 4219 4233 /** This action is documented in wp-includes/taxonomy.php */
Note: See TracChangeset
for help on using the changeset viewer.