Move manage subscription page filter to proper class
[MAILPOET-1635]
This commit is contained in:
committed by
Veljko V
parent
72ca0ce32f
commit
7c979c9b56
@@ -100,10 +100,7 @@ class ManageSubscriptionFormRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->wp->applyFilters(
|
return $this->templateRenderer->render('subscription/manage_subscription.html', $templateData);
|
||||||
'mailpoet_manage_subscription_page',
|
|
||||||
$this->templateRenderer->render('subscription/manage_subscription.html', $templateData)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getCustomFields(Subscriber $subscriber): array {
|
private function getCustomFields(Subscriber $subscriber): array {
|
||||||
|
@@ -357,7 +357,11 @@ class Pages {
|
|||||||
} else {
|
} else {
|
||||||
return $this->wp->__('Subscription management form is only available to mailing lists subscribers.', 'mailpoet');
|
return $this->wp->__('Subscription management form is only available to mailing lists subscribers.', 'mailpoet');
|
||||||
}
|
}
|
||||||
return $this->manageSubscriptionFormRenderer->renderForm($subscriber);
|
|
||||||
|
return $this->wp->applyFilters(
|
||||||
|
'mailpoet_manage_subscription_page',
|
||||||
|
$this->manageSubscriptionFormRenderer->renderForm($subscriber)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getUnsubscribeContent() {
|
private function getUnsubscribeContent() {
|
||||||
|
@@ -162,7 +162,7 @@ parameters:
|
|||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Access to an undefined property object\\:\\:\\$user_email\\.$#"
|
message: "#^Access to an undefined property object\\:\\:\\$user_email\\.$#"
|
||||||
count: 4
|
count: 5
|
||||||
path: ../../tests/integration/Config/ShortcodesTest.php
|
path: ../../tests/integration/Config/ShortcodesTest.php
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@@ -77,6 +77,28 @@ class ShortcodesTest extends \MailPoetTest {
|
|||||||
expect($result)->contains($subscriber->email);
|
expect($result)->contains($subscriber->email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testItAppliesFilterForManageSubscriptionForm() {
|
||||||
|
$wpUser = wp_set_current_user(1);
|
||||||
|
$wp = new WPFunctions;
|
||||||
|
expect($wp->isUserLoggedIn())->true();
|
||||||
|
$subscriber = Subscriber::create();
|
||||||
|
$subscriber->hydrate(Fixtures::get('subscriber_template'));
|
||||||
|
$subscriber->email = $wpUser->data->user_email;
|
||||||
|
$subscriber->wpUserId = $wpUser->ID;
|
||||||
|
$subscriber->save();
|
||||||
|
|
||||||
|
$shortcodes = ContainerWrapper::getInstance()->get(Shortcodes::class);
|
||||||
|
$shortcodes->init();
|
||||||
|
|
||||||
|
$wp->addAction('mailpoet_manage_subscription_page', function ($page) {
|
||||||
|
return $page . ' MY CUSTOM CONTENT';
|
||||||
|
});
|
||||||
|
$result = do_shortcode('[mailpoet_manage_subscription]');
|
||||||
|
expect($result)->contains('form class="mailpoet-manage-subscription" method="post"');
|
||||||
|
expect($result)->contains('MY CUSTOM CONTENT');
|
||||||
|
$wp->removeAllActions('mailpoet_manage_subscription_page');
|
||||||
|
}
|
||||||
|
|
||||||
public function testItDoesNotDisplayManageSubscriptionFormForLoggedinNonexistentSubscribers() {
|
public function testItDoesNotDisplayManageSubscriptionFormForLoggedinNonexistentSubscribers() {
|
||||||
$wpUser = wp_set_current_user(1);
|
$wpUser = wp_set_current_user(1);
|
||||||
expect((new WPFunctions)->isUserLoggedIn())->true();
|
expect((new WPFunctions)->isUserLoggedIn())->true();
|
||||||
|
Reference in New Issue
Block a user