Plugin Author
tuxlog
(@tuxlog)
Hello yezzz,
thank you for this hint. Can you please give the PHP and WordPress Version you are using? It is easier to rebuild the error then.
Thanks
Thread Starter
yezzz
(@yezzz)
Sure. PHP 7.2, WP 4.9.16.
BTW, moving the use statement inside the condition mentioned above is also not possible (giving fatal error). I just learned that the statement cannot be used inside block scope, so it should be handled differently.
Thread Starter
yezzz
(@yezzz)
Maybe you should use wp_mail() or global $phpmailer. Check out class handling in wp_mail source
Thread Starter
yezzz
(@yezzz)
If wp_mail() or global $phpmailer requires too many changes then you can use class_alias.
The following works fine for me, but you need to check for wp => 5.5
//use PHPMailer\PHPMailer\PHPMailer as PHPMailer;
if ( (float) $wp_version >= 5.5 ) {
if ( ! class_exists( 'PHPMailer\\PHPMailer\\PHPMailer' ) ) {
require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php';
require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php';
require_once ABSPATH . WPINC . '/PHPMailer/Exception.php';
}
class_alias('PHPMailer\PHPMailer\PHPMailer','PHPMailer');
} else {
Alternatively you could create another alias for both cases and extend that.
-
This reply was modified 5 years, 2 months ago by
yezzz.
Plugin Author
tuxlog
(@tuxlog)
Thanks for all your hints. I decided to separate this in two files and include accordingly. So, I can better make changes if necessary for future releases.
I will publish it in a few minutes.
Please test it and let me know if the problem is gone.
Thread Starter
yezzz
(@yezzz)
Thread Starter
yezzz
(@yezzz)
Yes, v5.9 seems to work well 🙂