Make WordPress Core


Ignore:
Timestamp:
04/19/2017 06:51:25 PM (10 years ago)
Author:
ocean90
Message:

Multisite: After [37918] add support for retrieving custom site properties 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-site.php

    r40344 r40478  
    241241                        case 'post_count':
    242242                        case 'home':
     243                        default: // Custom properties added by 'site_details' filter.
    243244                                if ( ! did_action( 'ms_loaded' ) ) {
    244245                                        return null;
    245246                                }
     247
    246248                                $details = $this->get_details();
    247                                 return $details->$key;
     249                                if ( isset( $details->$key ) ) {
     250                                        return $details->$key;
     251                                }
    248252                }
    249253
    … …  
    276280                                }
    277281                                return true;
     282                        default: // Custom properties added by 'site_details' filter.
     283                                if ( ! did_action( 'ms_loaded' ) ) {
     284                                        return false;
     285                                }
     286
     287                                $details = $this->get_details();
     288                                if ( isset( $details->$key ) ) {
     289                                        return true;
     290                                }
    278291                }
    279292
Note: See TracChangeset for help on using the changeset viewer.