plugin_url = rtrim( plugin_dir_url( __DIR__ ), '/\\' ); $this->plugin_path = rtrim( plugin_dir_path( __DIR__ ), '/\\' ); $this->hooks(); } /** * Assign all hooks to proper places. * * @since 1.0.0 */ public function hooks() { // Activation hook. add_action( 'activate_wp-mail-smtp/wp_mail_smtp.php', array( $this, 'activate' ) ); // Redefine PHPMailer. add_action( 'plugins_loaded', array( $this, 'get_processor' ) ); add_action( 'plugins_loaded', array( $this, 'replace_phpmailer' ) ); // Awesome Motive Notifications. add_action( 'plugins_loaded', array( $this, 'init_notifications' ) ); // Recommendations. if ( ! class_exists( '\WPMailSMTP\TGM_Plugin_Activation', false ) ) { require_once __DIR__ . '/TGMPA.php'; } add_action( 'wpms_tgmpa_register', array( $this, 'init_recommendations' ) ); add_action( 'init', array( $this, 'init' ) ); } /** * Initial plugin actions. * * @since 1.0.0 */ public function init() { // Load translations just in case. load_plugin_textdomain( 'wp-mail-smtp', false, plugin_basename( wp_mail_smtp()->plugin_path ) . '/languages' ); /* * Constantly check in admin area, that we don't need to upgrade DB. * Do not wait for the `admin_init` hook, because some actions are already done * on `plugins_loaded`, so migration has to be done before. * We should not fire this in AJAX requests. */ if ( WP::in_wp_admin() ) { $this->get_migration(); $this->get_upgrade(); $this->detect_conflicts(); } // In admin area, regardless of AJAX or not AJAX request. if ( is_admin() ) { $this->get_admin(); } // Plugin admin area notices. Display to "admins" only. if ( current_user_can( 'manage_options' ) ) { add_action( 'admin_notices', array( '\WPMailSMTP\WP', 'display_admin_notices' ) ); add_action( 'admin_notices', array( $this, 'display_debug_notices' ) ); } } /** * Load the plugin core processor. * * @since 1.0.0 * * @return Processor */ public function get_processor() { static $processor; if ( ! isset( $processor ) ) { $processor = apply_filters( 'wp_mail_smtp_core_get_processor', new Processor() ); } return $processor; } /** * Load the plugin admin area. * * @since 1.0.0 * * @return Admin\Area */ public function get_admin() { static $admin; if ( ! isset( $admin ) ) { $admin = apply_filters( 'wp_mail_smtp_core_get_admin', new Admin\Area() ); } return $admin; } /** * Load the plugin providers loader. * * @since 1.0.0 * * @return Providers\Loader */ public function get_providers() { static $providers; if ( ! isset( $providers ) ) { $providers = apply_filters( 'wp_mail_smtp_core_get_providers', new Providers\Loader() ); } return $providers; } /** * Load the plugin option migrator. * * @since 1.0.0 * * @return Migration */ public function get_migration() { static $migration; if ( ! isset( $migration ) ) { $migration = apply_filters( 'wp_mail_smtp_core_get_migration', new Migration() ); } return $migration; } /** * Load the plugin upgrader. * * @since 1.1.0 * * @return Upgrade */ public function get_upgrade() { static $upgrade; if ( ! isset( $upgrade ) ) { $upgrade = apply_filters( 'wp_mail_smtp_core_get_upgrade', new Upgrade() ); } return $upgrade; } /** * Awesome Motive Notifications. * * @since 1.0.0 */ public function init_notifications() { if ( Options::init()->get( 'general', 'am_notifications_hidden' ) ) { return; } static $notification; if ( ! isset( $notification ) ) { $notification = new AM_Notification( 'smtp', WPMS_PLUGIN_VER ); } } /** * Recommend WPForms Lite using TGM Activation. * * @since 1.3.0 */ public function init_recommendations() { // Recommend only for new installs. if ( ! $this->is_new_install() ) { return; } // Specify a plugin that we want to recommend. $plugins = apply_filters( 'wp_mail_smtp_core_recommendations_plugins', array( array( 'name' => 'Contact Form by WPForms', 'slug' => 'wpforms-lite', 'required' => false, 'is_callable' => 'wpforms', // This will target the Pro version as well, not only the one from WP.org repository. ), ) ); /* * Array of configuration settings. */ $config = apply_filters( 'wp_mail_smtp_core_recommendations_config', array( 'id' => 'wp-mail-smtp', // Unique ID for hashing notices for multiple instances of TGMPA. 'menu' => 'wp-mail-smtp-install-plugins', // Menu slug. 'parent_slug' => 'plugins.php', // Parent menu slug. 'capability' => 'manage_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used. 'has_notices' => true, // Show admin notices or not. 'dismissable' => true, // If false, a user cannot dismiss the nag message. 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. 'is_automatic' => false, // Automatically activate plugins after installation or not. 'message' => '', // Message to output right before the plugins table. 'strings' => array( /* translators: 1: plugin name(s). */ 'notice_can_install_recommended' => _n_noop( 'Thanks for installing WP Mail SMTP. We also recommend using %1$s. It\'s the best drag & drop form builder, has over 1 million active installs, and over 2000+ 5 star ratings.', 'Thanks for installing WP Mail SMTP. We also recommend using %1$s. It\'s the best drag & drop form builder, has over 1 million active installs, and over 2000+ 5 star ratings.', 'wp-mail-smtp' ), /* translators: 1: plugin name(s). */ 'notice_can_activate_recommended' => _n_noop( 'Thanks for installing WP Mail SMTP. We also recommend using %1$s. It\'s the best drag & drop form builder, has over 1 million active installs, and over 2000+ 5 star ratings.', 'Thanks for installing WP Mail SMTP. We also recommend using %1$s. It\'s the best drag & drop form builder, has over 1 million active installs, and over 2000+ 5 star ratings.', 'wp-mail-smtp' ), 'install_link' => _n_noop( 'Install WPForms Now', 'Begin installing plugins', 'wp-mail-smtp' ), 'activate_link' => _n_noop( 'Activate WPForms', 'Begin activating plugins', 'wp-mail-smtp' ), 'nag_type' => 'notice-info', ), ) ); \WPMailSMTP\tgmpa( (array) $plugins, (array) $config ); } /** * Display all debug mail-delivery related notices. * * @since 1.3.0 */ public static function display_debug_notices() { $notice = Debug::get_last(); if ( empty( $notice ) ) { return; } ?>
EMAIL DELIVERY ERROR: WP Mail SMTP plugin logged this error during the last time it tried to send an email: ', 'wp-mail-smtp' ), array( 'strong' => array(), ) ); ?>
get_admin()->is_admin_page() ) { printf( wp_kses( /* translators: %s - plugin admin page URL. */ __( 'Please review your WP Mail SMTP settings in plugin admin area.' ) . ' ', array( 'a' => array( 'href' => array(), ), ) ), wp_mail_smtp()->get_admin()->get_admin_page_url() ); } esc_html_e( 'Consider running an email test after fixing it.', 'wp-mail-smtp' ); ?>