robotstxt-smtp-amazonses/robotstxt-smtp-amazonses.php
2025-11-26 13:39:30 +00:00

115 lines
3.5 KiB
PHP

<?php
/**
* Plugin Name: SMTP Amazon SES (by ROBOTSTXT)
* Plugin URI: https://www.robotstxt.es/
* Description: Adds Amazon SES configuration support to the ROBOTSTXT SMTP plugin.
* Version: 1.0.0
* Requires at least: 6.0
* Requires PHP: 8.2
* Author: ROBOTSTXT
* Author URI: https://www.robotstxt.es/
* Text Domain: robotstxt-smtp-amazonses
* Domain Path: /languages
* Requires Plugins: robotstxt-smtp
* License: GPL-3.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Gitea Plugin URI: ROBOTSTXT/robotstxt-smtp-amazonses
* Gitea Plugin URI: https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp-amazonses
* Plugin ID: did:plc:z74fjcsglfynz7grselq5xos
*
* @package Robotstxt_SMTP_AmazonSES
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! defined( 'ROBOTSTXT_SMTP_AMAZONSES_VERSION' ) ) {
define( 'ROBOTSTXT_SMTP_AMAZONSES_VERSION', '1.0.0' );
}
if ( ! defined( 'ROBOTSTXT_SMTP_AMAZONSES_FILE' ) ) {
define( 'ROBOTSTXT_SMTP_AMAZONSES_FILE', __FILE__ );
}
if ( ! defined( 'ROBOTSTXT_SMTP_AMAZONSES_PATH' ) ) {
define( 'ROBOTSTXT_SMTP_AMAZONSES_PATH', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'ROBOTSTXT_SMTP_AMAZONSES_URL' ) ) {
define( 'ROBOTSTXT_SMTP_AMAZONSES_URL', plugin_dir_url( __FILE__ ) );
}
if ( ! defined( 'ROBOTSTXT_SMTP_AMAZONSES_SLUG' ) ) {
define( 'ROBOTSTXT_SMTP_AMAZONSES_SLUG', 'robotstxt-smtp-amazonses' );
}
if ( ! defined( 'ROBOTSTXT_SMTP_AMAZONSES_BASENAME' ) ) {
define( 'ROBOTSTXT_SMTP_AMAZONSES_BASENAME', plugin_basename( ROBOTSTXT_SMTP_AMAZONSES_FILE ) );
}
$autoload = ROBOTSTXT_SMTP_AMAZONSES_PATH . 'vendor/autoload.php';
if ( \is_readable( $autoload ) ) {
require_once $autoload;
}
require_once ROBOTSTXT_SMTP_AMAZONSES_PATH . 'includes/class-plugin.php';
if ( ! function_exists( 'robotstxt_smtp_amazonses_dependencies_satisfied' ) ) {
/**
* Determines whether all plugin dependencies are available.
*
* @since 1.0.1
*
* @return bool
*/
function robotstxt_smtp_amazonses_dependencies_satisfied(): bool {
return class_exists( '\\Robotstxt_SMTP\\Plugin' ) && class_exists( '\\Robotstxt_SMTP\\Admin\\Settings_Page' );
}
}
if ( ! function_exists( 'robotstxt_smtp_amazonses_register_dependency_notice' ) ) {
/**
* Registers the admin notice shown when the core plugin is missing.
*
* @since 1.0.1
*
* @return void
*/
function robotstxt_smtp_amazonses_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 add-on requires the ROBOTSTXT SMTP plugin to be installed and active.', 'robotstxt-smtp-amazonses' ),
esc_html__( 'ROBOTSTXT SMTP Amazon SES', 'robotstxt-smtp-amazonses' )
);
?>
<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_amazonses_dependencies_satisfied() ) {
\Robotstxt_SMTP_AmazonSES\Plugin::get_instance()->run();
} else {
robotstxt_smtp_amazonses_register_dependency_notice();
}