PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.10.2
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.10.2
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
acymailing / index.php

index.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.10.2, at index.php

153 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: AcyMailing
4 * Description: Manage your contact lists and send newsletters from your site.
5 * Author: AcyMailing Newsletter Team
6 * Author URI: https://www.acymailing.com
7 * License: GPLv3
8 * Version: 10.10.2
9 * Text Domain: acymailing
10 * Domain Path: /language
11 * Requires at least: 5.0
12 * Requires PHP: 7.4
13 */
14
15 use AcyMailing\WpInit\Activation;
16 use AcyMailing\WpInit\Addons;
17 use AcyMailing\WpInit\Beaver;
18 use AcyMailing\WpInit\Cron;
19 use AcyMailing\WpInit\Data;
20 use AcyMailing\WpInit\Deactivate;
21 use AcyMailing\WpInit\Elementor;
22 use AcyMailing\WpInit\Forms;
23 use AcyMailing\WpInit\Gutenberg;
24 use AcyMailing\WpInit\Menu;
25 use AcyMailing\WpInit\Message;
26 use AcyMailing\WpInit\Oauth;
27 use AcyMailing\WpInit\OverrideEmail;
28 use AcyMailing\WpInit\Router;
29 use AcyMailing\WpInit\Security;
30 use AcyMailing\WpInit\Update;
31 use AcyMailing\WpInit\UserSync;
32 use AcyMailing\WpInit\WpRocket;
33
34 defined('ABSPATH') || die('Restricted Access');
35
36 class acymailingLoader
37 {
38 public function __construct()
39 {
40 // Install Acy DB and sample data on first activation (not on installation because of FTP install)
41 register_activation_hook(__DIR__.'/'.basename(__FILE__), [$this, 'activation']);
42 add_action('wp_initialize_site', [$this, 'subsiteCreation'], 101);
43
44 // Prevent bad plugins from loading on AcyMailing pages
45 add_action('plugins_loaded', [$this, 'protectAcyMailingPages'], 5);
46
47 // Init widgets. According to the WP doc widgets_init should be loaded after init, but it isn't
48 add_action('widgets_init', [$this, 'initWidgets']);
49
50 // Init AcyMailing
51 add_action('init', [$this, 'initAcyMailing'], 0);
52
53 add_filter('wpml_show_admin_language_switcher', [$this, 'disableWpml']);
54 }
55
56 public function subsiteCreation(): void
57 {
58 if (is_plugin_active_for_network(basename(__DIR__).'/'.basename(__FILE__))) {
59 $this->activation();
60 }
61 }
62
63 public function activation(): void
64 {
65 // Load Acy library
66 $helperFile = __DIR__.DIRECTORY_SEPARATOR.'back'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'init.php';
67 if (file_exists($helperFile) && include_once $helperFile) {
68 $activation = new Activation();
69 $activation->install();
70 }
71 }
72
73 public function protectAcyMailingPages()
74 {
75 if (!$this->isCurrentlyOnAcyPage()) {
76 return;
77 }
78
79 // Prevent plugins from breaking AcyMailing pages (mainly JS scripts loaded without the WP way)
80 remove_action('plugins_loaded', 'mailchimp_on_all_plugins_loaded', 12);
81 remove_action('plugins_loaded', '_imagify_init');
82 remove_action('plugins_loaded', 'plugins_loaded_wps_hide_login_plugin');
83 remove_action('plugins_loaded', ['WPAS_Gas', 'get_instance'], 11);
84 remove_action('plugins_loaded', 'woosb_init', 12);
85 }
86
87 public function disableWpml(): bool
88 {
89 if (!$this->isCurrentlyOnAcyPage() || !$this->loadAcyMailingLibrary()) {
90 return true;
91 }
92
93 $config = acym_config();
94
95 return intval($config->get('multilingual')) !== 1;
96 }
97
98 public function initWidgets()
99 {
100 $ds = DIRECTORY_SEPARATOR;
101 include_once __DIR__.$ds.'widgets'.$ds.'archive'.$ds.'widget.php';
102 include_once __DIR__.$ds.'widgets'.$ds.'profile'.$ds.'widget.php';
103 include_once __DIR__.$ds.'widgets'.$ds.'subscriptionform'.$ds.'widget.php';
104
105 register_widget('acym_archive_widget');
106 register_widget('acym_profile_widget');
107 register_widget('acym_subscriptionform_widget');
108 }
109
110 private function loadAcyMailingLibrary()
111 {
112 $helperFile = __DIR__.DIRECTORY_SEPARATOR.'back'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'init.php';
113
114 return file_exists($helperFile) && include_once $helperFile;
115 }
116
117 public function initAcyMailing()
118 {
119 if (!$this->loadAcyMailingLibrary()) {
120 return;
121 }
122
123
124 new Update();
125 $router = new Router();
126 new Menu($router);
127 new UserSync();
128 new Message();
129 new Elementor();
130 new Beaver();
131 new WpRocket();
132 new Addons();
133 new Forms();
134 new OverrideEmail();
135 new Cron();
136 new Gutenberg();
137 new Security();
138 new Deactivate();
139 new Oauth();
140 new Data();
141 }
142
143 private function isCurrentlyOnAcyPage(): bool
144 {
145 // Make sure we're on an AcyMailing page
146 $page = isset($_REQUEST['page']) ? sanitize_text_field(wp_unslash($_REQUEST['page'])) : '';
147
148 return !empty($page) && strpos($page, 'acymailing_') !== false;
149 }
150 }
151
152 new acymailingLoader();
153