Plugins
This commit is contained in:
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Compatibility;
|
||||
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
* Compatibility.
|
||||
* Class for managing compatibility with other plugins.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
class Compatibility {
|
||||
|
||||
/**
|
||||
* Initialized compatibility plugins.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $plugins = [];
|
||||
|
||||
/**
|
||||
* Initialize class.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function init() {
|
||||
|
||||
$this->setup_compatibility();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup compatibility plugins.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function setup_compatibility() {
|
||||
|
||||
$plugins = [
|
||||
'admin-2020' => '\WPMailSMTP\Compatibility\Plugin\Admin2020',
|
||||
'wpforms-lite' => '\WPMailSMTP\Compatibility\Plugin\WPFormsLite',
|
||||
'wpforms' => '\WPMailSMTP\Compatibility\Plugin\WPForms',
|
||||
'woocommerce' => '\WPMailSMTP\Compatibility\Plugin\WooCommerce',
|
||||
];
|
||||
|
||||
foreach ( $plugins as $key => $classname ) {
|
||||
if ( class_exists( $classname ) && is_callable( [ $classname, 'is_applicable' ] ) ) {
|
||||
if ( $classname::is_applicable() ) {
|
||||
$this->plugins[ $key ] = new $classname();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get compatibility plugin.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param string $key Plugin key.
|
||||
*
|
||||
* @return \WPMailSMTP\Compatibility\Plugin\PluginAbstract | false
|
||||
*/
|
||||
public function get_plugin( $key ) {
|
||||
|
||||
return isset( $this->plugins[ $key ] ) ? $this->plugins[ $key ] : false;
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Compatibility\Plugin;
|
||||
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
* Admin 2020 Lite compatibility plugin.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
class Admin2020 extends PluginAbstract {
|
||||
|
||||
/**
|
||||
* If plugin can be loaded.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_applicable() {
|
||||
|
||||
return parent::is_applicable() && WP::in_wp_admin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin name.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
|
||||
return 'Admin 2020';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin path.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_path() {
|
||||
|
||||
return 'admin-2020/admin-2020.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute on init action in admin area.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function load_admin() {
|
||||
|
||||
add_action( 'wp_mail_smtp_admin_setup_wizard_load_setup_wizard_before', [ $this, 'disable_admin_bar' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable admin bar on Setup Wizard page.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function disable_admin_bar() {
|
||||
|
||||
global $wp_admin_bar;
|
||||
$wp_admin_bar = ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Compatibility\Plugin;
|
||||
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
* Compatibility plugin.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
abstract class PluginAbstract implements PluginInterface {
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
add_action( 'init', [ $this, 'load' ], 0 );
|
||||
|
||||
if ( WP::in_wp_admin() ) {
|
||||
add_action( 'init', [ $this, 'load_admin' ], 0 );
|
||||
}
|
||||
|
||||
$this->after_plugins_loaded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is plugin can be loaded.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_applicable() {
|
||||
|
||||
return static::is_activated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is plugin activated.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_activated() {
|
||||
|
||||
return WP::is_plugin_activated( static::get_path() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute after plugins loaded.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function after_plugins_loaded() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute on init action in admin area.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function load_admin() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute on init action.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function load() {
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Compatibility\Plugin;
|
||||
|
||||
/**
|
||||
* Compatibility plugin interface.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
interface PluginInterface {
|
||||
|
||||
/**
|
||||
* Is plugin can be loaded.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_applicable();
|
||||
|
||||
/**
|
||||
* Is plugin activated.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_activated();
|
||||
|
||||
/**
|
||||
* Execute after plugins loaded.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function after_plugins_loaded();
|
||||
|
||||
/**
|
||||
* Execute on init action in admin area.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function load_admin();
|
||||
|
||||
/**
|
||||
* Execute on init action.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function load();
|
||||
|
||||
/**
|
||||
* Get plugin name.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name();
|
||||
|
||||
/**
|
||||
* Get plugin path.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_path();
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Compatibility\Plugin;
|
||||
|
||||
/**
|
||||
* WPForms compatibility plugin.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class WPForms extends WPFormsLite {
|
||||
|
||||
/**
|
||||
* Get plugin name.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
|
||||
return 'WPForms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin path.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_path() {
|
||||
|
||||
return 'wpforms/wpforms.php';
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Compatibility\Plugin;
|
||||
|
||||
/**
|
||||
* WPForms Lite compatibility plugin.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class WPFormsLite extends PluginAbstract {
|
||||
|
||||
/**
|
||||
* Get plugin name.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
|
||||
return 'WPForms Lite';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin path.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_path() {
|
||||
|
||||
return 'wpforms-lite/wpforms.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute on init action.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function load() { // phpcs:ignore WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks
|
||||
|
||||
if ( wp_mail_smtp()->get_queue()->is_enabled() ) {
|
||||
add_filter( 'wpforms_tasks_entry_emails_trigger_send_same_process', '__return_true', PHP_INT_MAX );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Compatibility\Plugin;
|
||||
|
||||
/**
|
||||
* WooCommerce compatibility plugin.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class WooCommerce extends PluginAbstract {
|
||||
|
||||
/**
|
||||
* Get plugin name.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
|
||||
return 'WooCommerce';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin path.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_path() {
|
||||
|
||||
return 'woocommerce/woocommerce.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute on init action.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function load() { // phpcs:ignore WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks
|
||||
|
||||
if ( wp_mail_smtp()->get_queue()->is_enabled() ) {
|
||||
add_filter( 'woocommerce_defer_transactional_emails', '__return_false', PHP_INT_MAX );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user