126 lines
3.6 KiB
PHP
126 lines
3.6 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: SMTP (by ROBOTSTXT)
|
|
* Plugin URI: https://www.robotstxt.software/plugins/robotstxt-smtp/
|
|
* Description: Configure WordPress to send emails through SMTP with detailed controls.
|
|
* Version: 2.2.4
|
|
* Requires at least: 5.9
|
|
* Requires PHP: 8.0
|
|
* Network: true
|
|
* Security: robotstxt@robotstxt.es
|
|
* Author: ROBOTSTXT
|
|
* Author URI: https://www.robotstxt.software/
|
|
* Text Domain: robotstxt-smtp
|
|
* Domain Path: /languages
|
|
* License: GPL-3.0-or-later
|
|
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
|
* Update URI: https://www.robotstxt.software/plugins/robotstxt-smtp/
|
|
*
|
|
* @package Robotstxt_SMTP
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
if ( ! defined( 'ROBOTSTXT_SMTP_VERSION' ) ) {
|
|
define( 'ROBOTSTXT_SMTP_VERSION', '2.2.4' );
|
|
}
|
|
|
|
if ( ! defined( 'ROBOTSTXT_SMTP_FILE' ) ) {
|
|
define( 'ROBOTSTXT_SMTP_FILE', __FILE__ );
|
|
}
|
|
|
|
if ( ! defined( 'ROBOTSTXT_SMTP_URL' ) ) {
|
|
define( 'ROBOTSTXT_SMTP_URL', plugin_dir_url( __FILE__ ) );
|
|
}
|
|
|
|
if ( ! defined( 'ROBOTSTXT_SMTP_PATH' ) ) {
|
|
define( 'ROBOTSTXT_SMTP_PATH', plugin_dir_path( __FILE__ ) );
|
|
}
|
|
|
|
if ( ! defined( 'ROBOTSTXT_SMTP_SLUG' ) ) {
|
|
define( 'ROBOTSTXT_SMTP_SLUG', 'robotstxt-smtp' );
|
|
}
|
|
|
|
if ( ! defined( 'ROBOTSTXT_SMTP_BASENAME' ) ) {
|
|
define( 'ROBOTSTXT_SMTP_BASENAME', plugin_basename( ROBOTSTXT_SMTP_FILE ) );
|
|
}
|
|
|
|
if ( ! defined( 'ROBOTSTXT_SMTP_IS_MULTISITE' ) ) {
|
|
define( 'ROBOTSTXT_SMTP_IS_MULTISITE', is_multisite() );
|
|
}
|
|
|
|
if ( ! class_exists( 'PHPMailer\PHPMailer\PHPMailer' ) ) {
|
|
require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php';
|
|
}
|
|
|
|
if ( ! class_exists( 'PHPMailer\PHPMailer\Exception' ) ) {
|
|
require_once ABSPATH . WPINC . '/PHPMailer/Exception.php';
|
|
}
|
|
|
|
if ( ! class_exists( 'PHPMailer\PHPMailer\SMTP' ) ) {
|
|
require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php';
|
|
}
|
|
|
|
require_once ROBOTSTXT_SMTP_PATH . 'includes/class-robotstxt-smtp-encryption.php';
|
|
require_once ROBOTSTXT_SMTP_PATH . 'includes/class-smtp-diagnostics-client.php';
|
|
require_once ROBOTSTXT_SMTP_PATH . 'includes/class-statistics.php';
|
|
require_once ROBOTSTXT_SMTP_PATH . 'includes/class-settings-page.php';
|
|
require_once ROBOTSTXT_SMTP_PATH . 'includes/class-plugin.php';
|
|
|
|
if ( ! function_exists( 'robotstxt_smtp_dependencies_satisfied' ) ) {
|
|
/**
|
|
* Determines whether the plugin dependencies are available.
|
|
*
|
|
* @since 1.1.1
|
|
*
|
|
* @return bool
|
|
*/
|
|
function robotstxt_smtp_dependencies_satisfied(): bool {
|
|
return class_exists( '\\PHPMailer\\PHPMailer\\PHPMailer' );
|
|
}
|
|
}
|
|
|
|
if ( ! function_exists( 'robotstxt_smtp_register_dependency_notice' ) ) {
|
|
/**
|
|
* Registers an admin notice when dependencies are missing.
|
|
*
|
|
* @since 1.1.1
|
|
*
|
|
* @return void
|
|
*/
|
|
function robotstxt_smtp_register_dependency_notice(): void {
|
|
if ( ! is_admin() ) {
|
|
return;
|
|
}
|
|
|
|
$callback = static function (): void {
|
|
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
|
|
|
|
if ( $screen && 'plugins' !== $screen->id && 'plugins-network' !== $screen->id ) {
|
|
return;
|
|
}
|
|
|
|
$message = sprintf(
|
|
/* translators: %s: plugin name. */
|
|
esc_html__( 'The %s plugin requires the PHPMailer library to be available.', 'robotstxt-smtp' ),
|
|
esc_html__( 'ROBOTSTXT SMTP', 'robotstxt-smtp' )
|
|
);
|
|
?>
|
|
<div class="notice notice-error">
|
|
<p><?php echo esc_html( $message ); ?></p>
|
|
</div>
|
|
<?php
|
|
};
|
|
|
|
add_action( 'admin_notices', $callback );
|
|
add_action( 'network_admin_notices', $callback );
|
|
}
|
|
}
|
|
|
|
if ( robotstxt_smtp_dependencies_satisfied() ) {
|
|
\Robotstxt_SMTP\Plugin::get_instance()->run();
|
|
} else {
|
|
robotstxt_smtp_register_dependency_notice();
|
|
}
|