Remove static usage of WP functions
[MAILPOET-3808]
This commit is contained in:
@@ -84,6 +84,9 @@ class Initializer {
|
||||
/** @var AutomaticEmails */
|
||||
private $automaticEmails;
|
||||
|
||||
/** @var WPFunctions */
|
||||
private $wpFunctions;
|
||||
|
||||
/** @var AssetsLoader */
|
||||
private $assetsLoader;
|
||||
|
||||
@@ -122,6 +125,7 @@ class Initializer {
|
||||
Localizer $localizer,
|
||||
AutomaticEmails $automaticEmails,
|
||||
SubscriberActivityTracker $subscriberActivityTracker,
|
||||
WPFunctions $wpFunctions,
|
||||
AssetsLoader $assetsLoader,
|
||||
Engine $automationEngine,
|
||||
MailPoetIntegration $automationMailPoetIntegration,
|
||||
@@ -147,6 +151,7 @@ class Initializer {
|
||||
$this->localizer = $localizer;
|
||||
$this->automaticEmails = $automaticEmails;
|
||||
$this->subscriberActivityTracker = $subscriberActivityTracker;
|
||||
$this->wpFunctions = $wpFunctions;
|
||||
$this->assetsLoader = $assetsLoader;
|
||||
$this->automationEngine = $automationEngine;
|
||||
$this->automationMailPoetIntegration = $automationMailPoetIntegration;
|
||||
@@ -161,7 +166,7 @@ class Initializer {
|
||||
$this->databaseInitializer->initializeConnection();
|
||||
} catch (\Exception $e) {
|
||||
return WPNotice::displayError(Helpers::replaceLinkTags(
|
||||
WPFunctions::get()->__('Unable to connect to the database (the database is unable to open a file or folder), the connection is likely not configured correctly. Please read our [link] Knowledge Base article [/link] for steps how to resolve it.', 'mailpoet'),
|
||||
__('Unable to connect to the database (the database is unable to open a file or folder), the connection is likely not configured correctly. Please read our [link] Knowledge Base article [/link] for steps how to resolve it.', 'mailpoet'),
|
||||
'https://kb.mailpoet.com/article/200-solving-database-connection-issues',
|
||||
[
|
||||
'target' => '_blank',
|
||||
@@ -171,7 +176,7 @@ class Initializer {
|
||||
}
|
||||
|
||||
// activation function
|
||||
WPFunctions::get()->registerActivationHook(
|
||||
$this->wpFunctions->registerActivationHook(
|
||||
Env::$file,
|
||||
[
|
||||
$this,
|
||||
@@ -179,37 +184,37 @@ class Initializer {
|
||||
]
|
||||
);
|
||||
|
||||
WPFunctions::get()->addAction('activated_plugin', [
|
||||
$this->wpFunctions->addAction('activated_plugin', [
|
||||
new PluginActivatedHook(new DeferredAdminNotices),
|
||||
'action',
|
||||
], 10, 2);
|
||||
|
||||
WPFunctions::get()->addAction('init', [
|
||||
$this->wpFunctions->addAction('init', [
|
||||
$this,
|
||||
'preInitialize',
|
||||
], 0);
|
||||
|
||||
WPFunctions::get()->addAction('init', [
|
||||
$this->wpFunctions->addAction('init', [
|
||||
$this,
|
||||
'initialize',
|
||||
]);
|
||||
|
||||
WPFunctions::get()->addAction('admin_init', [
|
||||
$this->wpFunctions->addAction('admin_init', [
|
||||
$this,
|
||||
'setupPrivacyPolicy',
|
||||
]);
|
||||
|
||||
WPFunctions::get()->addAction('wp_loaded', [
|
||||
$this->wpFunctions->addAction('wp_loaded', [
|
||||
$this,
|
||||
'postInitialize',
|
||||
]);
|
||||
|
||||
WPFunctions::get()->addAction('admin_init', [
|
||||
$this->wpFunctions->addAction('admin_init', [
|
||||
new DeferredAdminNotices,
|
||||
'printAndClean',
|
||||
]);
|
||||
|
||||
WPFunctions::get()->addFilter('wpmu_drop_tables', [
|
||||
$this->wpFunctions->addFilter('wpmu_drop_tables', [
|
||||
$this,
|
||||
'multisiteDropTables',
|
||||
]);
|
||||
@@ -247,7 +252,7 @@ class Initializer {
|
||||
}
|
||||
|
||||
public function setupWidget() {
|
||||
WPFunctions::get()->registerWidget('\MailPoet\Form\Widget');
|
||||
$this->wpFunctions->registerWidget('\MailPoet\Form\Widget');
|
||||
}
|
||||
|
||||
public function initialize() {
|
||||
@@ -279,7 +284,7 @@ class Initializer {
|
||||
$this->automationEngine->initialize();
|
||||
}
|
||||
|
||||
WPFunctions::get()->doAction('mailpoet_initialized', MAILPOET_VERSION);
|
||||
$this->wpFunctions->doAction('mailpoet_initialized', MAILPOET_VERSION);
|
||||
} catch (InvalidStateException $e) {
|
||||
return $this->handleRunningMigration($e);
|
||||
} catch (\Exception $e) {
|
||||
@@ -337,7 +342,7 @@ class Initializer {
|
||||
}
|
||||
|
||||
public function setupImages() {
|
||||
WPFunctions::get()->addImageSize('mailpoet_newsletter_max', Env::NEWSLETTER_CONTENT_WIDTH);
|
||||
$this->wpFunctions->addImageSize('mailpoet_newsletter_max', Env::NEWSLETTER_CONTENT_WIDTH);
|
||||
}
|
||||
|
||||
public function setupCronTrigger() {
|
||||
@@ -364,8 +369,8 @@ class Initializer {
|
||||
}
|
||||
|
||||
public function setupUserLocale() {
|
||||
if (get_user_locale() === WPFunctions::get()->getLocale()) return;
|
||||
WPFunctions::get()->unloadTextdomain(Env::$pluginName);
|
||||
if (get_user_locale() === $this->wpFunctions->getLocale()) return;
|
||||
$this->wpFunctions->unloadTextdomain(Env::$pluginName);
|
||||
$this->localizer->init();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user