Fix stats redirect

When an unauthenticated user comes to any page they are redirected
to login screen. After they authenticate they are redirected
to the original page. But the # part of the url is ignored.
So we have to use regular query params from the email and
redirect user to the canonical URL later.

[MAILPOET-2554]
This commit is contained in:
Pavel Dohnal
2020-01-13 13:41:36 +01:00
committed by Jack Kitterhing
parent 8e38925850
commit 3b9ba5cac2
3 changed files with 11 additions and 2 deletions

View File

@ -75,6 +75,15 @@ class Newsletters {
public function render() { public function render() {
global $wp_roles; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps global $wp_roles; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
if (isset($_GET['stats'])) {
$this->wp->wpSafeRedirect(
$this->wp->getSiteUrl(null,
'/wp-admin/admin.php?page=mailpoet-newsletters#/stats/' . $_GET['stats']
)
);
exit;
}
$data = []; $data = [];
$data['items_per_page'] = $this->listingPageLimit->getLimitPerPage('newsletters'); $data['items_per_page'] = $this->listingPageLimit->getLimitPerPage('newsletters');

View File

@ -139,7 +139,7 @@ class Worker {
), ),
'topLinkClicks' => 0, 'topLinkClicks' => 0,
'linkSettings' => WPFunctions::get()->getSiteUrl(null, '/wp-admin/admin.php?page=mailpoet-settings#basics'), 'linkSettings' => WPFunctions::get()->getSiteUrl(null, '/wp-admin/admin.php?page=mailpoet-settings#basics'),
'linkStats' => WPFunctions::get()->getSiteUrl(null, '/wp-admin/admin.php?page=mailpoet-newsletters#/stats/' . $newsletter->getId()), 'linkStats' => WPFunctions::get()->getSiteUrl(null, '/wp-admin/admin.php?page=mailpoet-newsletters&stats=' . $newsletter->getId()),
'clicked' => $clicked, 'clicked' => $clicked,
'opened' => $opened, 'opened' => $opened,
'subscribersLimitReached' => $this->subscribersFeature->check(), 'subscribersLimitReached' => $this->subscribersFeature->check(),

View File

@ -209,7 +209,7 @@ class WorkerTest extends \MailPoetTest {
$this->anything(), $this->anything(),
$this->callback(function($context){ $this->callback(function($context){
return strpos($context['linkSettings'], 'mailpoet-settings') return strpos($context['linkSettings'], 'mailpoet-settings')
&& strpos($context['linkStats'], 'mailpoet-newsletters#/stats'); && strpos($context['linkStats'], 'mailpoet-newsletters&stats');
})); }));
$this->statsNotifications->process(); $this->statsNotifications->process();