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