| 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.2.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\Menu; |
| 19 |
use AcyMailing\WpInit\Cron; |
| 20 |
use AcyMailing\WpInit\Deactivate; |
| 21 |
use AcyMailing\WpInit\Elementor; |
| 22 |
use AcyMailing\WpInit\Forms; |
| 23 |
use AcyMailing\WpInit\Gutenberg; |
| 24 |
use AcyMailing\WpInit\Message; |
| 25 |
use AcyMailing\WpInit\Oauth; |
| 26 |
use AcyMailing\WpInit\OverrideEmail; |
| 27 |
use AcyMailing\WpInit\Router; |
| 28 |
use AcyMailing\WpInit\Security; |
| 29 |
use AcyMailing\WpInit\Update; |
| 30 |
use AcyMailing\WpInit\UserSync; |
| 31 |
use AcyMailing\WpInit\WpRocket; |
| 32 |
|
| 33 |
defined('ABSPATH') || die('Restricted Access'); |
| 34 |
|
| 35 |
class acymailingLoader |
| 36 |
{ |
| 37 |
public function __construct() |
| 38 |
{ |
| 39 |
// Install Acy DB and sample data on first activation (not on installation because of FTP install) |
| 40 |
register_activation_hook(__DIR__.'/index.php', [$this, 'activation']); |
| 41 |
|
| 42 |
// Prevent bad plugins from loading on AcyMailing pages |
| 43 |
add_action('plugins_loaded', [$this, 'protectAcyMailingPages'], 5); |
| 44 |
|
| 45 |
// Init widgets. According to the WP doc widgets_init should be loaded after init, but it isn't |
| 46 |
add_action('widgets_init', [$this, 'initWidgets']); |
| 47 |
|
| 48 |
// Init AcyMailing |
| 49 |
add_action('init', [$this, 'initAcyMailing'], 0); |
| 50 |
|
| 51 |
add_filter('wpml_show_admin_language_switcher', [$this, 'disableWpml']); |
| 52 |
} |
| 53 |
|
| 54 |
public function activation() |
| 55 |
{ |
| 56 |
// Load Acy library |
| 57 |
$helperFile = __DIR__.DIRECTORY_SEPARATOR.'back'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'init.php'; |
| 58 |
if (file_exists($helperFile) && include_once $helperFile) { |
| 59 |
$activation = new Activation(); |
| 60 |
$activation->install(); |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
public function protectAcyMailingPages() |
| 65 |
{ |
| 66 |
if (!$this->isCurrentlyOnAcyPage()) { |
| 67 |
return; |
| 68 |
} |
| 69 |
|
| 70 |
// Prevent plugins from breaking AcyMailing pages (mainly JS scripts loaded without the WP way) |
| 71 |
remove_action('plugins_loaded', 'mailchimp_on_all_plugins_loaded', 12); |
| 72 |
remove_action('plugins_loaded', '_imagify_init'); |
| 73 |
remove_action('plugins_loaded', 'plugins_loaded_wps_hide_login_plugin'); |
| 74 |
remove_action('plugins_loaded', ['WPAS_Gas', 'get_instance'], 11); |
| 75 |
remove_action('plugins_loaded', 'woosb_init', 12); |
| 76 |
} |
| 77 |
|
| 78 |
public function disableWpml(): bool |
| 79 |
{ |
| 80 |
if (!$this->isCurrentlyOnAcyPage() || !$this->loadAcyMailingLibrary()) { |
| 81 |
return true; |
| 82 |
} |
| 83 |
|
| 84 |
$config = acym_config(); |
| 85 |
|
| 86 |
return intval($config->get('multilingual')) !== 1; |
| 87 |
} |
| 88 |
|
| 89 |
public function initWidgets() |
| 90 |
{ |
| 91 |
$ds = DIRECTORY_SEPARATOR; |
| 92 |
include_once __DIR__.$ds.'widgets'.$ds.'archive'.$ds.'widget.php'; |
| 93 |
include_once __DIR__.$ds.'widgets'.$ds.'profile'.$ds.'widget.php'; |
| 94 |
include_once __DIR__.$ds.'widgets'.$ds.'subscriptionform'.$ds.'widget.php'; |
| 95 |
|
| 96 |
register_widget('acym_archive_widget'); |
| 97 |
register_widget('acym_profile_widget'); |
| 98 |
register_widget('acym_subscriptionform_widget'); |
| 99 |
} |
| 100 |
|
| 101 |
private function loadAcyMailingLibrary() |
| 102 |
{ |
| 103 |
$helperFile = __DIR__.DIRECTORY_SEPARATOR.'back'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'init.php'; |
| 104 |
|
| 105 |
return file_exists($helperFile) && include_once $helperFile; |
| 106 |
} |
| 107 |
|
| 108 |
public function initAcyMailing() |
| 109 |
{ |
| 110 |
if (!$this->loadAcyMailingLibrary()) { |
| 111 |
return; |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
new Update(); |
| 116 |
$router = new Router(); |
| 117 |
new Menu($router); |
| 118 |
new UserSync(); |
| 119 |
new Message(); |
| 120 |
new Elementor(); |
| 121 |
new Beaver(); |
| 122 |
new WpRocket(); |
| 123 |
new Addons(); |
| 124 |
new Forms(); |
| 125 |
new OverrideEmail(); |
| 126 |
new Cron(); |
| 127 |
new Gutenberg(); |
| 128 |
new Security(); |
| 129 |
new Deactivate(); |
| 130 |
new Oauth(); |
| 131 |
} |
| 132 |
|
| 133 |
private function isCurrentlyOnAcyPage(): bool |
| 134 |
{ |
| 135 |
// Make sure we're on an AcyMailing page |
| 136 |
$page = isset($_REQUEST['page']) ? sanitize_text_field(wp_unslash($_REQUEST['page'])) : ''; |
| 137 |
|
| 138 |
return !empty($page) && strpos($page, 'acymailing_') !== false; |
| 139 |
} |
| 140 |
} |
| 141 |
|
| 142 |
new acymailingLoader(); |
| 143 |
|