-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwp-mail-debugger.php
67 lines (56 loc) · 1.79 KB
/
wp-mail-debugger.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
declare( strict_types=1 );
/*
* Plugin Name: WP Mail Debugger
* Plugin URI: https://wpmaildebugger.com
* Description: Capture and display all email sent through wp_mail().
* Version: 1.1
* Text Domain: wp-mail-debugger
* Author: Timothy Jacobs
* Author URI: https://timothybjacobs.com
* Requires PHP: 7.2.0
* Requires at least: 6.3.0
* Network: true
*/
namespace TimothyBJacobs\WPMailDebugger;
use Psr\Container\ContainerInterface;
use TimothyBJacobs\WPMailDebugger\App\SettingsRegistry;
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require_once __DIR__ . '/vendor/autoload.php';
}
if ( ! class_exists( Plugin::class ) ) {
add_action( 'admin_notices', static function () {
if ( current_user_can( 'manage_options' ) ) {
$msg = esc_html__( 'Composer loader not configured.', 'wp-mail-debugger' );
echo '<div class="notice notice-error"><p>' . $msg . '</p></div>';
}
} );
return;
}
/**
* Return the container for the plugin.
*
* @return ContainerInterface
*/
function container(): ContainerInterface {
static $container;
if ( ! $container ) {
$container = require __DIR__ . '/container.php';
}
return $container;
}
add_action( 'plugins_loaded', static function () {
container()->get( Plugin::class )->run();
} );
if ( get_option( SettingsRegistry::CAPTURE_MODE ) === 'override' ) {
if ( function_exists( 'wp_mail' ) ) {
add_action( 'admin_notices', static function () {
if ( current_user_can( 'manage_options' ) ) {
$msg = esc_html__( 'Another plugin is defining wp_mail() before WP Mail Debugger can be initialized. Either disable other mail plugins, or change the Capture Mode to "Filter".', 'wp-mail-debugger' );
echo '<div class="notice notice-error"><p>' . $msg . '</p></div>';
}
} );
return;
}
require_once __DIR__ . '/src/pluggable.php';
}