Simplify the code for calling refresh_blog_details() whenever 'blogname', 'siteurl', or 'post_count' option is updated.
props pento, nacin. fixes #26410. Built from https://develop.svn.wordpress.org/trunk@29668 git-svn-id: http://core.svn.wordpress.org/trunk@29442 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8cc6ad5066
commit
2d1cc72d7f
|
@ -235,10 +235,14 @@ function get_blog_details( $fields = null, $get_all = true ) {
|
|||
*
|
||||
* @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;
|
||||
if ( ! $blog_id ) {
|
||||
$blog_id = get_current_blog_id();
|
||||
}
|
||||
|
||||
$details = get_blog_details( $blog_id, false );
|
||||
if ( ! $details ) {
|
||||
// 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 );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
|
@ -71,7 +71,9 @@ remove_filter( 'option_siteurl', '_config_wp_siteurl' );
|
|||
remove_filter( 'option_home', '_config_wp_home' );
|
||||
|
||||
// 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.
|
||||
add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );
|
||||
|
|
Loading…
Reference in New Issue