wp_parse_args

Definition:
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.

Parameters

  • 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;

	else

		wp_parse_str( $args, $r );



	if ( is_array( $defaults ) )

		return array_merge( $defaults, $r );

	return $r;

}

3971

About these ads

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 196 other followers

%d bloggers like this: