wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_parse_args › WordPress Function

Seit2.2.0
Veraltetn/v
wp_parse_args ( $args, $defaults = array() )
Parameter: (2)
  • (string|array|object) $args Value to merge with $defaults.
    Erforderlich: Ja
  • (array) $defaults Optional. Array that serves as the defaults. Default empty array.
    Erforderlich: Nein
    Standard: array()
Gibt zurück:
  • (array) Merged user defined values with defaults.
Definiert in:
Codex:
Changelog:
  • 2.3.0

Merges 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.


Quellcode

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

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