disable-emails.php
2.48 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
namespace uncanny_learndash_toolkit;
if ( ! defined( 'WPINC' ) ) {
die;
}
class DisableEmails extends Config implements RequiredFunctions {
/**
* Class constructor
*/
public function __construct() {
if ( ! defined( 'DISABLE_EMAILS_PLUGIN_ROOT' ) ) {
add_action( 'admin_bar_menu', array( __CLASS__, 'admin_bar_emails_disabled' ), 999 );
if ( ! defined( 'DISABLE_EMAILS_OPTIONS' ) ) {
define( 'DISABLE_EMAILS_OPTIONS', 'disable_emails' );
}
include_once UNCANNY_TOOLKIT_DIR . '/src/includes/class.DisableEmailsPlugin.php';
DisableEmailsPlugin::getInstance();
// replace standard WordPress wp_mail() if nobody else has already done it
if ( ! function_exists( 'wp_mail' ) ) {
require_once UNCANNY_TOOLKIT_DIR . '/src/includes/wp-mail-func.php';
DisableEmailsPlugin::setActive();
}
}
}
/**
* Description of class in Admin View
*
* @return array
*/
public static function get_details() {
$module_id = 'disable-emails';
$class_title = esc_html__( 'Disable Emails', 'uncanny-learndash-toolkit' );
$kb_link = 'https://www.uncannyowl.com/knowledge-base/disable-emails/';
$class_description = esc_html__( 'While this module is active, WordPress and any plugins using native WordPress email functions will be prevented from sending email.', 'uncanny-learndash-toolkit' );
$category = 'wordpress';
$type = 'free';
return array(
'id' => $module_id,
'title' => $class_title,
'type' => $type,
'category' => $category,
'kb_link' => $kb_link, // OR set as null not to display
'description' => $class_description,
'dependants_exist' => self::dependants_exist(),
'settings' => false,
);
}
/**
* Does the plugin rely on another function or plugin
*
* @return boolean || string Return either true or name of function or plugin
*
*/
public static function dependants_exist() {
return true;
}
/**
* Add toolbar node for suspending transients
*
* @access public
* @return void
* @since 1.6
*/
public static function admin_bar_emails_disabled( $wp_admin_bar ) {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$args = array(
'id' => 'emails-disable',
'title' => '<span style="font-weight: bold;font-style: italic;">' . __( 'Emails are Disabled', ' uncanny-learndash-toolkit' ) . '</span>',
'parent' => 'top-secondary',
);
$wp_admin_bar->add_node( $args );
}
}