- Updates code based on Taut's comments

This commit is contained in:
Vlad
2016-04-14 19:36:12 -04:00
parent 84294b7ee6
commit 599661e028
6 changed files with 36 additions and 25 deletions

View File

@ -18,37 +18,39 @@ class Subscription {
$action,
$default_value = false,
$newsletter = false,
$subscriber = false
$subscriber = false,
$text = false,
$shortcode
) {
switch($action) {
case 'unsubscribe':
return '<a target="_blank" href="['.
self::processUrl(
$action,
return '<a target="_blank" href="'.
self::getShortcodeUrl(
$shortcode,
esc_attr(SubscriptionUrl::getUnsubscribeUrl($subscriber))
)
.'">'.__('Unsubscribe').'</a>';
break;
case 'unsubscribe_url':
return self::processUrl(
$action,
return self::getShortcodeUrl(
$shortcode,
SubscriptionUrl::getUnsubscribeUrl($subscriber)
);
break;
case 'manage':
return '<a target="_blank" href="'.
self::processUrl(
$action,
self::getShortcodeUrl(
$shortcode,
esc_attr(SubscriptionUrl::getManageUrl($subscriber))
)
.'">'.__('Manage subscription').'</a>';
break;
case 'manage_url':
return self::processUrl(
$action,
return self::getShortcodeUrl(
$shortcode,
SubscriptionUrl::getManageUrl($subscriber)
);
break;
@ -59,10 +61,9 @@ class Subscription {
}
}
static function processUrl($action, $url) {
if((int) Setting::getValue('tracking.enabled') === 1) {
return sprintf('[subscription:%s]', $action);
}
return $url;
static function getShortcodeUrl($shortcode, $url) {
return ((boolean) Setting::getValue('tracking.enabled') === true) ?
$shortcode :
$url;
}
}