From 0bf6c87ec7efcf1a668a046f72dba62d2fdd9d6e Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 4 May 2016 10:45:30 -0400 Subject: [PATCH] - Fixes shortcode category name for view in browser url - Updates shortcode regex --- lib/Newsletter/Shortcodes/Categories/Link.php | 2 +- lib/Newsletter/Shortcodes/Shortcodes.php | 10 +++++++--- lib/Statistics/Track/Clicks.php | 3 +-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/Newsletter/Shortcodes/Categories/Link.php b/lib/Newsletter/Shortcodes/Categories/Link.php index 12210addd7..a223e65d24 100644 --- a/lib/Newsletter/Shortcodes/Categories/Link.php +++ b/lib/Newsletter/Shortcodes/Categories/Link.php @@ -147,7 +147,7 @@ class Link { case 'subscription_manage_url': $url = SubscriptionUrl::getManageUrl($subscriber); break; - case 'view_in_browser_url': + case 'newsletter_view_in_browser_url': $url = Link::getViewInBrowserUrl($newsletter, $subscriber, $queue); break; default: diff --git a/lib/Newsletter/Shortcodes/Shortcodes.php b/lib/Newsletter/Shortcodes/Shortcodes.php index dc3c55cd6c..5e551365f0 100644 --- a/lib/Newsletter/Shortcodes/Shortcodes.php +++ b/lib/Newsletter/Shortcodes/Shortcodes.php @@ -34,7 +34,7 @@ class Shortcodes { function match($shortcode) { preg_match( - '/\[(?P\w+):(?P\w+)(?:.*?\|.*?default:(?P\w+))?\]/ism', + '/\[(?P\w+)?:(?P\w+)(?:.*?\|.*?default:(?P.*?))?\]/', $shortcode, $match ); @@ -45,8 +45,12 @@ class Shortcodes { $processed_shortcodes = array_map( function($shortcode) use($content) { $shortcode_details = $this->match($shortcode); - $shortcode_category = ucfirst($shortcode_details['category']); - $shortcode_action = $shortcode_details['action']; + $shortcode_category = isset($shortcode_details['category']) ? + ucfirst($shortcode_details['category']) : + false; + $shortcode_action = isset($shortcode_details['action']) ? + $shortcode_details['action'] : + false; $shortcode_class = __NAMESPACE__ . '\\Categories\\' . $shortcode_category; $shortcode_default_value = isset($shortcode_details['default']) diff --git a/lib/Statistics/Track/Clicks.php b/lib/Statistics/Track/Clicks.php index c0f2a518b9..b1aa9cfde0 100644 --- a/lib/Statistics/Track/Clicks.php +++ b/lib/Statistics/Track/Clicks.php @@ -7,7 +7,6 @@ use MailPoet\Models\SendingQueue; use MailPoet\Models\StatisticsClicks; use MailPoet\Models\Subscriber; use MailPoet\Newsletter\Shortcodes\Categories\Link; -use MailPoet\Subscription\Url as SubscriptionUrl; if(!defined('ABSPATH')) exit; @@ -82,7 +81,7 @@ class Clicks { $subscriber, $queue ); - if (!$url) $this->abort(); + if(!$url) $this->abort(); } return $url; }