disable-emails icon indicating copy to clipboard operation
disable-emails copied to clipboard

Automatically disable any plugin declaring wp_mail first

Open BrianHenryIE opened this issue 5 years ago • 0 comments

I see there is a notice on the plugins page, but I imagine most people just want to install and go.

In your conditional if (!function_exists('wp_mail')) { I've added else which uses reflection to find the file wp_mail has been declared in, then find what plugin that is in, then disable the plugin.

To test, you can add this as a plugin:

<?php
/**
 * Plugin Name:       A WP_Mail Dummy
 * Description:       A plugin whose name starts with "A" which sets a custom wp_mail function.
 * Text Domain:       a-wpmail-dummy
 */
if (!function_exists('wp_mail')) {
	function wp_mail( $to, $subject, $message, $headers = '', $attachments = [] ) {
		return true;
	}
}

BrianHenryIE avatar May 02 '20 02:05 BrianHenryIE