-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpfrom-email.php
More file actions
518 lines (474 loc) · 21.7 KB
/
wpfrom-email.php
File metadata and controls
518 lines (474 loc) · 21.7 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
<?php
/* --------------------------------------------------
Plugin Name: WPFrom Email
Plugin URI: https://endurtech.com/wpfrom-email-wordpress-plugin/
Description: Replaces default WordPress sender FROM Name and Email Address. NEW admin email options.
Author: WP Gear Pro
Author URI: https://wpgearpro.com
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Requires at least: 5.4
Tested up to: 6.10
Version: 1.9.7
Text Domain: wpfrom-emails
Domain Path: /locale
TODOS:
=====================================================
- Use one database record to obtain/set values.
- Option: Disable 'E-mail address change' user email notification.
NOTEPAD:
=====================================================
// Display admin backend warning that emails are being stopped
// Working. Replace existing wpfrom_dashboard_disabled_notice if users prefer this more apparent notice over the small dashboard_glance_items notice.
add_action( 'admin_notices', 'wpfrom_backend_warning' );
function wpfrom_backend_warning()
{
echo '<div class="error"><p><strong>Emails Disabled:</strong> The FROM email is missing within the WPFrom Email plugin settings. This disables all emails from your web site. To fix, disable the plugin or provide an email address.</p></div>';
}
-------------------------------------------------- */
if( ! defined( 'ABSPATH' ) )
{
exit(); // No direct access
}
define( 'WPF_TITLE', 'WPFrom Email' ); // Title
define( 'WPF_SETTINGS', 'WPFrom Email Settings' ); // Settings page title
/*
* Load plugin textdomain
*
* @since 1.0
add_action( 'init', 'wpfrom_mail_load_textdomain' );
function wpfrom_mail_load_textdomain()
{
load_plugin_textdomain( 'wpfrom-mail', false, basename( dirname( __FILE__ ) ) . '/locale' );
}
*/
// Add link to plugin settings from "Settings" menu
add_action( 'admin_menu', 'wpfrom_mail_sender_menu' );
function wpfrom_mail_sender_menu()
{
add_options_page( __(WPF_SETTINGS), __(WPF_TITLE), 'manage_options', 'wpfrom-email', 'wpfrom_mail_sender_output' );
}
// Add link to plugin settings from "Plugins" page
add_filter( 'plugin_action_links_'.plugin_basename(__FILE__), 'wpfrom_email_settings_link' );
function wpfrom_email_settings_link( $links )
{
$links[] = '<a href="' . admin_url( 'options-general.php?page=wpfrom-email' ) . '">' . __('Settings') . '</a>';
return $links;
}
// Add notice to admin dashboard of disabled emails
add_filter( 'dashboard_glance_items', 'wpfrom_dashboard_disabled_notice' );
function wpfrom_dashboard_disabled_notice( $glances )
{
$email_killed_init = esc_html( get_option( 'wpfrom_mail_sender_email_id' ) );
$custom_email = get_option( 'wpfrom_custom_sender_id' );
if( $email_killed_init == '' && $custom_email == '1' )
{
$glances[] = '<li style="float:none;"><i class="dashicons dashicons-email" aria-hidden="true" style="color:#e14d43;"></i> WordPress Emails <strong>Disabled</strong></li>';
}
return $glances;
}
// WPFrom Plugin Deactivation Database Cleanup, you're welcome!
register_deactivation_hook( __FILE__, 'wpfrom_deactivation_cleaner' );
function wpfrom_deactivation_cleaner()
{
delete_option( 'wpfrom_custom_sender_id' );
delete_option( 'wpfrom_mail_sender_email_id' );
delete_option( 'wpfrom_mail_sender_name_id' );
delete_option( 'wpfrom_admin_verify_email_id' );
delete_option( 'wpfrom_pwd_admin_email_id' );
delete_option( 'wpfrom_pwd_user_email_id' );
delete_option( 'wpfrom_new_user_admin_email_id' );
delete_option( 'wpfrom_autoupdate_core_email_id' );
delete_option( 'wpfrom_autoupdate_plugin_email_id' );
delete_option( 'wpfrom_autoupdate_theme_email_id' );
delete_option( 'wpfrom_mail_sender_id' ); // since 1.0, now junk
delete_option( 'wpfrom_kill_email_id' ); // since 1.4.2, now junk
}
// WordPress plugin registration
add_action( 'admin_init', 'wpfrom_mail_sender_register' );
function wpfrom_mail_sender_register()
{
// Settings Section
//add_settings_section( 'wpfrom_mail_sender_section', WPF_SETTINGS, 'wpfrom_mail_intro_text', 'wpfrom_mail_sender' );
add_settings_section( 'wpfrom_mail_sender_section', '', 'wpfrom_mail_intro_text', 'wpfrom_mail_sender' );
// Enable WordPress Custom Emails
add_settings_field( 'wpfrom_custom_sender_id', __('WPFrom Custom Sender', 'wpfrom-mail'), 'wpfrom_custom_sender', 'wpfrom_mail_sender', 'wpfrom_mail_sender_section' );
register_setting( 'wpfrom_mail_sender_section', 'wpfrom_custom_sender_id' );
// Custom WordPress Sender Email
add_settings_field( 'wpfrom_mail_sender_email_id', __('Custom Senders Email', 'wpfrom-mail'), 'wpfrom_mail_sender_email', 'wpfrom_mail_sender', 'wpfrom_mail_sender_section' );
register_setting( 'wpfrom_mail_sender_section', 'wpfrom_mail_sender_email_id' );
// Custom WordPress Sender Name
add_settings_field( 'wpfrom_mail_sender_name_id', __('Custom Senders Name', 'wpfrom-mail'), 'wpfrom_mail_sender_name', 'wpfrom_mail_sender', 'wpfrom_mail_sender_section' );
register_setting( 'wpfrom_mail_sender_section', 'wpfrom_mail_sender_name_id' );
// Disable WordPress AutoUpdate Admin Email Notifications - Core
add_settings_field( 'wpfrom_autoupdate_core_email_id', __('AutoUpdate Core Email', 'wpfrom-mail'), 'wpfrom_autoupdate_core_email', 'wpfrom_mail_sender', 'wpfrom_mail_sender_section' );
register_setting( 'wpfrom_mail_sender_section', 'wpfrom_autoupdate_core_email_id' );
// Disable WordPress AutoUpdate Admin Email Notifications - Plugin
add_settings_field( 'wpfrom_autoupdate_plugin_email_id', __('AutoUpdate Plugin Email', 'wpfrom-mail'), 'wpfrom_autoupdate_plugin_email', 'wpfrom_mail_sender', 'wpfrom_mail_sender_section' );
register_setting( 'wpfrom_mail_sender_section', 'wpfrom_autoupdate_plugin_email_id' );
// Disable WordPress AutoUpdate Admin Email Notifications - Theme
add_settings_field( 'wpfrom_autoupdate_theme_email_id', __('AutoUpdate Theme Email', 'wpfrom-mail'), 'wpfrom_autoupdate_theme_email', 'wpfrom_mail_sender', 'wpfrom_mail_sender_section' );
register_setting( 'wpfrom_mail_sender_section', 'wpfrom_autoupdate_theme_email_id' );
// Disable WordPress "Admin Email Verification" prompt
add_settings_field( 'wpfrom_admin_verify_email_id', __('Admin Email Verification', 'wpfrom-mail'), 'wpfrom_admin_verify_email', 'wpfrom_mail_sender', 'wpfrom_mail_sender_section' );
register_setting( 'wpfrom_mail_sender_section', 'wpfrom_admin_verify_email_id' );
// Disable WordPress "Password Rest" admin email
add_settings_field( 'wpfrom_pwd_admin_email_id', __('User Password Reset', 'wpfrom-mail'), 'wpfrom_pwd_admin_email', 'wpfrom_mail_sender', 'wpfrom_mail_sender_section' );
register_setting( 'wpfrom_mail_sender_section', 'wpfrom_pwd_admin_email_id' );
// Disable WordPress "Password Changed" user email
add_settings_field( 'wpfrom_pwd_user_email_id', __('User Password Changed', 'wpfrom-mail'), 'wpfrom_pwd_user_email', 'wpfrom_mail_sender', 'wpfrom_mail_sender_section' );
register_setting( 'wpfrom_mail_sender_section', 'wpfrom_pwd_user_email_id' );
// Disable WordPress "New User Registration" admin email
add_settings_field( 'wpfrom_new_user_admin_email_id', __('New User Registration', 'wpfrom-mail'), 'wpfrom_new_user_admin_email', 'wpfrom_mail_sender', 'wpfrom_mail_sender_section' );
register_setting( 'wpfrom_mail_sender_section', 'wpfrom_new_user_admin_email_id' );
}
// Enable WPFrom Custom Sender checkbox
function wpfrom_custom_sender()
{
$custom_email = get_option( 'wpfrom_custom_sender_id' );
if( ! isset ( $custom_email ) || $custom_email == '' )
{
delete_option( 'wpfrom_custom_sender_id' );
}
else
{
$custom_email = 'checked="checked" ';
}
echo '<input name="wpfrom_custom_sender_id" id="wpfrom_custom_sender_id" type="checkbox" value="1" ' . $custom_email . '/> <label for="wpfrom_custom_sender_id">Enable custom WordPress emails?</label><br /><span style="font-size:12px; padding-left:10px;">If enabled, set Custom Senders Email/Name below.</span>';
}
// FROM Email field
function wpfrom_mail_sender_email()
{
$sender_email = esc_html( get_option( 'wpfrom_mail_sender_email_id' ) );
if( $sender_email == '' )
{
delete_option( 'wpfrom_mail_sender_email_id' );
}
echo '<input name="wpfrom_mail_sender_email_id" id="wpfrom_mail_sender_email_id" type="email" placeholder="wordpress@yourdomain.com" class="regular-text" value="' . $sender_email . '" /><br /><span style="font-size:12px; padding-left:10px;">Want to Disable ALL WordPress emails? Leave this blank!</span>';
}
// FROM Name field
function wpfrom_mail_sender_name()
{
$sender_name = esc_html( get_option( 'wpfrom_mail_sender_name_id' ) );
if( $sender_name == '' )
{
delete_option( 'wpfrom_mail_sender_name_id' );
}
echo '<input name="wpfrom_mail_sender_name_id" id="wpfrom_mail_sender_name_id" type="text" placeholder="WordPress" class="regular-text" value="' . $sender_name . '" /><br /><span style="font-size:12px; padding-left:10px;">Do not use commas and/or other special characters.</span>
<p> </p>';
}
// Disable WordPress AutoUpdate Admin Email Notifications - Core
function wpfrom_autoupdate_core_email()
{
//init vars
$wpfrom_autoupdate_core_email_prompt = get_option( 'wpfrom_autoupdate_core_email_id' );
$wpc = '';
$wpc1 = '';
$wpc2 = '';
if( ! isset ( $wpfrom_autoupdate_core_email_prompt ) || $wpfrom_autoupdate_core_email_prompt == '' )
{
delete_option( 'wpfrom_autoupdate_core_email_id' );
$wpc = ' selected="selected"';
}
elseif( $wpfrom_autoupdate_core_email_prompt == '1' )
{
$wpc1 = ' selected="selected"';
}
elseif( $wpfrom_autoupdate_core_email_prompt == '2' )
{
$wpc2 = ' selected="selected"';
}
echo '<select name="wpfrom_autoupdate_core_email_id" id="wpfrom_autoupdate_core_email_id">
<option value=""'. $wpc .'>Default, Send Core AutoUpdate Notices</option>
<option value="1"'. $wpc1 .'>Send Core AutoUpdate Failure Notices</option>
<option value="2"'. $wpc2 .'>Disable ALL Core AutoUpdate Notices</option>
</select> <br /><span style="font-size:12px; padding-left:10px;">Controls the <strong>WordPress Core</strong> AutoUpdate Admin Email Notification.</span>';
}
// Disable WordPress AutoUpdate Admin Email Notifications - Plugin
function wpfrom_autoupdate_plugin_email()
{
//init vars
$wpfrom_autoupdate_plugin_email_prompt = get_option( 'wpfrom_autoupdate_plugin_email_id' );
$wpp = '';
$wpp1 = '';
$wpp2 = '';
if( ! isset( $wpfrom_autoupdate_plugin_email_prompt ) || $wpfrom_autoupdate_plugin_email_prompt == '' )
{
delete_option( 'wpfrom_autoupdate_plugin_email_id' );
$wpp = ' selected="selected"';
}
elseif( $wpfrom_autoupdate_plugin_email_prompt == '1' )
{
$wpp1 = ' selected="selected"';
}
elseif( $wpfrom_autoupdate_plugin_email_prompt == '2' )
{
$wpp2 = ' selected="selected"';
}
echo '<select name="wpfrom_autoupdate_plugin_email_id" id="wpfrom_autoupdate_plugin_email_id">
<option value=""'. $wpp .'>Default, Send Plugin AutoUpdate Notices</option>
<option value="1"'. $wpp1 .'>Send Plugin AutoUpdate Failure Notices</option>
<option value="2"'. $wpp2 .'>Disable ALL Plugin AutoUpdate Notices</option>
</select> <br /><span style="font-size:12px; padding-left:10px;">Controls the <strong>WordPress Plugin</strong> AutoUpdate Admin Emails.</span>';
}
// Disable WordPress AutoUpdate Admin Email Notifications - Theme
function wpfrom_autoupdate_theme_email()
{
//init vars
$wpfrom_autoupdate_theme_email_prompt = get_option( 'wpfrom_autoupdate_theme_email_id' );
$wpt = '';
$wpt1 = '';
$wpt2 = '';
if( ! isset( $wpfrom_autoupdate_theme_email_prompt ) || $wpfrom_autoupdate_theme_email_prompt == '' )
{
delete_option( 'wpfrom_autoupdate_theme_email_id' );
$wpt = ' selected="selected"';
}
elseif( $wpfrom_autoupdate_theme_email_prompt == '1' )
{
$wpt1 = ' selected="selected"';
}
elseif( $wpfrom_autoupdate_theme_email_prompt == '2' )
{
$wpt2 = ' selected="selected"';
}
echo '<select name="wpfrom_autoupdate_theme_email_id" id="wpfrom_autoupdate_theme_email_id">
<option value=""'. $wpt .'>Default, Send Theme AutoUpdate Notices</option>
<option value="1"'. $wpt1 .'>Send Theme AutoUpdate Failure Notices</option>
<option value="2"'. $wpt2 .'>Disable ALL Theme AutoUpdate Notices</option>
</select> <br /><span style="font-size:12px; padding-left:10px;">Controls the <strong>WordPress Theme</strong> AutoUpdate Admin Emails.</span>
<p> </p>';
}
// Disable WordPress "Admin Email Verification" prompt checkbox
function wpfrom_admin_verify_email()
{
$admin_verify_email_prompt = get_option( 'wpfrom_admin_verify_email_id' );
if( ! isset ( $admin_verify_email_prompt ) || $admin_verify_email_prompt == '' )
{
delete_option( 'wpfrom_admin_verify_email_id' );
}
else
{
$admin_verify_email_prompt = 'checked="checked" ';
}
echo '<input name="wpfrom_admin_verify_email_id" id="wpfrom_admin_verify_email_id" type="checkbox" value="1" '.$admin_verify_email_prompt.'/> <label for="wpfrom_admin_verify_email_id">Disable WordPress <strong>Admin Email Verification</strong> prompt?</label><br /><span style="font-size:12px; padding-left:10px;">Stop WordPress from periodically requesting admin email verification.</span>';
}
// Disable WordPress "Password Rest" admin email checkbox
function wpfrom_pwd_admin_email()
{
$pwd_admin_email = get_option( 'wpfrom_pwd_admin_email_id' );
if( ! isset ( $pwd_admin_email ) || $pwd_admin_email == '' )
{
delete_option( 'wpfrom_pwd_admin_email_id' );
}
else
{
$pwd_admin_email = 'checked="checked" ';
}
echo '<input name="wpfrom_pwd_admin_email_id" id="wpfrom_pwd_admin_email_id" type="checkbox" value="1" '.$pwd_admin_email.'/> <label for="wpfrom_pwd_admin_email_id">Disable <strong>Admin email notice</strong> upon user password reset?</label><br /><span style="font-size:12px; padding-left:10px;">Stop notifications when a user resets their password.</span>';
}
// Disable WordPress "Password Changed" user email checkbox
function wpfrom_pwd_user_email()
{
$pwd_user_email = get_option( 'wpfrom_pwd_user_email_id' );
if( ! isset ( $pwd_user_email ) || $pwd_user_email == '' )
{
delete_option( 'wpfrom_pwd_user_email_id' );
}
else
{
$pwd_user_email = 'checked="checked" ';
}
echo '<input name="wpfrom_pwd_user_email_id" id="wpfrom_pwd_user_email_id" type="checkbox" value="1" '.$pwd_user_email.'/> <label for="wpfrom_pwd_user_email_id">Disable <strong>User email notice</strong> upon user password change?</label><br /><span style="font-size:12px; padding-left:10px;">Stop notifications to users when their password is changed.</span>';
}
// Disable WordPress "New User Registration" admin email checkbox
function wpfrom_new_user_admin_email()
{
$new_user_admin_email = get_option( 'wpfrom_new_user_admin_email_id' );
if( ! isset ( $new_user_admin_email ) || $new_user_admin_email == '' )
{
delete_option( 'wpfrom_new_user_admin_email_id' );
}
else
{
$new_user_admin_email = 'checked="checked" ';
}
echo '<input name="wpfrom_new_user_admin_email_id" id="wpfrom_new_user_admin_email_id" type="checkbox" value="1" '.$new_user_admin_email.'/> <label for="wpfrom_new_user_admin_email_id">Disable <strong>Admin email notice</strong> upon "New User Registration"?</label><br /><span style="font-size:12px; padding-left:10px;">Only for use with Gravity Forms User Registration Add-On. <a href="https://endurtech.com/wpfrom-email-wordpress-plugin/#using-wpfrom-email-wordpress-plugin" target="_blank" title="Opens in New Window">Read more</a></span>';
}
// Page description
function wpfrom_mail_intro_text()
{
/*echo '<p>Replaces the default WordPress FROM <strong>Email</strong> and <strong>Name</strong>. Enable and set Senders Email (<strong><em>otherwise all mail is disabled</em></strong>).</p>
<p>Did <a href="https://wordpress.org/plugins/wpfrom-email/" target="_blank" title="Opens New Window">this plugin</a> save you time and add value? <a href="https://endurtech.com/give-thanks/" target="_blank" title="Opens New Window"><strong>Share your appreciation</strong></a> and support future improvements.</p>';*/
}
// Page exit statement
function wpfrom_mail_exit_text()
{
echo '<p>Did <a href="https://wordpress.org/plugins/wpfrom-email/" target="_blank" title="Opens New Window">this plugin</a> save you time? <a href="https://endurtech.com/give-thanks/" target="_blank" title="Opens New Window"><strong>Share your appreciation</strong></a> and support future improvements.</p>';
}
// Settings form
function wpfrom_mail_sender_output()
{
echo '<div style="padding:20px 0px 20px 20px;">
<img src="' . plugins_url( 'wpfrom-logo.png', __FILE__ ) . '" style="max-width:80px; width:100%; height:auto; float:left;" />
<h1 style="float:left; padding:20px 0px 0px 20px;">' . WPF_TITLE . '</h1>
<div style="clear:both;"></div>
</div>
<div class="wrap" style="padding:20px; border-top:1px solid #cccccc; border-right:1px solid #cccccc; border-bottom:2px solid #cccccc; border-left:2px solid #cccccc; border-radius:10px; background:#ffffff;">
<form method="post" action="options.php" accept-charset="utf-8">';
settings_fields( 'wpfrom_mail_sender_section' );
do_settings_sections( 'wpfrom_mail_sender' );
echo wpfrom_mail_exit_text();
submit_button();
echo '</form>
</div>';
}
// Replace default WordPress emails with Custom Sender
add_filter( 'wp_mail', 'wpfrom_custom_sender_init' );
function wpfrom_custom_sender_init()
{
$custom_sender_init = get_option( 'wpfrom_custom_sender_id' );
if( $custom_sender_init == '1' )
{
// Replace the default FROM Email: wordpress@yourdomain.com
add_filter( 'wp_mail_from', 'wpfrom_new_mail_from' );
if( ! function_exists( 'wpfrom_new_mail_from' ) )
{
function wpfrom_new_mail_from()
{
return esc_html( get_option( 'wpfrom_mail_sender_email_id' ) );
}
}
// Replace the default FROM Name: WordPress
add_filter( 'wp_mail_from_name', 'wpfrom_new_mail_from_name' );
if( ! function_exists( 'wpfrom_new_mail_from_name' ) )
{
function wpfrom_new_mail_from_name()
{
return esc_html( get_option( 'wpfrom_mail_sender_name_id' ) );
}
}
}
}
// Disable WordPress AutoUpdate Admin Email Notifications - Core
$wpfrom_autoupdate_core_email_prompt = get_option( 'wpfrom_autoupdate_core_email_id' );
if( $wpfrom_autoupdate_core_email_prompt == '2' )
{
// Disable ALL Core Email
add_filter( 'auto_core_update_send_email', '__return_false' );
}
elseif( $wpfrom_autoupdate_core_email_prompt == '1' )
{
// Only Send Core Email Errors
add_filter( 'auto_core_update_send_email', 'wpfrom_autoupdate_core_email_onerror', 10, 4 );
function wpfrom_autoupdate_core_email_onerror($send,$type,$core_update,$result)
{
if( ! empty( $type ) && $type == 'success' )
{
return false;
}
else
{
return true;
}
}
}
// Disable WordPress AutoUpdate Admin Email Notifications - Plugin
$wpfrom_autoupdate_plugin_email_prompt = get_option( 'wpfrom_autoupdate_plugin_email_id' );
if( $wpfrom_autoupdate_plugin_email_prompt == '2' )
{
add_filter( 'auto_plugin_update_send_email', 'wpfrom_disable_autoupdate_plugin_email', 10, 2 );
function wpfrom_disable_autoupdate_plugin_email()
{
return false;
}
}
elseif( $wpfrom_autoupdate_plugin_email_prompt == '1' )
{
add_filter( 'auto_plugin_update_send_email', 'wpfrom_disable_autoupdate_failed_plugin_email', 10, 1 );
function wpfrom_disable_autoupdate_failed_plugin_email( $true, $update_results = null )
{
if( is_array( $update_results ) )
{
foreach( $update_results as $update_result )
{
if( true !== $update_result->result )
{
return $true;
}
}
}
return false;
}
}
// Disable WordPress AutoUpdate Admin Email Notifications - Theme
$wpfrom_autoupdate_theme_email_prompt = get_option( 'wpfrom_autoupdate_theme_email_id' );
if( $wpfrom_autoupdate_theme_email_prompt == '2' )
{
add_filter( 'auto_theme_update_send_email', 'wpfrom_disable_autoupdate_theme_email', 10, 2 );
function wpfrom_disable_autoupdate_theme_email()
{
return false;
}
}
elseif( $wpfrom_autoupdate_theme_email_prompt == '1' )
{
add_filter( 'auto_theme_update_send_email', 'wpfrom_disable_autoupdate_failed_theme_email', 10, 1 );
function wpfrom_disable_autoupdate_failed_theme_email( $true, $update_results = null )
{
if( is_array( $update_results ) )
{
foreach( $update_results as $update_result )
{
if( true !== $update_result->result )
{
return $true;
}
}
}
return false;
}
}
// Disable WordPress "Administration Email Verification" prompt
$admin_email_verify_prompt_init = get_option( 'wpfrom_admin_verify_email_id' );
if( $admin_email_verify_prompt_init == '1' )
{
add_filter( 'admin_email_check_interval', '__return_false' );
}
// Disable WordPress "Password Rest" admin email
$pwd_admin_email_init = get_option( 'wpfrom_pwd_admin_email_id' );
if( $pwd_admin_email_init == '1' )
{
if( ! function_exists( 'wp_password_change_notification' ) )
{
function wp_password_change_notification( $user )
{
return;
}
}
}
// Disable WordPress "Password Changed" user email
$pwd_user_email_init = get_option( 'wpfrom_pwd_user_email_id' );
if( $pwd_user_email_init == '1' )
{
add_filter( 'send_password_change_email', '__return_false' );
}
// Disable WordPress "New User Registration" admin email
$new_user_admin_email_init = get_option( 'wpfrom_new_user_admin_email_id' );
if( $new_user_admin_email_init == '1' )
{
add_filter( 'wp_new_user_notification_email_admin', 'disable_admin_email', 10, 3 );
function disable_admin_email( $wp_new_user_notification_email_admin, $user, $blogname )
{
// Return an array with junk values to prevent the wp_mail() function from being called
return array(
'to' => '',
'subject' => '',
'message' => '',
'headers' => '',
);
// return;
}
}
// Thank you for checking out my code. Let me know how I can improve upon it!
?>