function wp_parse_args( $args, $defaults = '' ) {}

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.


  • string|array $args: Value to merge with $defaults
  • array $defaults: Array that serves as the defaults.

Return values

returns:Merged user defined values with defaults.

Source code

function wp_parse_args( $args, $defaults = '' ) {

	if ( is_object( $args ) )

		$r = get_object_vars( $args );

	elseif ( is_array( $args ) )

		$r =& $args;


		wp_parse_str( $args, $r );

	if ( is_array( $defaults ) )

		return array_merge( $defaults, $r );

	return $r;



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: