- Timestamp:
- 04/19/2017 06:51:25 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-site.php
r40344 r40478 241 241 case 'post_count': 242 242 case 'home': 243 default: // Custom properties added by 'site_details' filter. 243 244 if ( ! did_action( 'ms_loaded' ) ) { 244 245 return null; 245 246 } 247 246 248 $details = $this->get_details(); 247 return $details->$key; 249 if ( isset( $details->$key ) ) { 250 return $details->$key; 251 } 248 252 } 249 253 … … 276 280 } 277 281 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 } 278 291 } 279 292 -
trunk/tests/phpunit/tests/multisite/siteDetails.php
r40344 r40478 145 145 $this->assertNotFalse( $cached_details ); 146 146 } 147 148 public function test_site_details_filter_with_blogname() { 149 add_filter( 'site_details', array( $this, '_filter_site_details_blogname' ) ); 150 $site = get_site(); 151 $blogname = $site->blogname; 152 remove_filter( 'site_details', array( $this, '_filter_site_details_blogname' ) ); 153 154 $this->assertSame( 'Foo Bar', $blogname ); 155 } 156 157 public function _filter_site_details_blogname( $details ) { 158 $details->blogname = 'Foo Bar'; 159 return $details; 160 } 161 162 /** 163 * @ticket 40458 164 */ 165 public function test_site_details_filter_with_custom_value_isetter() { 166 add_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) ); 167 $site = get_site(); 168 $custom_value_isset = isset( $site->custom_value ); 169 remove_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) ); 170 171 $this->assertTrue( $custom_value_isset ); 172 } 173 174 /** 175 * @ticket 40458 176 */ 177 public function test_site_details_filter_with_custom_value_getter() { 178 add_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) ); 179 $site = get_site(); 180 $custom_value = $site->custom_value; 181 remove_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) ); 182 183 $this->assertSame( 'foo', $custom_value ); 184 } 185 186 public function _filter_site_details_custom_value( $details ) { 187 $details->custom_value = 'foo'; 188 return $details; 189 } 147 190 } 148 191
Note: See TracChangeset
for help on using the changeset viewer.