installed plugin Easy Digital Downloads
version 3.1.0.3
This commit is contained in:
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* Email Marketing
|
||||
*
|
||||
* Manages automatic installation/activation for email marketing extensions.
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage EmailMarketing
|
||||
* @copyright Copyright (c) 2021, Easy Digital Downloads
|
||||
* @license https://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 2.11.4
|
||||
*/
|
||||
namespace EDD\Admin\Settings;
|
||||
|
||||
use \EDD\Admin\Extensions\Extension;
|
||||
|
||||
class EmailMarketing extends Extension {
|
||||
|
||||
/**
|
||||
* The EDD settings tab where this extension should show.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @var string
|
||||
*/
|
||||
protected $settings_tab = 'marketing';
|
||||
|
||||
/**
|
||||
* The settings section for this item.
|
||||
*
|
||||
* @since 2.11.5
|
||||
* @var string
|
||||
*/
|
||||
protected $settings_section = 'email_marketing';
|
||||
|
||||
public function __construct() {
|
||||
add_filter( 'edd_settings_sections_marketing', array( $this, 'add_section' ) );
|
||||
add_action( 'edd_settings_tab_top_marketing_email_marketing', array( $this, 'field' ) );
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an email marketing section to the Marketing tab.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @param array $sections
|
||||
* @return array
|
||||
*/
|
||||
public function add_section( $sections ) {
|
||||
if ( ! $this->is_edd_settings_screen() ) {
|
||||
return $sections;
|
||||
}
|
||||
$product_data = $this->get_product_data();
|
||||
if ( ! $product_data || ! is_array( $product_data ) ) {
|
||||
return $sections;
|
||||
}
|
||||
$sections[ $this->settings_section ] = __( 'Email Marketing', 'easy-digital-downloads' );
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the customized configuration for the extension card.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @param \EDD\Admin\Extensions\ProductData $product_data The product data object.
|
||||
* @return array
|
||||
*/
|
||||
protected function get_configuration( \EDD\Admin\Extensions\ProductData $product_data ) {
|
||||
$configuration = array();
|
||||
if ( ! empty( $product_data->title ) ) {
|
||||
/* translators: the product name */
|
||||
$configuration['title'] = sprintf( __( 'Get %s Today!', 'easy-digital-downloads' ), $product_data->title );
|
||||
}
|
||||
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the email marketing extensions as cards.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @return void
|
||||
*/
|
||||
public function field() {
|
||||
$this->hide_submit_button();
|
||||
if ( $this->is_activated() ) {
|
||||
printf( '<p>%s</p>', esc_html__( 'Looks like you have an email marketing extension installed, but we support more providers!', 'easy-digital-downloads' ) );
|
||||
}
|
||||
?>
|
||||
<div class="edd-extension-manager__card-group">
|
||||
<?php
|
||||
foreach ( $this->get_product_data() as $item_id => $extension ) {
|
||||
$this->do_single_extension_card( $item_id );
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the body array sent to the Products API.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @return array
|
||||
*/
|
||||
protected function get_api_body() {
|
||||
return array(
|
||||
'tag' => 1578,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether any email marketing extension is active.
|
||||
*
|
||||
* @since 2.11.4
|
||||
*
|
||||
* @return bool True if any email marketing extension is active.
|
||||
*/
|
||||
protected function is_activated() {
|
||||
foreach ( $this->get_product_data() as $extension ) {
|
||||
// The data is stored in the database as an array--at this point it has not been converted to an object.
|
||||
if ( ! empty( $extension['basename'] ) && $this->manager->is_plugin_active( $extension['basename'] ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
new EmailMarketing();
|
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoices
|
||||
*
|
||||
* Manages automatic installation/activation for Invoices.
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage Invoices
|
||||
* @copyright Copyright (c) 2021, Easy Digital Downloads
|
||||
* @license https://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 2.11.4
|
||||
*/
|
||||
namespace EDD\Admin\Settings;
|
||||
|
||||
use \EDD\Admin\Extensions\Extension;
|
||||
|
||||
class Invoices extends Extension {
|
||||
|
||||
/**
|
||||
* The product ID on EDD.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $item_id = 375153;
|
||||
|
||||
/**
|
||||
* The EDD settings tab where this extension should show.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @var string
|
||||
*/
|
||||
protected $settings_tab = 'gateways';
|
||||
|
||||
/**
|
||||
* The settings section for this item.
|
||||
*
|
||||
* @since 2.11.5
|
||||
* @var string
|
||||
*/
|
||||
protected $settings_section = 'invoices';
|
||||
|
||||
/**
|
||||
* The pass level required to access this extension.
|
||||
*/
|
||||
const PASS_LEVEL = \EDD\Admin\Pass_Manager::EXTENDED_PASS_ID;
|
||||
|
||||
public function __construct() {
|
||||
add_filter( 'edd_settings_sections_gateways', array( $this, 'add_section' ) );
|
||||
add_action( 'edd_settings_tab_top_gateways_invoices', array( $this, 'settings_field' ) );
|
||||
add_action( 'edd_settings_tab_top_gateways_invoices', array( $this, 'hide_submit_button' ) );
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom configuration for Invoices.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @param \EDD\Admin\Extensions\ProductData $product_data The product data object.
|
||||
* @return array
|
||||
*/
|
||||
protected function get_configuration( \EDD\Admin\Extensions\ProductData $product_data ) {
|
||||
return array(
|
||||
'style' => 'detailed-2col',
|
||||
'title' => 'Attractive Invoices For Your Customers',
|
||||
'description' => $this->get_custom_description(),
|
||||
'features' => array(
|
||||
'Generate Attractive Invoices',
|
||||
'Build Customer Confidence',
|
||||
'PDF Download Support',
|
||||
'Include in Purchase Emails',
|
||||
'Customizable Templates',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a custom description for the Invoices extension card.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @return string
|
||||
*/
|
||||
private function get_custom_description() {
|
||||
$description = array(
|
||||
'Impress customers and build customer loyalty with attractive invoices. Making it easy to locate, save, and print purchase history builds trust with customers.',
|
||||
'Provide a professional experience with customizable templates and one-click PDF downloads. ',
|
||||
);
|
||||
|
||||
return $this->format_description( $description );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the Invoices Payments section to the settings.
|
||||
*
|
||||
* @param array $sections
|
||||
* @return array
|
||||
*/
|
||||
public function add_section( $sections ) {
|
||||
if ( ! $this->can_show_product_section() ) {
|
||||
return $sections;
|
||||
}
|
||||
|
||||
$sections[ $this->settings_section ] = __( 'Invoices', 'easy-digital-downloads' );
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether EDD Invoices active or not.
|
||||
*
|
||||
* @since 2.11.4
|
||||
*
|
||||
* @return bool True if Invoices is active.
|
||||
*/
|
||||
protected function is_activated() {
|
||||
if ( $this->manager->is_plugin_active( $this->get_product_data() ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return class_exists( 'EDDInvoices' );
|
||||
}
|
||||
}
|
||||
|
||||
new Invoices();
|
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* Recurring Payments
|
||||
*
|
||||
* Manages automatic activation for Recurring Payments.
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage Recurring
|
||||
* @copyright Copyright (c) 2021, Easy Digital Downloads
|
||||
* @license https://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 2.11.4
|
||||
*/
|
||||
namespace EDD\Admin\Settings;
|
||||
|
||||
use \EDD\Admin\Extensions\Extension;
|
||||
|
||||
class Recurring extends Extension {
|
||||
|
||||
/**
|
||||
* The product ID on EDD.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $item_id = 28530;
|
||||
|
||||
/**
|
||||
* The EDD settings tab where this extension should show.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @var string
|
||||
*/
|
||||
protected $settings_tab = 'gateways';
|
||||
|
||||
/**
|
||||
* The pass level required to access this extension.
|
||||
*/
|
||||
const PASS_LEVEL = \EDD\Admin\Pass_Manager::EXTENDED_PASS_ID;
|
||||
|
||||
/**
|
||||
* The settings section for this item.
|
||||
*
|
||||
* @since 2.11.5
|
||||
* @var string
|
||||
*/
|
||||
protected $settings_section = 'recurring';
|
||||
|
||||
public function __construct() {
|
||||
add_filter( 'edd_settings_sections_gateways', array( $this, 'add_section' ) );
|
||||
add_action( 'edd_settings_tab_top_gateways_recurring', array( $this, 'settings_field' ) );
|
||||
add_action( 'edd_settings_tab_top_gateways_recurring', array( $this, 'hide_submit_button' ) );
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom configuration for Recurring.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @param \EDD\Admin\Extensions\ProductData $product_data The product data object.
|
||||
* @return array
|
||||
*/
|
||||
protected function get_configuration( \EDD\Admin\Extensions\ProductData $product_data ) {
|
||||
return array(
|
||||
'style' => 'detailed-2col',
|
||||
'title' => 'Increase Revenue By Selling Subscriptions!',
|
||||
'description' => $this->get_custom_description(),
|
||||
'features' => array(
|
||||
'Flexible Recurring Payments',
|
||||
'Custom Reminder Emails',
|
||||
'Free Trial Support',
|
||||
'Signup Fees',
|
||||
'Recurring Revenue Reports',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a custom description for the Recurring extension card.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @return string
|
||||
*/
|
||||
private function get_custom_description() {
|
||||
$description = array(
|
||||
'Grow stable income by selling subscriptions and make renewals hassle free for your customers.',
|
||||
'When your customers are automatically billed, you reduce the risk of missed payments and retain more customers.',
|
||||
);
|
||||
|
||||
return $this->format_description( $description );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the Recurring Payments section to the settings.
|
||||
*
|
||||
* @param array $sections
|
||||
* @return array
|
||||
*/
|
||||
public function add_section( $sections ) {
|
||||
if ( ! $this->can_show_product_section() ) {
|
||||
return $sections;
|
||||
}
|
||||
|
||||
$sections[ $this->settings_section ] = __( 'Recurring Payments', 'easy-digital-downloads' );
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether EDD Recurring active or not.
|
||||
*
|
||||
* @since 2.11.4
|
||||
*
|
||||
* @return bool True if Recurring is active.
|
||||
*/
|
||||
protected function is_activated() {
|
||||
if ( $this->manager->is_plugin_active( $this->get_product_data() ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return class_exists( 'EDD_Recurring' );
|
||||
}
|
||||
}
|
||||
|
||||
new Recurring();
|
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/**
|
||||
* Reviews
|
||||
*
|
||||
* Manages automatic activation for Reviews.
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage Reviews
|
||||
* @copyright Copyright (c) 2021, Easy Digital Downloads
|
||||
* @license https://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 2.11.4
|
||||
*/
|
||||
namespace EDD\Admin\Settings;
|
||||
|
||||
use \EDD\Admin\Extensions\Extension;
|
||||
|
||||
class Reviews extends Extension {
|
||||
|
||||
/**
|
||||
* The product ID on EDD.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $item_id = 37976;
|
||||
|
||||
/**
|
||||
* The EDD settings tab where this extension should show.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @var string
|
||||
*/
|
||||
protected $settings_tab = 'marketing';
|
||||
|
||||
/**
|
||||
* The settings section for this item.
|
||||
*
|
||||
* @since 2.11.5
|
||||
* @var string
|
||||
*/
|
||||
protected $settings_section = 'reviews';
|
||||
|
||||
/**
|
||||
* The pass level required to access this extension.
|
||||
*/
|
||||
const PASS_LEVEL = \EDD\Admin\Pass_Manager::EXTENDED_PASS_ID;
|
||||
|
||||
public function __construct() {
|
||||
add_filter( 'edd_settings_sections_marketing', array( $this, 'add_section' ) );
|
||||
add_action( 'edd_settings_tab_top_marketing_reviews', array( $this, 'settings_field' ) );
|
||||
add_action( 'edd_settings_tab_top_marketing_reviews', array( $this, 'hide_submit_button' ) );
|
||||
add_action( 'add_meta_boxes', array( $this, 'maybe_do_metabox' ) );
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom configuration for Reviews.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @param \EDD\Admin\Extensions\ProductData $product_data The product data object.
|
||||
* @return array
|
||||
*/
|
||||
protected function get_configuration( \EDD\Admin\Extensions\ProductData $product_data ) {
|
||||
$configuration = array(
|
||||
'title' => 'Build Trust With Real Customer Reviews',
|
||||
);
|
||||
$settings_configuration = array(
|
||||
'style' => 'detailed-2col',
|
||||
'description' => $this->get_custom_description(),
|
||||
'features' => array(
|
||||
'Request Reviews',
|
||||
'Incentivize Reviewers',
|
||||
'Full Schema.org Support',
|
||||
'Embed Reviews Via Blocks',
|
||||
'Limit Reviews to Customers',
|
||||
'Vendor Reviews (with Frontend Submissions)',
|
||||
),
|
||||
);
|
||||
return $this->is_edd_settings_screen() ? array_merge( $configuration, $settings_configuration ) : $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a custom description for the Reviews extension card.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @return string
|
||||
*/
|
||||
private function get_custom_description() {
|
||||
$description = array(
|
||||
'Increase sales on your site with social proof. 70% of online shoppers don\'t purchase before reading reviews.',
|
||||
'Easily collect, manage, and beautifully display reviews all from your WordPress dashboard.',
|
||||
);
|
||||
|
||||
return $this->format_description( $description );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the Reviews section to the settings.
|
||||
*
|
||||
* @param array $sections
|
||||
* @return array
|
||||
*/
|
||||
public function add_section( $sections ) {
|
||||
if ( ! $this->can_show_product_section() ) {
|
||||
return $sections;
|
||||
}
|
||||
|
||||
$sections[ $this->settings_section ] = __( 'Reviews', 'easy-digital-downloads' );
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
||||
/**
|
||||
* If Reviews is not active, registers a metabox on individual download edit screen.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_do_metabox() {
|
||||
if ( ! $this->is_download_edit_screen() ) {
|
||||
return;
|
||||
}
|
||||
if ( $this->is_activated() ) {
|
||||
return;
|
||||
}
|
||||
add_meta_box(
|
||||
'edd-reviews-status',
|
||||
__( 'Product Reviews', 'easy-digital-downloads' ),
|
||||
array( $this, 'settings_field' ),
|
||||
'download',
|
||||
'side',
|
||||
'low'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether EDD Reviews active or not.
|
||||
*
|
||||
* @since 2.11.4
|
||||
*
|
||||
* @return bool True if Reviews is active.
|
||||
*/
|
||||
protected function is_activated() {
|
||||
if ( $this->manager->is_plugin_active( $this->get_product_data() ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return function_exists( 'edd_reviews' );
|
||||
}
|
||||
}
|
||||
|
||||
new Reviews();
|
@ -0,0 +1,232 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Mail SMTP
|
||||
*
|
||||
* Manages automatic installation/activation for WP Mail SMTP.
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage WP_SMTP
|
||||
* @copyright Copyright (c) 2021, Easy Digital Downloads
|
||||
* @license https://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 2.11.4
|
||||
*/
|
||||
namespace EDD\Admin\Settings;
|
||||
|
||||
class WP_SMTP {
|
||||
|
||||
/**
|
||||
* Array of configuration data for WP Mail SMTP.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $config = array(
|
||||
'lite_plugin' => 'wp-mail-smtp/wp_mail_smtp.php',
|
||||
'lite_wporg_url' => 'https://wordpress.org/plugins/wp-mail-smtp/',
|
||||
'lite_download_url' => 'https://downloads.wordpress.org/plugin/wp-mail-smtp.zip',
|
||||
'pro_plugin' => 'wp-mail-smtp-pro/wp_mail_smtp.php',
|
||||
'smtp_settings' => 'admin.php?page=wp-mail-smtp',
|
||||
'smtp_wizard' => 'admin.php?page=wp-mail-smtp-setup-wizard',
|
||||
);
|
||||
|
||||
/**
|
||||
* The Extension Manager
|
||||
*
|
||||
* @var \EDD\Admin\Extensions\Extension_Manager
|
||||
*/
|
||||
private $manager;
|
||||
|
||||
public function __construct() {
|
||||
add_filter( 'edd_settings_emails', array( $this, 'register_setting' ) );
|
||||
add_action( 'edd_wpsmtp', array( $this, 'settings_field' ) );
|
||||
|
||||
$this->manager = new \EDD\Admin\Extensions\Extension_Manager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the setting to show the WP SMTP installer if it isn't active.
|
||||
*
|
||||
* @param array $settings
|
||||
* @return array
|
||||
*/
|
||||
public function register_setting( $settings ) {
|
||||
if ( $this->is_smtp_configured() ) {
|
||||
return $settings;
|
||||
}
|
||||
$settings['main']['wpsmtp'] = array(
|
||||
'id' => 'wpsmtp',
|
||||
'name' => __( 'Improve Email Deliverability', 'easy-digital-downloads' ),
|
||||
'desc' => '',
|
||||
'type' => 'hook',
|
||||
);
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the settings field (installation helper).
|
||||
*
|
||||
* @param array $args
|
||||
* @return void
|
||||
*/
|
||||
public function settings_field( $args ) {
|
||||
$this->manager->enqueue();
|
||||
?>
|
||||
<div class="edd-extension-manager__body">
|
||||
<p class="edd-extension-manager__description">
|
||||
<?php esc_html_e( 'WP Mail SMTP allows you to easily set up WordPress to use a trusted provider to reliably send emails, including sales notifications.', 'easy-digital-downloads' ); ?>
|
||||
</p>
|
||||
|
||||
<div class="edd-extension-manager__group">
|
||||
<div class="edd-extension-manager__step">
|
||||
<?php $this->manager->button( $this->get_button_parameters() ); ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ( $this->is_smtp_activated() ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="edd-extension-manager__step" style="display:none;">
|
||||
<?php $this->manager->link( $this->get_link_parameters() ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the button parameters.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_button_parameters() {
|
||||
$button = array();
|
||||
// If neither the lite nor pro plugin is installed, the button will prompt to install and activate the lite plugin.
|
||||
if ( ! $this->manager->is_plugin_installed( $this->config['lite_plugin'] ) && ! $this->manager->is_plugin_installed( $this->config['pro_plugin'] ) ) {
|
||||
$button['plugin'] = $this->config['lite_download_url'];
|
||||
$button['action'] = 'install';
|
||||
$button['button_text'] = __( 'Install & Activate WP Mail SMTP', 'easy-digital-downloads' );
|
||||
} elseif ( ! $this->is_smtp_activated() ) {
|
||||
// If one of the SMTP plugins is installed, but not activated, the button will prompt to activate it.
|
||||
$button['plugin'] = $this->config['lite_plugin'];
|
||||
$button['action'] = 'activate';
|
||||
$button['button_text'] = __( 'Activate WP Mail SMTP', 'easy-digital-downloads' );
|
||||
} elseif ( ! $this->is_smtp_configured() ) {
|
||||
// If the plugin is active, but not configured, the button will send them to the setup wizard.
|
||||
$button = $this->get_link_parameters();
|
||||
}
|
||||
|
||||
return $button;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the array of parameters for the link to configure WP Mail SMTP.
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @return array
|
||||
*/
|
||||
private function get_link_parameters() {
|
||||
return $this->is_smtp_configured() ?
|
||||
array(
|
||||
'button_text' => __( 'Configure WP Mail SMTP', 'easy-digital-downloads' ),
|
||||
'href' => admin_url( $this->config['smtp_settings'] ),
|
||||
) :
|
||||
array(
|
||||
'button_text' => __( 'Run the WP Mail SMTP Setup Wizard', 'easy-digital-downloads' ),
|
||||
'href' => admin_url( $this->config['smtp_wizard'] ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether WP Mail SMTP plugin configured or not.
|
||||
*
|
||||
* @since 2.11.4
|
||||
*
|
||||
* @return bool True if some mailer is selected and configured properly.
|
||||
*/
|
||||
protected function is_smtp_configured() {
|
||||
|
||||
if ( ! $this->is_smtp_activated() || ! class_exists( '\\WPMailSMTP\\Options' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$phpmailer = $this->get_phpmailer();
|
||||
|
||||
$mailer = \WPMailSMTP\Options::init()->get( 'mail', 'mailer' );
|
||||
$is_mailer_complete = ! empty( $mailer ) && wp_mail_smtp()->get_providers()->get_mailer( $mailer, $phpmailer )->is_mailer_complete();
|
||||
|
||||
return 'mail' !== $mailer && $is_mailer_complete;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether WP Mail SMTP plugin active or not.
|
||||
*
|
||||
* @since 2.11.4
|
||||
*
|
||||
* @return bool True if SMTP plugin is active.
|
||||
*/
|
||||
protected function is_smtp_activated() {
|
||||
return function_exists( 'wp_mail_smtp' ) && ( is_plugin_active( $this->config['lite_plugin'] ) || is_plugin_active( $this->config['pro_plugin'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get $phpmailer instance.
|
||||
*
|
||||
* @since 2.11.4
|
||||
*
|
||||
* @return \PHPMailer|\PHPMailer\PHPMailer\PHPMailer Instance of PHPMailer.
|
||||
*/
|
||||
protected function get_phpmailer() {
|
||||
|
||||
if ( version_compare( get_bloginfo( 'version' ), '5.5-alpha', '<' ) ) {
|
||||
$phpmailer = $this->get_phpmailer_v5();
|
||||
} else {
|
||||
$phpmailer = $this->get_phpmailer_v6();
|
||||
}
|
||||
|
||||
return $phpmailer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get $phpmailer v5 instance.
|
||||
*
|
||||
* @since 2.11.4
|
||||
*
|
||||
* @return \PHPMailer Instance of PHPMailer.
|
||||
*/
|
||||
private function get_phpmailer_v5() {
|
||||
|
||||
global $phpmailer;
|
||||
|
||||
if ( ! ( $phpmailer instanceof \PHPMailer ) ) {
|
||||
require_once ABSPATH . WPINC . '/class-phpmailer.php';
|
||||
require_once ABSPATH . WPINC . '/class-smtp.php';
|
||||
$phpmailer = new \PHPMailer( true ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||
}
|
||||
|
||||
return $phpmailer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get $phpmailer v6 instance.
|
||||
*
|
||||
* @since 2.11.4
|
||||
*
|
||||
* @return \PHPMailer\PHPMailer\PHPMailer Instance of PHPMailer.
|
||||
*/
|
||||
private function get_phpmailer_v6() {
|
||||
|
||||
global $phpmailer;
|
||||
|
||||
if ( ! ( $phpmailer instanceof \PHPMailer\PHPMailer\PHPMailer ) ) {
|
||||
require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php';
|
||||
require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php';
|
||||
require_once ABSPATH . WPINC . '/PHPMailer/Exception.php';
|
||||
$phpmailer = new \PHPMailer\PHPMailer\PHPMailer( true ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||
}
|
||||
|
||||
return $phpmailer;
|
||||
}
|
||||
}
|
||||
|
||||
new WP_SMTP();
|
Reference in New Issue
Block a user