Changeset 54670 for trunk/src/wp-includes/class-wp-block-type.php
- Timestamp:
- 10/24/2022 02:14:25 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-block-type.php
r54210 r54670 296 296 * @param string $name Deprecated property name. 297 297 * 298 * @return string| null|void The value read from the new property if the first item in the array provided,299 * null when value not found, or void when unknown property name provided.298 * @return string|string[]|null|void The value read from the new property if the first item in the array provided, 299 * null when value not found, or void when unknown property name provided. 300 300 */ 301 301 public function __get( $name ) { … … 305 305 306 306 $new_name = $name . '_handles'; 307 308 if ( ! property_exists( $this, $new_name ) || ! is_array( $this->{$new_name} ) ) { 309 return null; 310 } 311 312 if ( count( $this->{$new_name} ) > 1 ) { 313 return $this->{$new_name}; 314 } 307 315 return isset( $this->{$new_name}[0] ) ? $this->{$new_name}[0] : null; 308 316 } … … 344 352 } 345 353 354 $new_name = $name . '_handles'; 355 356 if ( is_array( $value ) ) { 357 $filtered = array_filter( $value, 'is_string' ); 358 359 if ( count( $filtered ) !== count( $value ) ) { 360 _doing_it_wrong( 361 __METHOD__, 362 sprintf( 363 /* translators: %s: The '$value' argument. */ 364 __( 'The %s argument must be a string or a string array.' ), 365 '<code>$value</code>' 366 ), 367 '6.1.0' 368 ); 369 } 370 371 $this->{$new_name} = array_values( $filtered ); 372 return; 373 } 374 346 375 if ( ! is_string( $value ) ) { 347 376 return; 348 377 } 349 378 350 $new_name = $name . '_handles'; 351 $this->{$new_name}[0] = $value; 379 $this->{$new_name} = array( $value ); 352 380 } 353 381
Note: See TracChangeset
for help on using the changeset viewer.