Changeset 37748 for trunk/src/wp-includes/compat.php
- Timestamp:
- 06/19/2016 12:24:23 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/compat.php
r37674 r37748 436 436 } 437 437 438 if ( ! function_exists( 'array_replace_recursive' ) ) : 439 /** 440 * PHP-agnostic version of {@link array_replace_recursive()}. 441 * 442 * The array_replace_recursive() function is a PHP 5.3 function. WordPress 443 * currently supports down to PHP 5.2, so this method is a workaround 444 * for PHP 5.2. 445 * 446 * Note: array_replace_recursive() supports infinite arguments, but for our use- 447 * case, we only need to support two arguments. 448 * 449 * Subject to removal once WordPress makes PHP 5.3.0 the minimum requirement. 450 * 451 * @since 4.5.3 452 * 453 * @see http://php.net/manual/en/function.array-replace-recursive.php#109390 454 * 455 * @param array $base Array with keys needing to be replaced. 456 * @param array $replacements Array with the replaced keys. 457 * 458 * @return array 459 */ 460 function array_replace_recursive( $base = array(), $replacements = array() ) { 461 foreach ( array_slice( func_get_args(), 1 ) as $replacements ) { 462 $bref_stack = array( &$base ); 463 $head_stack = array( $replacements ); 464 465 do { 466 end( $bref_stack ); 467 468 $bref = &$bref_stack[ key( $bref_stack ) ]; 469 $head = array_pop( $head_stack ); 470 471 unset( $bref_stack[ key( $bref_stack ) ] ); 472 473 foreach ( array_keys( $head ) as $key ) { 474 if ( isset( $key, $bref ) && is_array( $bref[ $key ] ) && is_array( $head[ $key ] ) ) { 475 $bref_stack[] = &$bref[ $key ]; 476 $head_stack[] = $head[ $key ]; 477 } else { 478 $bref[ $key ] = $head[ $key ]; 479 } 480 } 481 } while ( count( $head_stack ) ); 482 } 483 484 return $base; 485 } 486 endif; 487 438 488 // SPL can be disabled on PHP 5.2 439 489 if ( ! function_exists( 'spl_autoload_register' ) ):
Note: See TracChangeset
for help on using the changeset viewer.