From 3a1c1adcc5aef8b0256960e6643f17f8a790ad77 Mon Sep 17 00:00:00 2001 From: yehudah Date: Tue, 11 Aug 2020 21:39:07 +0000 Subject: WordPress 5.5 compatibility --- Postman/Phpmailer/PostsmtpMailer.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'Postman') diff --git a/Postman/Phpmailer/PostsmtpMailer.php b/Postman/Phpmailer/PostsmtpMailer.php index b8227d5..cbea5f8 100644 --- a/Postman/Phpmailer/PostsmtpMailer.php +++ b/Postman/Phpmailer/PostsmtpMailer.php @@ -3,10 +3,30 @@ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } -if ( ! class_exists( 'PHPMailer', false ) ) { - require_once ABSPATH . WPINC . '/class-phpmailer.php'; +if ( version_compare( get_bloginfo( 'version' ), '5.5-alpha', '<' ) ) { + if ( ! class_exists( '\PHPMailer', false ) ) { + require_once ABSPATH . WPINC . '/class-phpmailer.php'; + } + +} else { + if ( ! class_exists( '\PHPMailer\PHPMailer\PHPMailer', false ) ) { + require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php'; + } + + if ( ! class_exists( '\PHPMailer\PHPMailer\Exception', false ) ) { + require_once ABSPATH . WPINC . '/PHPMailer/Exception.php'; + } + + if ( ! class_exists( '\PHPMailer\PHPMailer\SMTP', false ) ) { + require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php'; + } + + class_alias( PHPMailer\PHPMailer\PHPMailer::class, 'PHPMailer' ); + class_alias( PHPMailer\PHPMailer\SMTP::class, 'SMTP' ); + class_alias( PHPMailer\PHPMailer\Exception::class, 'phpmailerException' ); } + add_action('plugins_loaded', function() { global $phpmailer; @@ -120,7 +140,7 @@ class PostsmtpMailer extends PHPMailer { return $result; - } catch (phpmailerException $exc) { + } catch (Exception $exc) { $this->error = $exc; -- cgit v1.2.3