You are here

function shortcode_attrs in Shortcode 6

Same name and namespace in other branches
  1. 7.2 shortcode.module \shortcode_attrs()
  2. 7 shortcode.module \shortcode_attrs()

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.

If the $atts list has unsupported attributes, then they will be ignored and removed from the final returned list.

@since 2.5

Parameters

array $pairs Entire list of supported attributes and their defaults.:

array $atts User defined attributes in shortcode tag.:

Return value

array Combined and filtered attribute list.

9 calls to shortcode_attrs()
shortcode_basic_tags_shortcode_button in shortcode_basic_tags/shortcode_basic_tags.module
shortcode_basic_tags_shortcode_clear in shortcode_basic_tags/shortcode_basic_tags.module
shortcode_basic_tags_shortcode_dropcap in shortcode_basic_tags/shortcode_basic_tags.module
shortcode_basic_tags_shortcode_highlight in shortcode_basic_tags/shortcode_basic_tags.module
Insert a span around the text with highlight css class
shortcode_basic_tags_shortcode_item in shortcode_basic_tags/shortcode_basic_tags.module

... See full list

File

./shortcode.module, line 531

Code

function shortcode_attrs($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;
}