Advertisements

shortcode_atts

Definition:
function shortcode_atts($pairs, $atts) {}

Combine user attributes with known attributes and fill in defaults when needed.
The pairs should be considered to be all of the attributes which are supported by the caller and given as a list. The returned attributes will only contain the attributes in the $pairs list.

Parameters

  • array $pairs: Entire list of supported attributes and their defaults.
  • array $atts: User defined attributes in shortcode tag.

Return values

returns:Combined and filtered attribute list.

Source code

function shortcode_atts($pairs, $atts) {

	$atts = (array)$atts;

	$out = array();

	foreach($pairs as $name => $default) {

		if ( array_key_exists($name, $atts) )

			$out[$name] = $atts[$name];

		else

			$out[$name] = $default;

	}

	return $out;

}

2861

Advertisements

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

%d bloggers like this: