- 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:
@@ -80,7 +80,7 @@ class Links {
|
||||
// i.e., <a href="http://google.com">(http://google.com)</a> => [(http://google.com)](http://tracked_link)
|
||||
$regex_escaped_extracted_link = preg_quote($extracted_link['link'], '/');
|
||||
$content = preg_replace(
|
||||
'/\[(' . $regex_escaped_extracted_link . ')\](\(' . $regex_escaped_extracted_link . '\))/',
|
||||
'/\[(.*?)\](\(' . $regex_escaped_extracted_link . '\))/',
|
||||
'[$1](' . $tracked_link . ')',
|
||||
$content
|
||||
);
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user