PopulatorData
3 months ago
AccessControl.php
2 years ago
Activator.php
2 months ago
AssetsLoader.php
4 weeks ago
Capabilities.php
3 months ago
Changelog.php
3 months ago
DeactivationPoll.php
3 years ago
DeferredAdminNotices.php
2 months ago
Env.php
6 months ago
Hooks.php
1 month ago
HooksWooCommerce.php
1 month ago
Initializer.php
1 month ago
Installer.php
11 months ago
Localizer.php
1 week ago
Menu.php
1 month ago
PersonalDataErasers.php
1 month ago
PersonalDataExporters.php
1 month ago
PluginActivatedHook.php
3 years ago
Populator.php
4 weeks ago
PrivacyPolicy.php
1 month ago
Renderer.php
1 year ago
RendererFactory.php
3 years ago
RequirementsChecker.php
2 months ago
Router.php
3 months ago
ServicesChecker.php
3 years ago
Shortcodes.php
1 week ago
SilentUpgraderSkin.php
3 years ago
SubscriberChangesNotifier.php
2 months ago
TranslationUpdater.php
3 months ago
TwigEnvironment.php
1 year ago
TwigFileSystemCache.php
3 years ago
Updater.php
2 weeks ago
index.php
3 years ago
Router.php
45 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\Config; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\WP\Functions as WPFunctions; |
| 9 | |
| 10 | class Router { |
| 11 | /** @var WPFunctions */ |
| 12 | private $wp; |
| 13 | |
| 14 | public function __construct( |
| 15 | WPFunctions $wp |
| 16 | ) { |
| 17 | $this->wp = $wp; |
| 18 | } |
| 19 | |
| 20 | public function checkRedirects(): void { |
| 21 | $url = null; |
| 22 | if (isset($_GET['page']) && is_string($_GET['page']) && sanitize_text_field(wp_unslash($_GET['page'])) === 'mailpoet-newsletters') { |
| 23 | $url = $this->checkNewslettersRedirect(); |
| 24 | } |
| 25 | if (!$url) return; |
| 26 | |
| 27 | $this->redirect($url); |
| 28 | } |
| 29 | |
| 30 | private function checkNewslettersRedirect(): ?string { |
| 31 | if (isset($_GET['stats']) && is_string($_GET['stats'])) { |
| 32 | return '/wp-admin/admin.php?page=mailpoet-newsletters#/stats/' . sanitize_text_field(wp_unslash($_GET['stats'])); |
| 33 | } |
| 34 | |
| 35 | return null; |
| 36 | } |
| 37 | |
| 38 | private function redirect(string $url): void { |
| 39 | $this->wp->wpSafeRedirect( |
| 40 | $this->wp->getSiteUrl(null, $url) |
| 41 | ); |
| 42 | exit; |
| 43 | } |
| 44 | } |
| 45 |