Un motore di ricerca WordPress per sviluppatori e autori di temi



wp_parse_args ›

Da2.2.0
Deprecaton/a
wp_parse_args ( $args, $defaults = '' )
Parametri: (2)
  • (string|array|object) $args Value to merge with $defaults.
    Richiesto:
  • (array) $defaults Optional. Array that serves as the defaults. Default empty.
    Richiesto: No
    Default: (vuoto)
Ritorna:
  • (array) Merged user defined values with defaults.
Definito a:
Codex:
ChangeLog:
  • 2.3.0

Merge user defined arguments into defaults array.

This function is used throughout WordPress to allow for both string or array to be merged into another array.



Sorgenti

function wp_parse_args( $args, $defaults = '' ) {
	if ( is_object( $args ) ) {
		$r = get_object_vars( $args );
	} elseif ( is_array( $args ) ) {
		$r =& $args;
	} else {
		wp_parse_str( $args, $r );
	}

	if ( is_array( $defaults ) ) {
		return array_merge( $defaults, $r );
	}
	return $r;
}