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