private static function FilterOEmbed::oembed_parse_attr in oEmbed 8
Retrieve all attributes from the shortcodes tag.
Parameters
string $text:
Return value
array List of attributes and their value.
See also
shortcode_parse_atts in WordPress 3.1.3.
1 call to FilterOEmbed::oembed_parse_attr()
- FilterOEmbed::oembed_preg_tag_replace in src/
Plugin/ Filter/ FilterOEmbed.php - PREG replace callback finds [embed] shortcodes, URLs and request options.
File
- src/
Plugin/ Filter/ FilterOEmbed.php, line 176 - Contains \Drupal\filter\Plugin\Filter\FilterOEmbed.
Class
- FilterOEmbed
- Provides a fallback placeholder filter to use for missing filters.
Namespace
Drupal\oembed\Plugin\FilterCode
private static function oembed_parse_attr($text) {
$attributes = array();
$pattern = '/([\\w-]+)\\s*=\\s*"([^"]*)"(?:\\s|$)|([\\w-]+)\\s*=\\s*\'([^\']*)\'(?:\\s|$)|([\\w-]+)\\s*=\\s*([^\\s\'"]+)(?:\\s|$)|"([^"]*)"(?:\\s|$)|(\\S+)(?:\\s|$)/';
$text = preg_replace("/[\\x{00a0}\\x{200b}]+/u", " ", $text);
if (preg_match_all($pattern, $text, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
if (!empty($match[1])) {
$attributes[strtolower($match[1])] = stripcslashes($match[2]);
}
elseif (!empty($match[3])) {
$attributes[strtolower($match[3])] = stripcslashes($match[4]);
}
elseif (!empty($match[5])) {
$attributes[strtolower($match[5])] = stripcslashes($match[6]);
}
elseif (isset($match[7]) && strlen($match[7])) {
$attributes[] = stripcslashes($match[7]);
}
elseif (isset($match[8])) {
$attributes[] = stripcslashes($match[8]);
}
}
// Reject any unclosed HTML elements
foreach ($attributes as &$value) {
if (false !== strpos($value, '<')) {
if (1 !== preg_match('/^[^<]*+(?:<[^>]*+>[^<]*+)*+$/', $value)) {
$value = '';
}
}
}
}
else {
$attributes = ltrim($text);
}
return $attributes;
}