| 1 |
<?php |
| 2 |
|
| 3 |
use webaware\disable_emails\Plugin; |
| 4 |
use webaware\disable_emails\PHPMailerMock; |
| 5 |
|
| 6 |
if (!defined('ABSPATH')) { |
| 7 |
exit; |
| 8 |
} |
| 9 |
|
| 10 |
require DISABLE_EMAILS_PLUGIN_ROOT . 'includes/functions.php'; |
| 11 |
|
| 12 |
// replace standard WordPress wp_mail() if nobody else has already done it |
| 13 |
if (!function_exists('wp_mail')) { |
| 14 |
|
| 15 |
require DISABLE_EMAILS_PLUGIN_ROOT . 'includes/class.EmailAddress.php'; |
| 16 |
require DISABLE_EMAILS_PLUGIN_ROOT . 'includes/class.PHPMailerMock.php'; |
| 17 |
|
| 18 |
function wp_mail( $to, $subject, $message, $headers = '', $attachments = [] ) { |
| 19 |
global $phpmailer; |
| 20 |
|
| 21 |
// create mock PHPMailer object to handle any filter and action hook listeners |
| 22 |
$phpmailer = new PHPMailerMock(); |
| 23 |
return $phpmailer->wpmail($to, $subject, $message, $headers, $attachments); |
| 24 |
} |
| 25 |
|
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* kick start the plugin |
| 30 |
*/ |
| 31 |
require DISABLE_EMAILS_PLUGIN_ROOT . 'includes/class.Plugin.php'; |
| 32 |
Plugin::getInstance()->pluginStart(); |
| 33 |
|