- 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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user