function _shortcode_process_tag in Shortcode 7.2
Same name and namespace in other branches
- 6 shortcode.module \_shortcode_process_tag()
- 7 shortcode.module \_shortcode_process_tag()
Regular Expression callable for do_shortcode() for calling ShortCode hook.
See for details of the match array contents.
Parameters
array $m: Regular expression match array.
object $filter: The input format filter object.
Return value
mixed False on failure.
1 call to _shortcode_process_tag()
- _shortcode_process in ./
shortcode.module - Processes the ShortCodes according to the text and the text format.
File
- ./
shortcode.module, line 336 - Provides ShortCodes filter framework and API (like WP ShortCodes)
Code
function _shortcode_process_tag(array $m, $filter) {
// Get tags from the static cache.
$shortcodes = _shortcode_get_shortcodes($filter);
$tag = $m[2];
if (!empty($shortcodes[$tag])) {
// Process if tag exists (enabled).
$attr = _shortcode_parse_attrs($m[3]);
/*
* @codingStandardsIgnoreStart
* 0 - the full tag text?
* 1/5 - An extra [ or ] to allow for escaping ShortCodes with double [[]]
* 2 - The ShortCode name
* 3 - The ShortCode argument list
* 4 - The content of a ShortCode when it wraps some content.
* @codingStandardsIgnoreEnd
*/
if (!is_null($m[4])) {
// This is an enclosing tag, means extra parameter is present.
if (is_string($shortcodes[$tag]['function']) && function_exists($shortcodes[$tag]['function'])) {
return $m[1] . call_user_func($shortcodes[$tag]['function'], $attr, $m[4], $m[2]) . $m[5];
}
return $m[1] . $m[5];
}
else {
// This is a self-closing tag.
if (is_string($shortcodes[$tag]['function']) && function_exists($shortcodes[$tag]['function'])) {
return $m[1] . call_user_func($shortcodes[$tag]['function'], $attr, NULL, $m[2]) . $m[5];
}
return $m[1] . $m[5];
}
}
elseif (is_null($m[4])) {
return $m[4];
}
return '';
}