Last active
July 1, 2020 20:57
-
-
Save afragen/c710026eaa1d1634b637dbf91c726c75 to your computer and use it in GitHub Desktop.
Shim to fix errors in WP 5.5-alpha+ and WP Mail SMTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WP Mail SMTP Shim for WP 5.5 plugin bootstrap. | |
* | |
* @package WP_Mail_SMTP_Shim | |
* @author Andy Fragen | |
* @license MIT | |
* | |
* @wordpress-plugin | |
* Plugin Name: WP Mail SMTP Shim for WP 5.5 | |
* Plugin URI: https://gist.github.com/afragen/c710026eaa1d1634b637dbf91c726c75 | |
* Description: Don't display the deprecated file error for WP Mail SMTP in WP 5.5-alpha+. Deprecated file warning displays as `/wp-includes/class-phpmailer.php` has moved to `/wp-includes/PHPMailer/PHPMailer.php`. Properly load the `class PHPMailer\PHPMailer\SMTP` so `MailCatcher->send()` works. | |
* Version: 0.5 | |
* Author: Andy Fragen | |
* Author URI: https://thefragens.com/ | |
* License: MIT | |
* Requires at least: 5.5-alpha | |
* Requires PHP: 5.6 | |
* Gist Plugin URI: https://gist.github.com/afragen/c710026eaa1d1634b637dbf91c726c75 | |
*/ | |
if ( ! function_exists( 'is_plugin_active' ) ) { | |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
} | |
if ( is_wp_version_compatible( '5.5-alpha' ) && is_plugin_active( 'wp-mail-smtp/wp_mail_smtp.php' ) ) { | |
add_filter( 'deprecated_file_trigger_error', '__return_false' ); | |
add_action( | |
'wp_mail_smtp_mailcatcher_smtp_send_before', | |
function() { | |
if ( ! class_exists( 'PHPMailer\PHPMailer\SMTP' ) ) { | |
require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php'; | |
} | |
} | |
); | |
} | |
Suggest adding require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
to line 21; otherwise, it tends to throw a Fatal error: Uncaught Error: Call to undefined function is_plugin_active() in /var/www/html/wp-content/plugins/wp-mail-smtp-shim.php on line 24
on activation.
Thank you for the shim for use in the meantime!
@pkarjala will do.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation instructions: https://gist.github.com/westonruter/6110fbc4bef0c4b8c021a112012f7e9c