From bb8ca3bd5f25d6feeb7e439530abafc823e40446 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Sun, 4 Oct 2015 20:50:48 +0000 Subject: [PATCH] MS: Populate `site_name` property in a new `WP_Network`. This allows us to reduce some extra handling in `ms-settings.php`. Requires [34777]. Props johnjamesjacoby for the initial patch. See #31985. git-svn-id: https://develop.svn.wordpress.org/trunk@34819 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-network.php | 16 ++++++++++++++++ src/wp-includes/ms-settings.php | 7 ------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/class-wp-network.php b/src/wp-includes/class-wp-network.php index f40db91883..cb80ead944 100644 --- a/src/wp-includes/class-wp-network.php +++ b/src/wp-includes/class-wp-network.php @@ -129,9 +129,25 @@ class WP_Network { $this->$key = $value; } + $this->_set_site_name(); $this->_set_cookie_domain(); } + /** + * Set the site name assigned to the network if one has not been populated. + * + * @since 4.4.0 + * @access private + */ + private function _set_site_name() { + if ( ! empty( $this->site_name ) ) { + return; + } + + $default = ucfirst( $this->domain ); + $this->site_name = get_network_option( 'site_name', $default, $this->id ); + } + /** * Set the cookie domain based on the network domain if one has * not been populated. diff --git a/src/wp-includes/ms-settings.php b/src/wp-includes/ms-settings.php index 7d0fbc6207..861ee14abf 100644 --- a/src/wp-includes/ms-settings.php +++ b/src/wp-includes/ms-settings.php @@ -221,12 +221,5 @@ if ( ! $current_site instanceof WP_Network ) { $current_site = new WP_Network( $current_site ); } -if ( empty( $current_site->site_name ) ) { - $current_site->site_name = get_network_option( 'site_name' ); - if ( ! $current_site->site_name ) { - $current_site->site_name = ucfirst( $current_site->domain ); - } -} - // Define upload directory constants ms_upload_constants();