Skip to content

Commit

Permalink
Multisite: After [37918] add support for retrieving custom site prope…
Browse files Browse the repository at this point in the history
…rties set by the `site_details` filter.

The behaviour was previously possible with the `blog_details` filter and `get_blog_details()` function. The former is deprecated since [38936].
This change adjusts the magic methods of `WP_Site` to also check if `$key` exists in `WP_Site::get_details()`. 

Fixes #40458.
Built from https://develop.svn.wordpress.org/trunk@40478


git-svn-id: http://core.svn.wordpress.org/trunk@40354 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
ocean90 committed Apr 19, 2017
1 parent ebf0b9e commit 7977451
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion wp-includes/class-wp-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,15 @@ public function __get( $key ) {
case 'siteurl':
case 'post_count':
case 'home':
default: // Custom properties added by 'site_details' filter.
if ( ! did_action( 'ms_loaded' ) ) {
return null;
}

$details = $this->get_details();
return $details->$key;
if ( isset( $details->$key ) ) {
return $details->$key;
}
}

return null;
Expand Down Expand Up @@ -275,6 +279,15 @@ public function __isset( $key ) {
return false;
}
return true;
default: // Custom properties added by 'site_details' filter.
if ( ! did_action( 'ms_loaded' ) ) {
return false;
}

$details = $this->get_details();
if ( isset( $details->$key ) ) {
return true;
}
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-alpha-40477';
$wp_version = '4.8-alpha-40478';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down

0 comments on commit 7977451

Please sign in to comment.