Simplify the code for calling refresh_blog_details() whenever 'blogname', 'siteurl', or 'post_count' option is updated.
props pento, nacin. fixes #26410. git-svn-id: https://develop.svn.wordpress.org/trunk@29668 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
52dacfd3a5
commit
fb8548fd48
|
@ -235,10 +235,14 @@ function get_blog_details( $fields = null, $get_all = true ) {
|
||||||
*
|
*
|
||||||
* @since MU
|
* @since MU
|
||||||
*
|
*
|
||||||
* @param int $blog_id Blog ID
|
* @param int $blog_id Optional. Blog ID. Defaults to current blog.
|
||||||
*/
|
*/
|
||||||
function refresh_blog_details( $blog_id ) {
|
function refresh_blog_details( $blog_id = 0 ) {
|
||||||
$blog_id = (int) $blog_id;
|
$blog_id = (int) $blog_id;
|
||||||
|
if ( ! $blog_id ) {
|
||||||
|
$blog_id = get_current_blog_id();
|
||||||
|
}
|
||||||
|
|
||||||
$details = get_blog_details( $blog_id, false );
|
$details = get_blog_details( $blog_id, false );
|
||||||
if ( ! $details ) {
|
if ( ! $details ) {
|
||||||
// Make sure clean_blog_cache() gets the blog ID
|
// Make sure clean_blog_cache() gets the blog ID
|
||||||
|
@ -263,19 +267,6 @@ function refresh_blog_details( $blog_id ) {
|
||||||
do_action( 'refresh_blog_details', $blog_id );
|
do_action( 'refresh_blog_details', $blog_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Refresh blog details when an option is updated.
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @param string $option_name
|
|
||||||
*/
|
|
||||||
function _wp_refresh_blog_details_on_updated_option( $option_name ) {
|
|
||||||
$options = array( 'blogname', 'siteurl', 'post_count' );
|
|
||||||
if ( in_array( $option_name, $options ) ) {
|
|
||||||
refresh_blog_details( get_current_blog_id() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the details for a blog. Updates the blogs table for a given blog id.
|
* Update the details for a blog. Updates the blogs table for a given blog id.
|
||||||
*
|
*
|
||||||
|
|
|
@ -71,7 +71,9 @@ remove_filter( 'option_siteurl', '_config_wp_siteurl' );
|
||||||
remove_filter( 'option_home', '_config_wp_home' );
|
remove_filter( 'option_home', '_config_wp_home' );
|
||||||
|
|
||||||
// Some options changes should trigger blog details refresh.
|
// Some options changes should trigger blog details refresh.
|
||||||
add_action( 'updated_option', '_wp_refresh_blog_details_on_updated_option' );
|
add_action( 'update_option_blogname', 'refresh_blog_details', 10, 0 );
|
||||||
|
add_action( 'update_option_siteurl', 'refresh_blog_details', 10, 0 );
|
||||||
|
add_action( 'update_option_post_count', 'refresh_blog_details', 10, 0 );
|
||||||
|
|
||||||
// If the network upgrade hasn't run yet, assume ms-files.php rewriting is used.
|
// If the network upgrade hasn't run yet, assume ms-files.php rewriting is used.
|
||||||
add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );
|
add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );
|
||||||
|
|
Loading…
Reference in New Issue