PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | WpInit/Router.php +0 -280 10.10.2 → 11.1.1 View file →
@@ -1,280 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\WpInit;
4 -
5 -use AcyMailing\Classes\PluginClass;
6 -
7 -class Router
8 -{
9 - public function __construct()
10 - {
11 - add_action('wp_ajax_acymailing_router', [$this, 'router']);
12 - if (!acym_isAdmin()) {
13 - add_action('wp_loaded', [$this, 'frontRouter']);
14 - }
15 -
16 - $pages = [
17 - 'automation',
18 - 'bounces',
19 - 'campaigns',
20 - 'configuration',
21 - 'dashboard',
22 - 'dynamics',
23 - 'fields',
24 - 'file',
25 - 'followups',
26 - 'forms',
27 - 'language',
28 - 'lists',
29 - 'mails',
30 - 'override',
31 - 'queue',
32 - 'segments',
33 - 'stats',
34 - 'users',
35 - ];
36 - $headerPages = [
37 - 'automation',
38 - 'bounces',
39 - 'campaigns',
40 - 'configuration',
41 - 'dashboard',
42 - 'fields',
43 - 'followups',
44 - 'forms',
45 - 'lists',
46 - 'mails',
47 - 'override',
48 - 'queue',
49 - 'segments',
50 - 'stats',
51 - 'users',
52 - ];
53 - foreach ($pages as $page) {
54 - if (in_array($page, $headerPages)) {
55 - add_action('load-acymailing_page_acymailing_'.$page, [$this, 'waitHeaders']);
56 - }
57 - add_action('admin_print_scripts-acymailing_page_acymailing_'.$page, [$this, 'disableJsBreakingPages']);
58 - add_action('admin_print_styles-acymailing_page_acymailing_'.$page, [$this, 'removeCssBreakingPages']);
59 - }
60 - add_action('admin_print_scripts-toplevel_page_acymailing_dashboard', [$this, 'disableJsBreakingPages']);
61 - add_action('admin_print_styles-toplevel_page_acymailing_dashboard', [$this, 'removeCssBreakingPages']);
62 - add_action('wp_enqueue_media', [$this, 'protectAcyMailingPages'], 100);
63 - add_action('init', [$this, 'autologin']);
64 - }
65 -
66 - public function protectAcyMailingPages()
67 - {
68 - $page = isset($_REQUEST['page']) ? sanitize_text_field(wp_unslash($_REQUEST['page'])) : '';
69 - if (empty($page) || strpos($page, 'acymailing_') === false) return;
70 -
71 - wp_dequeue_script('responsive-lightbox-admin-select2');
72 - wp_dequeue_style('responsive-lightbox-admin-select2');
73 -
74 - wp_dequeue_script('dsm-select-two');
75 - wp_dequeue_style('dsm-select-two');
76 - }
77 -
78 - public function waitHeaders()
79 - {
80 - ob_start();
81 - }
82 -
83 - public function disableJsBreakingPages()
84 - {
85 - remove_action('admin_print_scripts', 'print_emoji_detection_script');
86 -
87 - remove_action('wp_enqueue_media', '\\Slideshowck\\Tinymce\\register_scripts_styles');
88 -
89 - remove_action('wp_enqueue_media', '\\Sgdg\\Admin\\TinyMCE\\register_scripts_styles');
90 -
91 - wp_dequeue_script('select2.js');
92 -
93 - wp_dequeue_script('checkout_fields_js');
94 -
95 - wp_dequeue_script('wp-optimize-minify-admin-purge');
96 -
97 - wp_dequeue_script('happy-elementor-addons-select2');
98 - wp_dequeue_script('select2');
99 - }
100 -
101 - public function removeCssBreakingPages()
102 - {
103 - wp_dequeue_style('saswp-main-css');
104 - wp_dequeue_style('WP REST API Controller');
105 - wp_dequeue_style('wpml-select-2');
106 - wp_dequeue_style('swcfpc_admin_css');
107 -
108 - wp_dequeue_style('happy-elementor-addons-select2');
109 - wp_dequeue_style('select2');
110 -
111 - wp_dequeue_style('qlwapp-admin-menu');
112 - }
113 -
114 - public function frontRouter()
115 - {
116 - $page = acym_getVar('string', 'page');
117 - if (empty($page) || $page !== ACYM_COMPONENT.'_front') return;
118 -
119 - $this->router(true);
120 - }
121 -
122 - public function router(bool $front = false): void
123 - {
124 - displayFreeTrialMessage();
125 -
126 -
127 - if (!$front) {
128 - auth_redirect();
129 - }
130 -
131 - if (file_exists(ACYM_FOLDER.'update.php')) {
132 - $acyActivation = new Activation();
133 - if (is_multisite()) {
134 - $currentBlog = get_current_blog_id();
135 - $sites = function_exists('get_sites') ? get_sites() : wp_get_sites();
136 -
137 - foreach ($sites as $site) {
138 - if (is_object($site)) {
139 - $site = get_object_vars($site);
140 - }
141 - switch_to_blog($site['blog_id']);
142 - acym_config(true);
143 - $acyActivation->updateAcym();
144 - }
145 -
146 - switch_to_blog($currentBlog);
147 - } else {
148 - $acyActivation->updateAcym();
149 - }
150 -
151 - unlink(ACYM_FOLDER.'update.php');
152 - }
153 -
154 - $config = acym_config(true);
155 -
156 - $ctrl = acym_getVar('cmd', 'ctrl', '');
157 - $task = acym_getVar('cmd', 'task', '');
158 -
159 - if (!$front && acym_isAdmin() && file_exists(ACYM_NEW_FEATURES_SPLASHSCREEN_JSON) && is_writable(ACYM_NEW_FEATURES_SPLASHSCREEN_JSON)) {
160 - $ctrl = 'dashboard';
161 - $task = 'features';
162 - acym_setVar('ctrl', $ctrl);
163 - acym_setVar('task', $task);
164 - }
165 -
166 - $needToMigrate = $config->get('migration') == 0 && acym_existsAcyMailing59() && acym_getVar('string', 'task') !== 'migrationDone';
167 - $forceDashboard = !$front && ($needToMigrate || $config->get('walk_through', 0) == 1) && !(defined('DOING_AJAX') && DOING_AJAX) && 'dynamics' !== $ctrl;
168 - if ($forceDashboard) {
169 - $ctrl = 'dashboard';
170 - acym_setVar('ctrl', $ctrl);
171 - }
172 -
173 - if (empty($ctrl)) {
174 - $ctrl = str_replace(ACYM_COMPONENT.'_', '', acym_getVar('cmd', 'page', ''));
175 -
176 - if (empty($ctrl)) {
177 - echo acym_translation('ACYM_PAGE_NOT_FOUND');
178 -
179 - $noCache = acym_getVar('int', 'nocache', 0);
180 - if (!empty($noCache)) {
181 - acym_redirect(acym_rootURI());
182 - }
183 -
184 - return;
185 - }
186 -
187 - acym_setVar('ctrl', $ctrl);
188 - }
189 -
190 - $this->deactivateHookAdminFooter();
191 - $subNamespace = $front ? 'Front' : '';
192 - $controllerNamespace = 'AcyMailing\\'.$subNamespace.'Controllers\\'.ucfirst($ctrl).'Controller';
193 -
194 - if (!class_exists($controllerNamespace)) {
195 - echo acym_translation('ACYM_PAGE_NOT_FOUND').': '.$ctrl;
196 -
197 - return;
198 - }
199 -
200 - if (!$front && acym_isAdmin() && $task != 'edit' && !(defined('DOING_AJAX') && DOING_AJAX)) {
201 - $pluginClass = new PluginClass();
202 - $installedPlugins = $pluginClass->getAll('title');
203 - $newPlugins = json_decode(ACYM_AVAILABLE_PLUGINS);
204 - foreach ($newPlugins as $onePlugin) {
205 - if (empty($installedPlugins[$onePlugin->name])) continue;
206 - if ($installedPlugins[$onePlugin->name]->type !== 'ADDON') continue;
207 -
208 - acym_enqueueMessage(
209 - acym_translationSprintf(
210 - 'ACYM_NEW_PLUGIN_FORMAT',
211 - $onePlugin->name,
212 - '<a target="_blank" style="color: #00a5ff;" href="'.$onePlugin->downloadlink.'">'.acym_translation('ACYM_CLICK_HERE').'</a>'
213 - ),
214 - 'error'
215 - );
216 - }
217 - }
218 -
219 - $controller = new $controllerNamespace();
220 - if (empty($task)) {
221 - $task = acym_getVar('cmd', 'defaulttask', $controller->defaulttask);
222 - }
223 -
224 - if ($forceDashboard && !method_exists($controller, $task)) {
225 - $task = 'listing';
226 - acym_setVar('task', $task);
227 - }
228 -
229 - $controller->call($task, $front);
230 - }
231 -
232 - public function autologin()
233 - {
234 - $subId = acym_getVar('int', 'autoSubId');
235 - $subToken = acym_getVar('string', 'subKey');
236 -
237 - if (empty($subId) || empty($subToken)) {
238 - return;
239 - }
240 -
241 - $currentUrl = acym_currentURL();
242 - $cleanedUrl = acym_cleanUrl($currentUrl, ['autoSubId', 'subKey']);
243 -
244 - $config = acym_config();
245 - if ($config->get('autologin_urls', 0) == 0) {
246 - acym_redirect($cleanedUrl);
247 - }
248 -
249 - $subscriber = acym_loadObject('SELECT `cms_id`, `key` FROM #__acym_user WHERE `id` = '.intval($subId));
250 - if (empty($subscriber->cms_id) || $subscriber->cms_id === acym_currentUserId()) {
251 - acym_redirect($cleanedUrl);
252 - }
253 -
254 - if (!acym_verifyAutologinToken($subId, $subToken, $subscriber->key)) {
255 - acym_redirect($cleanedUrl);
256 - }
257 -
258 - $user = get_user_by('id', $subscriber->cms_id);
259 -
260 - if (is_wp_error($user) || !$user) {
261 - acym_redirect($cleanedUrl);
262 - }
263 -
264 - if ($user->has_cap('manage_options')) {
265 - acym_redirect($cleanedUrl);
266 - }
267 -
268 - wp_clear_auth_cookie();
269 - wp_set_current_user($user->ID);
270 - wp_set_auth_cookie($user->ID);
271 -
272 - acym_redirect($cleanedUrl);
273 - }
274 -
275 - private function deactivateHookAdminFooter()
276 - {
277 - remove_action('admin_footer', 'Freemius::_enrich_ajax_url');
278 - remove_action('admin_footer', 'Freemius::_open_support_forum_in_new_page');
279 - }
280 -}