4 * Site/blog functions that work with the blogs table and related data.
7 * @subpackage Multisite
12 * Update the last_updated field for the current blog.
16 function wpmu_update_blogs_date() {
19 update_blog_details( $wpdb->blogid, array('last_updated' => current_time('mysql', true)) );
21 * Fires after the blog details are updated.
25 * @param int $blog_id Blog ID.
27 do_action( 'wpmu_blog_updated', $wpdb->blogid );
31 * Get a full blog URL, given a blog id.
35 * @param int $blog_id Blog ID
36 * @return string Full URL of the blog if found. Empty string if not.
38 function get_blogaddress_by_id( $blog_id ) {
39 $bloginfo = get_blog_details( (int) $blog_id, false ); // only get bare details!
40 return ( $bloginfo ) ? esc_url( 'http://' . $bloginfo->domain . $bloginfo->path ) : '';
44 * Get a full blog URL, given a blog name.
48 * @param string $blogname The (subdomain or directory) name
51 function get_blogaddress_by_name( $blogname ) {
52 if ( is_subdomain_install() ) {
53 if ( $blogname == 'main' )
55 $url = rtrim( network_home_url(), '/' );
56 if ( !empty( $blogname ) )
57 $url = preg_replace( '|^([^\.]+://)|', "\${1}" . $blogname . '.', $url );
59 $url = network_home_url( $blogname );
61 return esc_url( $url . '/' );
65 * Given a blog's (subdomain or directory) slug, retrieve its id.
70 * @return int A blog id
72 function get_id_from_blogname( $slug ) {
75 $current_site = get_current_site();
76 $slug = trim( $slug, '/' );
78 $blog_id = wp_cache_get( 'get_id_from_blogname_' . $slug, 'blog-details' );
82 if ( is_subdomain_install() ) {
83 $domain = $slug . '.' . $current_site->domain;
84 $path = $current_site->path;
86 $domain = $current_site->domain;
87 $path = $current_site->path . $slug . '/';
90 $blog_id = $wpdb->get_var( $wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $domain, $path) );
91 wp_cache_set( 'get_id_from_blogname_' . $slug, $blog_id, 'blog-details' );
96 * Retrieve the details for a blog from the blogs table and blog options.
100 * @param int|string|array $fields A blog ID, a blog slug, or an array of fields to query against. Optional. If not specified the current blog ID is used.
101 * @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true.
102 * @return object|false Blog details on success. False on failure.
104 function get_blog_details( $fields = null, $get_all = true ) {
107 if ( is_array($fields ) ) {
108 if ( isset($fields['blog_id']) ) {
109 $blog_id = $fields['blog_id'];
110 } elseif ( isset($fields['domain']) && isset($fields['path']) ) {
111 $key = md5( $fields['domain'] . $fields['path'] );
112 $blog = wp_cache_get($key, 'blog-lookup');
113 if ( false !== $blog )
115 if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
116 $nowww = substr( $fields['domain'], 4 );
117 $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) );
119 $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'] ) );
122 wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
123 $blog_id = $blog->blog_id;
127 } elseif ( isset($fields['domain']) && is_subdomain_install() ) {
128 $key = md5( $fields['domain'] );
129 $blog = wp_cache_get($key, 'blog-lookup');
130 if ( false !== $blog )
132 if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
133 $nowww = substr( $fields['domain'], 4 );
134 $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'] ) );
136 $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'] ) );
139 wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
140 $blog_id = $blog->blog_id;
149 $blog_id = get_current_blog_id();
150 elseif ( ! is_numeric( $fields ) )
151 $blog_id = get_id_from_blogname( $fields );
156 $blog_id = (int) $blog_id;
158 $all = $get_all == true ? '' : 'short';
159 $details = wp_cache_get( $blog_id . $all, 'blog-details' );
162 if ( ! is_object( $details ) ) {
163 if ( $details == -1 ) {
166 // Clear old pre-serialized objects. Cache clients do better with that.
167 wp_cache_delete( $blog_id . $all, 'blog-details' );
175 // Try the other cache.
177 $details = wp_cache_get( $blog_id . 'short', 'blog-details' );
179 $details = wp_cache_get( $blog_id, 'blog-details' );
180 // If short was requested and full cache is set, we can return.
182 if ( ! is_object( $details ) ) {
183 if ( $details == -1 ) {
186 // Clear old pre-serialized objects. Cache clients do better with that.
187 wp_cache_delete( $blog_id, 'blog-details' );
196 if ( empty($details) ) {
197 $details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE blog_id = %d /* get_blog_details */", $blog_id ) );
199 // Set the full cache.
200 wp_cache_set( $blog_id, -1, 'blog-details' );
206 wp_cache_set( $blog_id . $all, $details, 'blog-details' );
210 switch_to_blog( $blog_id );
211 $details->blogname = get_option( 'blogname' );
212 $details->siteurl = get_option( 'siteurl' );
213 $details->post_count = get_option( 'post_count' );
214 restore_current_blog();
217 * Filter a blog's details.
221 * @param object $details The blog details.
223 $details = apply_filters( 'blog_details', $details );
225 wp_cache_set( $blog_id . $all, $details, 'blog-details' );
227 $key = md5( $details->domain . $details->path );
228 wp_cache_set( $key, $details, 'blog-lookup' );
234 * Clear the blog details cache.
238 * @param int $blog_id Optional. Blog ID. Defaults to current blog.
240 function refresh_blog_details( $blog_id = 0 ) {
241 $blog_id = (int) $blog_id;
243 $blog_id = get_current_blog_id();
246 $details = get_blog_details( $blog_id, false );
248 // Make sure clean_blog_cache() gets the blog ID
249 // when the blog has been previously cached as
251 $details = (object) array(
252 'blog_id' => $blog_id,
258 clean_blog_cache( $details );
261 * Fires after the blog details cache is cleared.
265 * @param int $blog_id Blog ID.
267 do_action( 'refresh_blog_details', $blog_id );
271 * Update the details for a blog. Updates the blogs table for a given blog id.
275 * @param int $blog_id Blog ID
276 * @param array $details Array of details keyed by blogs table field names.
277 * @return bool True if update succeeds, false otherwise.
279 function update_blog_details( $blog_id, $details = array() ) {
282 if ( empty($details) )
285 if ( is_object($details) )
286 $details = get_object_vars($details);
288 $current_details = get_blog_details($blog_id, false);
289 if ( empty($current_details) )
292 $current_details = get_object_vars($current_details);
294 $details = array_merge($current_details, $details);
295 $details['last_updated'] = current_time('mysql', true);
297 $update_details = array();
298 $fields = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id');
299 foreach ( array_intersect( array_keys( $details ), $fields ) as $field ) {
300 if ( 'path' === $field ) {
301 $details[ $field ] = trailingslashit( '/' . trim( $details[ $field ], '/' ) );
304 $update_details[ $field ] = $details[ $field ];
307 $result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) );
309 if ( false === $result )
312 // If spam status changed, issue actions.
313 if ( $details['spam'] != $current_details['spam'] ) {
314 if ( $details['spam'] == 1 ) {
316 * Fires when the blog status is changed to 'spam'.
320 * @param int $blog_id Blog ID.
322 do_action( 'make_spam_blog', $blog_id );
325 * Fires when the blog status is changed to 'ham'.
329 * @param int $blog_id Blog ID.
331 do_action( 'make_ham_blog', $blog_id );
335 // If mature status changed, issue actions.
336 if ( $details['mature'] != $current_details['mature'] ) {
337 if ( $details['mature'] == 1 ) {
339 * Fires when the blog status is changed to 'mature'.
343 * @param int $blog_id Blog ID.
345 do_action( 'mature_blog', $blog_id );
348 * Fires when the blog status is changed to 'unmature'.
352 * @param int $blog_id Blog ID.
354 do_action( 'unmature_blog', $blog_id );
358 // If archived status changed, issue actions.
359 if ( $details['archived'] != $current_details['archived'] ) {
360 if ( $details['archived'] == 1 ) {
362 * Fires when the blog status is changed to 'archived'.
366 * @param int $blog_id Blog ID.
368 do_action( 'archive_blog', $blog_id );
371 * Fires when the blog status is changed to 'unarchived'.
375 * @param int $blog_id Blog ID.
377 do_action( 'unarchive_blog', $blog_id );
381 // If deleted status changed, issue actions.
382 if ( $details['deleted'] != $current_details['deleted'] ) {
383 if ( $details['deleted'] == 1 ) {
385 * Fires when the blog status is changed to 'deleted'.
389 * @param int $blog_id Blog ID.
391 do_action( 'make_delete_blog', $blog_id );
394 * Fires when the blog status is changed to 'undeleted'.
398 * @param int $blog_id Blog ID.
400 do_action( 'make_undelete_blog', $blog_id );
404 if ( isset( $details['public'] ) ) {
405 switch_to_blog( $blog_id );
406 update_option( 'blog_public', $details['public'] );
407 restore_current_blog();
410 refresh_blog_details($blog_id);
416 * Clean the blog cache
420 * @param stdClass $blog The blog details as returned from get_blog_details()
422 function clean_blog_cache( $blog ) {
423 $blog_id = $blog->blog_id;
424 $domain_path_key = md5( $blog->domain . $blog->path );
426 wp_cache_delete( $blog_id , 'blog-details' );
427 wp_cache_delete( $blog_id . 'short' , 'blog-details' );
428 wp_cache_delete( $domain_path_key, 'blog-lookup' );
429 wp_cache_delete( 'current_blog_' . $blog->domain, 'site-options' );
430 wp_cache_delete( 'current_blog_' . $blog->domain . $blog->path, 'site-options' );
431 wp_cache_delete( 'get_id_from_blogname_' . trim( $blog->path, '/' ), 'blog-details' );
432 wp_cache_delete( $domain_path_key, 'blog-id-cache' );
436 * Retrieve option value for a given blog id based on name of option.
438 * If the option does not exist or does not have a value, then the return value
439 * will be false. This is useful to check whether you need to install an option
440 * and is commonly used during installation of plugin options and to test
441 * whether upgrading is required.
443 * If the option was serialized then it will be unserialized when it is returned.
447 * @param int $id A blog ID. Can be null to refer to the current blog.
448 * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
449 * @param mixed $default Optional. Default value to return if the option does not exist.
450 * @return mixed Value set for the option.
452 function get_blog_option( $id, $option, $default = false ) {
456 $id = get_current_blog_id();
458 if ( get_current_blog_id() == $id )
459 return get_option( $option, $default );
461 switch_to_blog( $id );
462 $value = get_option( $option, $default );
463 restore_current_blog();
466 * Filter a blog option value.
468 * The dynamic portion of the hook name, `$option`, refers to the blog option name.
472 * @param string $value The option value.
473 * @param int $id Blog ID.
475 return apply_filters( "blog_option_{$option}", $value, $id );
479 * Add a new option for a given blog id.
481 * You do not need to serialize values. If the value needs to be serialized, then
482 * it will be serialized before it is inserted into the database. Remember,
483 * resources can not be serialized or added as an option.
485 * You can create options without values and then update the values later.
486 * Existing options will not be updated and checks are performed to ensure that you
487 * aren't adding a protected WordPress option. Care should be taken to not name
488 * options the same as the ones which are protected.
492 * @param int $id A blog ID. Can be null to refer to the current blog.
493 * @param string $option Name of option to add. Expected to not be SQL-escaped.
494 * @param mixed $value Optional. Option value, can be anything. Expected to not be SQL-escaped.
495 * @return bool False if option was not added and true if option was added.
497 function add_blog_option( $id, $option, $value ) {
501 $id = get_current_blog_id();
503 if ( get_current_blog_id() == $id )
504 return add_option( $option, $value );
506 switch_to_blog( $id );
507 $return = add_option( $option, $value );
508 restore_current_blog();
514 * Removes option by name for a given blog id. Prevents removal of protected WordPress options.
518 * @param int $id A blog ID. Can be null to refer to the current blog.
519 * @param string $option Name of option to remove. Expected to not be SQL-escaped.
520 * @return bool True, if option is successfully deleted. False on failure.
522 function delete_blog_option( $id, $option ) {
526 $id = get_current_blog_id();
528 if ( get_current_blog_id() == $id )
529 return delete_option( $option );
531 switch_to_blog( $id );
532 $return = delete_option( $option );
533 restore_current_blog();
539 * Update an option for a particular blog.
543 * @param int $id The blog id
544 * @param string $option The option key
545 * @param mixed $value The option value
546 * @return bool True on success, false on failure.
548 function update_blog_option( $id, $option, $value, $deprecated = null ) {
551 if ( null !== $deprecated )
552 _deprecated_argument( __FUNCTION__, '3.1' );
554 if ( get_current_blog_id() == $id )
555 return update_option( $option, $value );
557 switch_to_blog( $id );
558 $return = update_option( $option, $value );
559 restore_current_blog();
561 refresh_blog_details( $id );
567 * Switch the current blog.
569 * This function is useful if you need to pull posts, or other information,
570 * from other blogs. You can switch back afterwards using restore_current_blog().
572 * Things that aren't switched:
573 * - autoloaded options. See #14992
574 * - plugins. See #14941
576 * @see restore_current_blog()
579 * @param int $new_blog The id of the blog you want to switch to. Default: current blog
580 * @param bool $deprecated Deprecated argument
581 * @return bool Always returns True.
583 function switch_to_blog( $new_blog, $deprecated = null ) {
584 global $wpdb, $wp_roles;
586 if ( empty( $new_blog ) )
587 $new_blog = $GLOBALS['blog_id'];
589 $GLOBALS['_wp_switched_stack'][] = $GLOBALS['blog_id'];
592 * If we're switching to the same blog id that we're on,
593 * set the right vars, do the associated actions, but skip
594 * the extra unnecessary work
596 if ( $new_blog == $GLOBALS['blog_id'] ) {
598 * Fires when the blog is switched.
602 * @param int $new_blog New blog ID.
603 * @param int $new_blog Blog ID.
605 do_action( 'switch_blog', $new_blog, $new_blog );
606 $GLOBALS['switched'] = true;
610 $wpdb->set_blog_id( $new_blog );
611 $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
612 $prev_blog_id = $GLOBALS['blog_id'];
613 $GLOBALS['blog_id'] = $new_blog;
615 if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
616 wp_cache_switch_to_blog( $new_blog );
618 global $wp_object_cache;
620 if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
621 $global_groups = $wp_object_cache->global_groups;
623 $global_groups = false;
627 if ( function_exists( 'wp_cache_add_global_groups' ) ) {
628 if ( is_array( $global_groups ) ) {
629 wp_cache_add_global_groups( $global_groups );
631 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache' ) );
633 wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
637 if ( did_action( 'init' ) ) {
639 $current_user = wp_get_current_user();
640 $current_user->for_blog( $new_blog );
643 /** This filter is documented in wp-includes/ms-blogs.php */
644 do_action( 'switch_blog', $new_blog, $prev_blog_id );
645 $GLOBALS['switched'] = true;
651 * Restore the current blog, after calling switch_to_blog()
653 * @see switch_to_blog()
656 * @return bool True on success, false if we're already on the current blog
658 function restore_current_blog() {
659 global $wpdb, $wp_roles;
661 if ( empty( $GLOBALS['_wp_switched_stack'] ) )
664 $blog = array_pop( $GLOBALS['_wp_switched_stack'] );
666 if ( $GLOBALS['blog_id'] == $blog ) {
667 /** This filter is documented in wp-includes/ms-blogs.php */
668 do_action( 'switch_blog', $blog, $blog );
669 // If we still have items in the switched stack, consider ourselves still 'switched'
670 $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
674 $wpdb->set_blog_id( $blog );
675 $prev_blog_id = $GLOBALS['blog_id'];
676 $GLOBALS['blog_id'] = $blog;
677 $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
679 if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
680 wp_cache_switch_to_blog( $blog );
682 global $wp_object_cache;
684 if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
685 $global_groups = $wp_object_cache->global_groups;
687 $global_groups = false;
691 if ( function_exists( 'wp_cache_add_global_groups' ) ) {
692 if ( is_array( $global_groups ) ) {
693 wp_cache_add_global_groups( $global_groups );
695 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache' ) );
697 wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
701 if ( did_action( 'init' ) ) {
703 $current_user = wp_get_current_user();
704 $current_user->for_blog( $blog );
707 /** This filter is documented in wp-includes/ms-blogs.php */
708 do_action( 'switch_blog', $blog, $prev_blog_id );
710 // If we still have items in the switched stack, consider ourselves still 'switched'
711 $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
717 * Determines if switch_to_blog() is in effect
721 * @return bool True if switched, false otherwise.
723 function ms_is_switched() {
724 return ! empty( $GLOBALS['_wp_switched_stack'] );
728 * Check if a particular blog is archived.
732 * @param int $id The blog id
733 * @return string Whether the blog is archived or not
735 function is_archived( $id ) {
736 return get_blog_status($id, 'archived');
740 * Update the 'archived' status of a particular blog.
744 * @param int $id The blog id
745 * @param string $archived The new status
746 * @return string $archived
748 function update_archived( $id, $archived ) {
749 update_blog_status($id, 'archived', $archived);
754 * Update a blog details field.
758 * @param int $blog_id BLog ID
759 * @param string $pref A field name
760 * @param string $value Value for $pref
761 * @return string $value
763 function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
766 if ( null !== $deprecated )
767 _deprecated_argument( __FUNCTION__, '3.1' );
769 if ( ! in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) )
772 $result = $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) );
774 if ( false === $result )
777 refresh_blog_details( $blog_id );
779 if ( 'spam' == $pref ) {
781 /** This filter is documented in wp-includes/ms-blogs.php */
782 do_action( 'make_spam_blog', $blog_id );
784 /** This filter is documented in wp-includes/ms-blogs.php */
785 do_action( 'make_ham_blog', $blog_id );
787 } elseif ( 'mature' == $pref ) {
789 /** This filter is documented in wp-includes/ms-blogs.php */
790 do_action( 'mature_blog', $blog_id );
792 /** This filter is documented in wp-includes/ms-blogs.php */
793 do_action( 'unmature_blog', $blog_id );
795 } elseif ( 'archived' == $pref ) {
797 /** This filter is documented in wp-includes/ms-blogs.php */
798 do_action( 'archive_blog', $blog_id );
800 /** This filter is documented in wp-includes/ms-blogs.php */
801 do_action( 'unarchive_blog', $blog_id );
803 } elseif ( 'deleted' == $pref ) {
805 /** This filter is documented in wp-includes/ms-blogs.php */
806 do_action( 'make_delete_blog', $blog_id );
808 /** This filter is documented in wp-includes/ms-blogs.php */
809 do_action( 'make_undelete_blog', $blog_id );
811 } elseif ( 'public' == $pref ) {
813 * Fires after the current blog's 'public' setting is updated.
817 * @param int $blog_id Blog ID.
818 * @param string $value The value of blog status.
820 do_action( 'update_blog_public', $blog_id, $value ); // Moved here from update_blog_public().
827 * Get a blog details field.
831 * @param int $id The blog id
832 * @param string $pref A field name
833 * @return bool $value
835 function get_blog_status( $id, $pref ) {
838 $details = get_blog_details( $id, false );
840 return $details->$pref;
842 return $wpdb->get_var( $wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id) );
846 * Get a list of most recently updated blogs.
850 * @param mixed $deprecated Not used
851 * @param int $start The offset
852 * @param int $quantity The maximum number of blogs to retrieve. Default is 40.
853 * @return array The list of blogs
855 function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) {
858 if ( ! empty( $deprecated ) )
859 _deprecated_argument( __FUNCTION__, 'MU' ); // never used
861 return $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity ) , ARRAY_A );
865 * Handler for updating the blog date when a post is published or an already published post is changed.
869 * @param string $new_status The new post status
870 * @param string $old_status The old post status
871 * @param object $post Post object
873 function _update_blog_date_on_post_publish( $new_status, $old_status, $post ) {
874 $post_type_obj = get_post_type_object( $post->post_type );
875 if ( ! $post_type_obj || ! $post_type_obj->public ) {
879 if ( 'publish' != $new_status && 'publish' != $old_status ) {
883 // Post was freshly published, published post was saved, or published post was unpublished.
885 wpmu_update_blogs_date();
889 * Handler for updating the blog date when a published post is deleted.
893 * @param int $post_id Post ID
895 function _update_blog_date_on_post_delete( $post_id ) {
896 $post = get_post( $post_id );
898 $post_type_obj = get_post_type_object( $post->post_type );
899 if ( ! $post_type_obj || ! $post_type_obj->public ) {
903 if ( 'publish' != $post->post_status ) {
907 wpmu_update_blogs_date();
911 * Handler for updating the blog posts count date when a post is deleted.
915 * @param int $post_id Post ID.
917 function _update_posts_count_on_delete( $post_id ) {
918 $post = get_post( $post_id );
920 if ( ! $post || 'publish' !== $post->post_status ) {
924 update_posts_count();
928 * Handler for updating the blog posts count date when a post status changes.
932 * @param string $new_status The status the post is changing to.
933 * @param string $old_status The status the post is changing from.
935 function _update_posts_count_on_transition_post_status( $new_status, $old_status ) {
936 if ( $new_status === $old_status ) {
940 if ( 'publish' !== $new_status && 'publish' !== $old_status ) {
944 update_posts_count();