diff --git a/lib/Newsletter/Shortcodes/Categories/Date.php b/lib/Newsletter/Shortcodes/Categories/Date.php index 6ec3affa24..b276706145 100644 --- a/lib/Newsletter/Shortcodes/Categories/Date.php +++ b/lib/Newsletter/Shortcodes/Categories/Date.php @@ -6,6 +6,7 @@ use MailPoet\WP\Functions as WPFunctions; class Date { static function process( + $shortcode, $action, $action_argument = false, $action_argument_value = false diff --git a/lib/Newsletter/Shortcodes/Categories/Link.php b/lib/Newsletter/Shortcodes/Categories/Link.php index bf1e46ca3d..f8e3c787b8 100644 --- a/lib/Newsletter/Shortcodes/Categories/Link.php +++ b/lib/Newsletter/Shortcodes/Categories/Link.php @@ -10,6 +10,7 @@ class Link { const CATEGORY_NAME = 'link'; static function process( + $shortcode, $action, $action_argument, $action_argument_value, diff --git a/lib/Newsletter/Shortcodes/Categories/Newsletter.php b/lib/Newsletter/Shortcodes/Categories/Newsletter.php index 98566601ad..980269acc0 100644 --- a/lib/Newsletter/Shortcodes/Categories/Newsletter.php +++ b/lib/Newsletter/Shortcodes/Categories/Newsletter.php @@ -8,7 +8,9 @@ if(!defined('ABSPATH')) exit; require_once(ABSPATH . "wp-includes/pluggable.php"); class Newsletter { - static function process($action, + static function process( + $shortcode, + $action, $action_argument, $action_argument_value, $newsletter, diff --git a/lib/Newsletter/Shortcodes/Categories/Subscriber.php b/lib/Newsletter/Shortcodes/Categories/Subscriber.php index 27ec94a78f..6e14d79800 100644 --- a/lib/Newsletter/Shortcodes/Categories/Subscriber.php +++ b/lib/Newsletter/Shortcodes/Categories/Subscriber.php @@ -9,6 +9,7 @@ require_once(ABSPATH . 'wp-includes/pluggable.php'); class Subscriber { static function process( + $shortcode, $action, $action_argument, $action_argument_value, diff --git a/lib/Newsletter/Shortcodes/Shortcodes.php b/lib/Newsletter/Shortcodes/Shortcodes.php index 88c8f525c5..a93cd674af 100644 --- a/lib/Newsletter/Shortcodes/Shortcodes.php +++ b/lib/Newsletter/Shortcodes/Shortcodes.php @@ -78,6 +78,7 @@ class Shortcodes { $custom_shortcode; } return $shortcode_class::process( + $shortcode, $shortcode_action, $shortcode_argument, $shortcode_argument_value, diff --git a/tests/unit/Newsletter/ShortcodesTest.php b/tests/unit/Newsletter/ShortcodesTest.php index f0b2c8e22d..68b65a150f 100644 --- a/tests/unit/Newsletter/ShortcodesTest.php +++ b/tests/unit/Newsletter/ShortcodesTest.php @@ -83,14 +83,14 @@ class ShortcodesTest extends \MailPoetTest { function testItCanProcessDateShortcodes() { $date = new \DateTime(current_time('mysql')); - expect(Date::process('d'))->equals(date_i18n('d', current_time('timestamp'))); - expect(Date::process('dordinal'))->equals(date_i18n('dS', current_time('timestamp'))); - expect(Date::process('dtext'))->equals(date_i18n('l', current_time('timestamp'))); - expect(Date::process('m'))->equals(date_i18n('m', current_time('timestamp'))); - expect(Date::process('mtext'))->equals(date_i18n('F', current_time('timestamp'))); - expect(Date::process('y'))->equals(date_i18n('Y', current_time('timestamp'))); + expect(Date::process('[date:d]', 'd'))->equals(date_i18n('d', current_time('timestamp'))); + expect(Date::process('[date:dordinal]', 'dordinal'))->equals(date_i18n('dS', current_time('timestamp'))); + expect(Date::process('[date:dordinal]', 'dtext'))->equals(date_i18n('l', current_time('timestamp'))); + expect(Date::process('[date:m]', 'm'))->equals(date_i18n('m', current_time('timestamp'))); + expect(Date::process('[date:mtext]', 'mtext'))->equals(date_i18n('F', current_time('timestamp'))); + expect(Date::process('[date:y]', 'y'))->equals(date_i18n('Y', current_time('timestamp'))); // allow custom date formats (http://php.net/manual/en/function.date.php) - expect(Date::process('custom', 'format', 'U F'))->equals(date_i18n('U F', current_time('timestamp'))); + expect(Date::process('[date:custom|format:U F]', 'custom', 'format', 'U F'))->equals(date_i18n('U F', current_time('timestamp'))); } function testItCanProcessNewsletterShortcodes() { @@ -152,13 +152,13 @@ class ShortcodesTest extends \MailPoetTest { ); $result = $shortcodes_object->process(array('[subscriber:firstname | default:test]')); expect($result[0])->equals($this->subscriber->first_name); - // when subscriber is not empty and not an object, false is returned + // when subscriber is not empty and not an object, shortcode is returned $shortcodes_object = new \MailPoet\Newsletter\Shortcodes\Shortcodes( $this->newsletter, $subscriber = array() ); $result = $shortcodes_object->process(array('[subscriber:firstname | default:test]')); - expect($result[0])->false(); + expect($result[0])->equals('[subscriber:firstname | default:test]'); } function testSubscriberFirstAndLastNameShortcodesReturnDefaultValueWhenDataIsEmpty() {