diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index 05acf4e..f5551cb 100644
|
a
|
b
|
|
| 2585 | 2585 | /** |
| 2586 | 2586 | * Merge user defined arguments into defaults array. |
| 2587 | 2587 | * |
| 2588 | | * This function is used throughout WordPress to allow for both string or array |
| 2589 | | * to be merged into another array. |
| | 2588 | * This function is used throughout WordPress to allow for either a string or |
| | 2589 | * array to be merged into another array. It allows for arguments to be |
| | 2590 | * passively or aggressively filtered using the optional $filter_key parameter. |
| | 2591 | * If no $filter_key is passed, no filters are applied. |
| 2590 | 2592 | * |
| 2591 | 2593 | * @since 2.2.0 |
| 2592 | 2594 | * |
| 2593 | 2595 | * @param string|array $args Value to merge with $defaults |
| 2594 | | * @param array $defaults Array that serves as the defaults. |
| 2595 | | * @return array Merged user defined values with defaults. |
| | 2596 | * @param array $defaults Array that serves as the defaults |
| | 2597 | * @param string $filter_key String to key the filters from |
| | 2598 | * @return array Merged user defined values with defaults |
| 2596 | 2599 | */ |
| 2597 | | function wp_parse_args( $args, $defaults = '' ) { |
| 2598 | | if ( is_object( $args ) ) |
| 2599 | | $r = get_object_vars( $args ); |
| 2600 | | elseif ( is_array( $args ) ) |
| 2601 | | $r =& $args; |
| 2602 | | else |
| 2603 | | wp_parse_str( $args, $r ); |
| | 2600 | function wp_parse_args( $args, $defaults = '', $filter_key = '' ) { |
| 2604 | 2601 | |
| 2605 | | if ( is_array( $defaults ) ) |
| 2606 | | return array_merge( $defaults, $r ); |
| | 2602 | // Setup a temporary array from $args |
| | 2603 | if ( is_object( $args ) ) { |
| | 2604 | $r = get_object_vars( $args ); |
| | 2605 | } elseif ( is_array( $args ) ) { |
| | 2606 | $r =& $args; |
| | 2607 | } else { |
| | 2608 | wp_parse_str( $args, $r ); |
| | 2609 | } |
| | 2610 | |
| | 2611 | // Passively filter the args before the parse |
| | 2612 | if ( !empty( $filter_key ) ) { |
| | 2613 | $r = apply_filters( 'wp_before_' . $filter_key . '_parse_args', $r ); |
| | 2614 | } |
| | 2615 | |
| | 2616 | // Parse |
| | 2617 | if ( is_array( $defaults ) && !empty( $defaults ) ) { |
| | 2618 | $r = array_merge( $defaults, $r ); |
| | 2619 | } |
| | 2620 | |
| | 2621 | // Aggressively filter the args after the parse |
| | 2622 | if ( !empty( $filter_key ) ) { |
| | 2623 | $r = apply_filters( 'wp_after_' . $filter_key . '_parse_args', $r ); |
| | 2624 | } |
| | 2625 | |
| | 2626 | // Return the parsed results |
| 2607 | 2627 | return $r; |
| 2608 | 2628 | } |
| 2609 | 2629 | |