- Updates regex to not match http/ftp links as shortcodes

- Updates regex to properly replace links in text version of newsletter
This commit is contained in:
Vlad
2016-07-27 21:57:55 -04:00
parent 420650f37f
commit 8e4d07c658
2 changed files with 5 additions and 3 deletions

View File

@@ -25,8 +25,10 @@ class Shortcodes {
function extract($content, $categories = false) {
$categories = (is_array($categories)) ? implode('|', $categories) : false;
// match: [category:shortcode] or [category|category|...:shortcode]
// dot not match: [category://shortcode] - avoids matching http/ftp links
$regex = sprintf(
'/\[%s:.*?\]/ism',
'/\[%s:(?!\/\/).*?\]/ism',
($categories) ? '(?:' . $categories . ')' : '(?:\w+)'
);
preg_match_all($regex, $content, $shortcodes);
@@ -94,4 +96,4 @@ class Shortcodes {
$shortcodes = array_intersect_key($shortcodes, $processed_shortcodes);
return str_replace($shortcodes, $processed_shortcodes, $content);
}
}
}