mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Multisite: Only update a site's post
count when post types of post
are updated.
Previously, the query to update the count of published posts would run every time any post type transitioned between a `publish`/non-published status or was deleted. Props sboisvert, JPry, spacedmonkey. Fixes #42021. Built from https://develop.svn.wordpress.org/trunk@41665 git-svn-id: http://core.svn.wordpress.org/trunk@41499 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b47cf7330c
commit
78880a6a0b
@ -1285,7 +1285,7 @@ function _update_blog_date_on_post_delete( $post_id ) {
|
||||
function _update_posts_count_on_delete( $post_id ) {
|
||||
$post = get_post( $post_id );
|
||||
|
||||
if ( ! $post || 'publish' !== $post->post_status ) {
|
||||
if ( ! $post || 'publish' !== $post->post_status || 'post' !== $post->post_type ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1296,15 +1296,21 @@ function _update_posts_count_on_delete( $post_id ) {
|
||||
* Handler for updating the blog posts count date when a post status changes.
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @since 4.9.0 Added the `$post` parameter.
|
||||
*
|
||||
* @param string $new_status The status the post is changing to.
|
||||
* @param string $old_status The status the post is changing from.
|
||||
* @param string $new_status The status the post is changing to.
|
||||
* @param string $old_status The status the post is changing from.
|
||||
* @param WP_Post $post Post object
|
||||
*/
|
||||
function _update_posts_count_on_transition_post_status( $new_status, $old_status ) {
|
||||
function _update_posts_count_on_transition_post_status( $new_status, $old_status, $post = null ) {
|
||||
if ( $new_status === $old_status ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'post' !== get_post_type( $post ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'publish' !== $new_status && 'publish' !== $old_status ) {
|
||||
return;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ add_filter( 'term_id_filter', 'global_terms', 10, 2 );
|
||||
add_action( 'delete_post', '_update_posts_count_on_delete' );
|
||||
add_action( 'delete_post', '_update_blog_date_on_post_delete' );
|
||||
add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 );
|
||||
add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 2 );
|
||||
add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 );
|
||||
|
||||
// Counts
|
||||
add_action( 'admin_init', 'wp_schedule_update_network_counts');
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9-alpha-41664';
|
||||
$wp_version = '4.9-alpha-41665';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user