Skip to content

Instantly share code, notes, and snippets.

@afragen
Last active July 1, 2020 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afragen/c710026eaa1d1634b637dbf91c726c75 to your computer and use it in GitHub Desktop.
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
<?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';
}
}
);
}
@afragen
Copy link
Author

afragen commented Jun 27, 2020

@pkarjala
Copy link

pkarjala commented Jul 1, 2020

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!

@afragen
Copy link
Author

afragen commented Jul 1, 2020

@pkarjala will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment