Manage Notification E-mails - Version 1.6.0

Version Description

ADDED: Automatic Wordpress plugin, and theme update e-mail options.

Download this release

Release Info

Developer Virgial
Plugin Icon 128x128 Manage Notification E-mails
Version 1.6.0
Comparing to
See all releases

Code changes from version 1.5.1 to 1.6.0

includes/class.FAMNE.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manage notification emails settings page class
4
+ *
5
+ * initializes the plugin.
6
+ *
7
+ * This file is part of the Manage Notification Emails plugin
8
+ * You can find out more about this plugin at http://www.freeamigos.mx
9
+ * Copyright (c) 2006-2015 Virgial Berveling
10
+ *
11
+ * @package WordPress
12
+ * @author Virgial Berveling
13
+ * @copyright 2006-2015
14
+ *
15
+ * since: 1.6.0
16
+ */
17
+
18
+ if (!class_exists('FAMNE')):
19
+ class FAMNE{
20
+
21
+ static public function get_option($name)
22
+ {
23
+ if ($name == 'fa_mne_version') return get_site_option($name);
24
+
25
+ return get_option($name);
26
+ }
27
+
28
+ static public function update_option($name,$options)
29
+ {
30
+ if ($name == 'fa_mne_version') return update_site_option($name,$options);
31
+
32
+ return update_option($name,$options);
33
+
34
+ }
35
+ static public function update_check()
36
+ {
37
+ if (self::get_option( 'fa_mne_version' ) != FA_MNE_VERSION) {
38
+ $options = self::get_option( 'famne_options' );
39
+ $current_version = self::get_option( 'fa_mne_version' );
40
+
41
+ /* Is this the first install, then set all defaults to active */
42
+ if ($options === false)
43
+ {
44
+ $options = array(
45
+ 'wp_new_user_notification_to_user' => '1',
46
+ 'wp_new_user_notification_to_admin' => '1',
47
+ 'wp_notify_postauthor' => '1',
48
+ 'wp_notify_moderator' => '1',
49
+ 'wp_password_change_notification' => '1',
50
+ 'send_password_change_email' => '1',
51
+ 'send_email_change_email' => '1',
52
+ 'send_password_forgotten_email' => '1',
53
+ 'send_password_admin_forgotten_email' => '1',
54
+ 'auto_core_update_send_email' => '1',
55
+ 'auto_plugin_update_send_email' => '1',
56
+ 'auto_theme_update_send_email' => '1'
57
+ );
58
+
59
+ self::update_option('famne_options',$options);
60
+
61
+ /* UPDATE DONE! */
62
+ self::update_option('fa_mne_version',FA_MNE_VERSION);
63
+ return;
64
+ }
65
+
66
+ if ( version_compare($current_version, '1.5.1') <=0)
67
+ {
68
+ /** update to 1.6.0
69
+ * setting the newly added options to checked as default
70
+ */
71
+ $options['auto_plugin_update_send_email'] = '1';
72
+ $options['auto_theme_update_send_email'] = '1';
73
+ self::update_option('famne_options',$options);
74
+ }
75
+
76
+ if ($current_version == '1.1.0')
77
+ {
78
+ /** update 1.1.0 to 1.2.0
79
+ * setting the newly added options to checked as default
80
+ */
81
+
82
+ $options['send_password_forgotten_email'] = '1';
83
+ $options['send_password_admin_forgotten_email'] ='1';
84
+
85
+ self::update_option('famne_options',$options);
86
+ }
87
+
88
+
89
+ /** update to 1.4.1
90
+ * setting the newly added options to checked as default
91
+ */
92
+
93
+ if ( version_compare($current_version, '1.4.0') <=0)
94
+ {
95
+ $options['auto_core_update_send_email'] ='1';
96
+ self::update_option('famne_options',$options);
97
+ }
98
+
99
+
100
+
101
+ /** update 1.0 to 1.1 fix:
102
+ * update general wp_new_user_notification option into splitted options
103
+ */
104
+ if ( version_compare($current_version, '1.0.0') <=0)
105
+ {
106
+ unset($options['wp_new_user_notification']);
107
+ $options['wp_new_user_notification_to_user'] ='1';
108
+ $options['wp_new_user_notification_to_admin'] ='1';
109
+ self::update_option('famne_options',$options);
110
+ }
111
+
112
+ /* UPDATE DONE! */
113
+ self::update_option('fa_mne_version',FA_MNE_VERSION);
114
+ }
115
+ }
116
+ }
117
+ endif;
includes/class.FAMNESettingsPage.php CHANGED
@@ -15,6 +15,7 @@
15
  * version: 1.3.0
16
  */
17
 
 
18
 
19
  class FAMNESettingsPage
20
  {
@@ -28,7 +29,6 @@ class FAMNESettingsPage
28
  */
29
  public function __construct()
30
  {
31
- add_action( 'plugins_loaded', array($this, 'update_check') );
32
  add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
33
  add_action( 'admin_init', array( $this, 'page_init' ) );
34
  add_filter( 'plugin_action_links_' . FA_MNE_PLUGIN_BASENAME, array($this,'add_action_links') );
@@ -56,11 +56,11 @@ class FAMNESettingsPage
56
  public function create_admin_page()
57
  {
58
  // Set class property
59
- $this->options = get_option( 'famne_options' );
60
 
61
  ?>
62
  <div class="wrap">
63
- <h2><?php _e('Manage the notification e-mails','manage-notification-emails')?></h2>
64
  <form method="post" action="options.php">
65
  <?php
66
  // This prints out all hidden setting fields
@@ -166,21 +166,39 @@ class FAMNESettingsPage
166
  'setting_section_id'
167
  );
168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  add_settings_field(
170
  'send_password_admin_forgotten_email',
171
  __('Password forgotten e-mail to administrator','manage-notification-emails'),
172
  array( $this, 'field9_callback' ),
173
  'famne-admin',
174
  'setting_section_id'
175
- );
176
 
177
- add_settings_field(
178
- 'auto_core_update_send_email',
179
- __('automatic Wordpress core update e-mail','manage-notification-emails'),
180
- array( $this, 'field10_callback' ),
181
- 'famne-admin',
182
- 'setting_section_id'
183
- );
184
 
185
 
186
  }
@@ -271,79 +289,19 @@ class FAMNESettingsPage
271
  public function field10_callback()
272
  {
273
  $this->print_checkbox('field10','auto_core_update_send_email',__('Sends an e-mail after a successful automatic Wordpress core update to administrators. E-mails about failed updates will always be sent to the administrators and cannot be disabled.','manage-notification-emails'));
274
- }
 
 
 
 
 
275
 
276
- public function update_check()
277
  {
278
- if (get_site_option( 'fa_mne_version' ) != FA_MNE_VERSION) {
279
-
280
-
281
- $this->options = get_option( 'famne_options' );
282
-
283
-
284
- /* Is this the first install, then set all defaults to active */
285
- if ($this->options === false)
286
- {
287
- $options = array(
288
- 'wp_new_user_notification_to_user' => '1',
289
- 'wp_new_user_notification_to_admin' => '1',
290
- 'wp_notify_postauthor' => '1',
291
- 'wp_notify_moderator' => '1',
292
- 'wp_password_change_notification' => '1',
293
- 'send_password_change_email' => '1',
294
- 'send_email_change_email' => '1',
295
- 'send_password_forgotten_email' => '1',
296
- 'send_password_admin_forgotten_email' => '1',
297
- 'auto_core_update_send_email' => '1'
298
- );
299
-
300
- update_option('famne_options',$options);
301
- $this->options = $options;
302
-
303
- }
304
-
305
- if (get_site_option( 'fa_mne_version' ) == '1.1.0')
306
- {
307
-
308
- /** update 1.1.0 to 1.2.0
309
- * setting the newly added options to checked as default
310
- */
311
-
312
- $this->options['send_password_forgotten_email'] = '1';
313
- $this->options['send_password_admin_forgotten_email'] ='1';
314
-
315
- update_option('famne_options',$this->options);
316
- }
317
-
318
-
319
- /** update to 1.4.1
320
- * setting the newly added options to checked as default
321
- */
322
-
323
- if (!isset($this->options['auto_core_update_send_email']))
324
- {
325
- $this->options['auto_core_update_send_email'] ='1';
326
- update_option('famne_options',$this->options);
327
- }
328
-
329
-
330
-
331
- /** update 1.0 to 1.1 fix:
332
- * update general wp_new_user_notification option into splitted options
333
- */
334
- if (!empty($this->options['wp_new_user_notification']))
335
- {
336
- unset($this->options['wp_new_user_notification']);
337
- $this->options['wp_new_user_notification_to_user'] ='1';
338
- $this->options['wp_new_user_notification_to_admin'] ='1';
339
- update_option('famne_options',$this->options);
340
- }
341
-
342
- /* UPDATE DONE! */
343
- update_site_option('fa_mne_version',FA_MNE_VERSION);
344
- }
345
  }
346
 
 
347
  function add_action_links ( $links ) {
348
  $mylinks = array(
349
  '<a href="' . admin_url( 'options-general.php?page=famne-admin' ) . '">'.__('Settings').'</a>',
@@ -359,6 +317,6 @@ class FAMNESettingsPage
359
  function famne_load_textdomain() {
360
  load_plugin_textdomain( 'manage-notification-emails', false, basename(FA_MNE_PLUGIN_DIR) . '/languages' );
361
  }
 
362
 
363
-
364
- }
15
  * version: 1.3.0
16
  */
17
 
18
+ if (!class_exists('FAMNESettingsPage')):
19
 
20
  class FAMNESettingsPage
21
  {
29
  */
30
  public function __construct()
31
  {
 
32
  add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
33
  add_action( 'admin_init', array( $this, 'page_init' ) );
34
  add_filter( 'plugin_action_links_' . FA_MNE_PLUGIN_BASENAME, array($this,'add_action_links') );
56
  public function create_admin_page()
57
  {
58
  // Set class property
59
+ $this->options = FAMNE::get_option( 'famne_options' );
60
 
61
  ?>
62
  <div class="wrap">
63
+ <h2><?php _e('Manage the notification e-mails','manage-notification-emails')?></h2>
64
  <form method="post" action="options.php">
65
  <?php
66
  // This prints out all hidden setting fields
166
  'setting_section_id'
167
  );
168
 
169
+ add_settings_field(
170
+ 'auto_core_update_send_email',
171
+ __('automatic Wordpress core update e-mail','manage-notification-emails'),
172
+ array( $this, 'field10_callback' ),
173
+ 'famne-admin',
174
+ 'setting_section_id'
175
+ );
176
+
177
+ add_settings_field(
178
+ 'auto_plugin_update_send_email',
179
+ __('Automatic Wordpress plugin update e-mail','manage-notification-emails'),
180
+ array( $this, 'field11_callback' ),
181
+ 'famne-admin',
182
+ 'setting_section_id'
183
+ );
184
+
185
+ add_settings_field(
186
+ 'auto_theme_update_send_email',
187
+ __('Automatic Wordpress theme update e-mail','manage-notification-emails'),
188
+ array( $this, 'field12_callback' ),
189
+ 'famne-admin',
190
+ 'setting_section_id'
191
+ );
192
+
193
  add_settings_field(
194
  'send_password_admin_forgotten_email',
195
  __('Password forgotten e-mail to administrator','manage-notification-emails'),
196
  array( $this, 'field9_callback' ),
197
  'famne-admin',
198
  'setting_section_id'
199
+ );
200
 
201
+
 
 
 
 
 
 
202
 
203
 
204
  }
289
  public function field10_callback()
290
  {
291
  $this->print_checkbox('field10','auto_core_update_send_email',__('Sends an e-mail after a successful automatic Wordpress core update to administrators. E-mails about failed updates will always be sent to the administrators and cannot be disabled.','manage-notification-emails'));
292
+ }
293
+
294
+ public function field11_callback()
295
+ {
296
+ $this->print_checkbox('field11','auto_plugin_update_send_email',__('Sends an e-mail after a successful automatic plugin update to administrators. E-mails about failed plugin updates will always be sent to the administrators','manage-notification-emails'));
297
+ }
298
 
299
+ public function field12_callback()
300
  {
301
+ $this->print_checkbox('field12','auto_theme_update_send_email',__('Sends an e-mail after a successful automatic theme update to administrators. E-mails about failed theme updates will always be sent to the administrators','manage-notification-emails'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
  }
303
 
304
+
305
  function add_action_links ( $links ) {
306
  $mylinks = array(
307
  '<a href="' . admin_url( 'options-general.php?page=famne-admin' ) . '">'.__('Settings').'</a>',
317
  function famne_load_textdomain() {
318
  load_plugin_textdomain( 'manage-notification-emails', false, basename(FA_MNE_PLUGIN_DIR) . '/languages' );
319
  }
320
+ }
321
 
322
+ endif;
 
includes/pluggable-functions-1.5.php ADDED
@@ -0,0 +1,374 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+
4
+ STOP SENDING NOTIFICATION MAILS TO THE USERS
5
+ version 1.5.2
6
+ added: Email automatic plugin update notification to admin option
7
+ added: Email automatic theme update notification to admin option
8
+ since 1.5.1
9
+ updated: the core pluggable function wp_new_user_notification
10
+ added: passing through the $deprecated and $notify
11
+ fixed notice of $deprecated
12
+ */
13
+
14
+ if (!defined('ABSPATH')) die();
15
+
16
+ $famne_options = FAMNE::get_option( 'famne_options' );
17
+
18
+ if (!function_exists('dont_send_password_change_email') ) :
19
+ /**
20
+ * Email password change notification to registered user.
21
+ *
22
+ */
23
+ //echo "dont_send_password_change_email";
24
+ function dont_send_password_change_email( $send=false, $user='', $userdata='')
25
+ {
26
+
27
+ global $famne_options;
28
+
29
+ if (is_array($user)) $user = (object) $user;
30
+
31
+ if (!empty($famne_options['wp_password_change_notification']) ) :
32
+
33
+ // send a copy of password change notification to the admin
34
+ // but check to see if it's the admin whose password we're changing, and skip this
35
+ if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) ) {
36
+ $message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n";
37
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
38
+ // we want to reverse this for the plain text arena of emails.
39
+ $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
40
+ wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), $blogname), $message);
41
+ }
42
+
43
+ endif;
44
+
45
+ if (empty($famne_options['send_password_change_email']) ) :
46
+ return false;
47
+ else :
48
+ return true;
49
+ endif;
50
+ }
51
+ add_filter('send_password_change_email', 'dont_send_password_change_email',1,3);
52
+ endif;
53
+
54
+
55
+ if (empty($famne_options['send_email_change_email']) && !function_exists('dont_send_email_change_email') ) :
56
+ /**
57
+ * Email users e-mail change notification to registered user.
58
+ *
59
+ */
60
+ //echo "dont_send_email_change_email off";
61
+ function dont_send_email_change_email( $send=false, $user='', $userdata='')
62
+ {
63
+ return false;
64
+ }
65
+ add_filter('send_email_change_email', 'dont_send_email_change_email',1,3);
66
+ endif;
67
+
68
+
69
+
70
+ if (!function_exists('wp_new_user_notification') ) :
71
+ /**
72
+ * Email login credentials to a newly-registered user.
73
+ *
74
+ * A new user registration notification is also sent to admin email.
75
+ */
76
+ //echo "wp_new_user_notification off";
77
+ function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) {
78
+
79
+ global $famne_options;
80
+
81
+ if (!empty($famne_options['wp_new_user_notification_to_admin']))
82
+ {
83
+ fa_new_user_notification_to_admin($user_id,$deprecated,$notify);
84
+ }
85
+ if (!empty($famne_options['wp_new_user_notification_to_user']))
86
+ {
87
+ fa_new_user_notification_to_user($user_id,$deprecated,$notify);
88
+ }
89
+ }
90
+ endif;
91
+
92
+ if (empty($famne_options['wp_notify_postauthor']) && !function_exists('wp_notify_postauthor') ) :
93
+ /**
94
+ * Notify an author (and/or others) of a comment/trackback/pingback on a post.
95
+ */
96
+ //echo "wp_notify_postauthor off";
97
+ function wp_notify_postauthor( $comment_id, $deprecated = null ) {}
98
+ endif;
99
+
100
+ if (empty($famne_options['wp_notify_moderator']) && !function_exists('wp_notify_moderator') ) :
101
+ /**
102
+ * Notifies the moderator of the blog about a new comment that is awaiting approval.
103
+ */
104
+ //echo "wp_notify_moderator off";
105
+ function wp_notify_moderator($comment_id) {}
106
+ endif;
107
+
108
+
109
+
110
+
111
+ if (empty($famne_options['wp_password_change_notification']) && !function_exists('wp_password_change_notification') ) :
112
+ /**
113
+ * Notify the blog admin of a user changing password, normally via email.
114
+ */
115
+ function wp_password_change_notification($user) {}
116
+
117
+
118
+ endif;
119
+
120
+
121
+
122
+ if ((empty($famne_options['send_password_forgotten_email']) || empty($famne_options['send_password_admin_forgotten_email'])) && !function_exists('dont_send_password_forgotten_email') ) :
123
+ /**
124
+ * Email forgotten password notification to registered user.
125
+ *
126
+ */
127
+ //echo "dont_send_password_forgotten_email off";exit;
128
+ function dont_send_password_forgotten_email( $send=true, $user_id=0 )
129
+ {
130
+ global $famne_options;
131
+
132
+ $is_administrator = fa_user_is_administrator($user_id);
133
+
134
+ if ($is_administrator && empty($famne_options['send_password_admin_forgotten_email']))
135
+ {
136
+ // stop sending admin forgot email
137
+ return false;
138
+ }
139
+ if (!$is_administrator && empty($famne_options['send_password_forgotten_email']))
140
+ {
141
+ // stop sending user forgot email
142
+ return false;
143
+ }
144
+ // none of the above so give the default status back
145
+ return $send;
146
+ }
147
+ add_filter('allow_password_reset', 'dont_send_password_forgotten_email',1,3);
148
+ endif;
149
+
150
+
151
+
152
+
153
+ if (empty($famne_options['auto_core_update_send_email']) && !function_exists('fa_dont_sent_auto_core_update_emails') ) :
154
+ /**
155
+ * Send email when wordpress automatic updated.
156
+ *
157
+ */
158
+ //echo "auto_core_update_send_email off";exit;
159
+
160
+
161
+ function fa_dont_sent_auto_core_update_emails( $send, $type, $core_update, $result ) {
162
+ if ( ! empty( $type ) && $type == 'success' ) {
163
+ return false;
164
+ }
165
+ return true;
166
+ }
167
+ add_filter( 'auto_core_update_send_email', 'fa_dont_sent_auto_core_update_emails', 10, 4 );
168
+ endif;
169
+
170
+
171
+
172
+ function fa_new_user_notification_to_admin ($user_id,$deprecated,$notify='')
173
+ {
174
+
175
+ //Most parts of this function are copied form pluggable.php
176
+
177
+ if ( $deprecated !== null ) {
178
+ _deprecated_argument( __FUNCTION__, '4.3.1' );
179
+ }
180
+
181
+ global $wpdb, $wp_hasher;
182
+ $user = get_userdata( $user_id );
183
+
184
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
185
+ // we want to reverse this for the plain text arena of emails.
186
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
187
+
188
+ if ( 'user' !== $notify ) {
189
+ $switched_locale = switch_to_locale( get_locale() );
190
+
191
+ /* translators: %s: site title */
192
+ $message = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
193
+ /* translators: %s: user login */
194
+ $message .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
195
+ /* translators: %s: user email address */
196
+ $message .= sprintf( __( 'Email: %s' ), $user->user_email ) . "\r\n";
197
+
198
+ $wp_new_user_notification_email_admin = array(
199
+ 'to' => get_option( 'admin_email' ),
200
+ /* translators: New user registration notification email subject. %s: Site title */
201
+ 'subject' => __( '[%s] New User Registration' ),
202
+ 'message' => $message,
203
+ 'headers' => '',
204
+ );
205
+
206
+ /**
207
+ * Filters the contents of the new user notification email sent to the site admin.
208
+ *
209
+ * @since 4.9.0
210
+ *
211
+ * @param array $wp_new_user_notification_email {
212
+ * Used to build wp_mail().
213
+ *
214
+ * @type string $to The intended recipient - site admin email address.
215
+ * @type string $subject The subject of the email.
216
+ * @type string $message The body of the email.
217
+ * @type string $headers The headers of the email.
218
+ * }
219
+ * @param WP_User $user User object for new user.
220
+ * @param string $blogname The site title.
221
+ */
222
+ $wp_new_user_notification_email_admin = apply_filters( 'wp_new_user_notification_email_admin', $wp_new_user_notification_email_admin, $user, $blogname );
223
+
224
+ @wp_mail(
225
+ $wp_new_user_notification_email_admin['to'],
226
+ wp_specialchars_decode( sprintf( $wp_new_user_notification_email_admin['subject'], $blogname ) ),
227
+ $wp_new_user_notification_email_admin['message'],
228
+ $wp_new_user_notification_email_admin['headers']
229
+ );
230
+
231
+ if ( $switched_locale ) {
232
+ restore_previous_locale();
233
+ }
234
+ }
235
+ }
236
+
237
+
238
+ function fa_new_user_notification_to_user($user_id,$deprecated=null,$notify='')
239
+ {
240
+ if ( $deprecated !== null ) {
241
+ _deprecated_argument( __FUNCTION__, '4.3.1' );
242
+ }
243
+
244
+ // Accepts only 'user', 'admin' , 'both' or default '' as $notify
245
+ if ( ! in_array( $notify, array( 'user', 'admin', 'both', '' ), true ) ) {
246
+ return;
247
+ }
248
+
249
+ global $wpdb, $wp_hasher;
250
+ $user = get_userdata( $user_id );
251
+
252
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
253
+ // we want to reverse this for the plain text arena of emails.
254
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
255
+
256
+ // `$deprecated was pre-4.3 `$plaintext_pass`. An empty `$plaintext_pass` didn't sent a user notification.
257
+ if ( 'admin' === $notify || ( empty( $deprecated ) && empty( $notify ) ) ) {
258
+ return;
259
+ }
260
+
261
+ // Generate something random for a password reset key.
262
+ $key = wp_generate_password( 20, false );
263
+
264
+ /** This action is documented in wp-login.php */
265
+ do_action( 'retrieve_password_key', $user->user_login, $key );
266
+
267
+ // Now insert the key, hashed, into the DB.
268
+ if ( empty( $wp_hasher ) ) {
269
+ require_once ABSPATH . WPINC . '/class-phpass.php';
270
+ $wp_hasher = new PasswordHash( 8, true );
271
+ }
272
+ $hashed = time() . ':' . $wp_hasher->HashPassword( $key );
273
+ $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) );
274
+
275
+ $switched_locale = switch_to_locale( get_user_locale( $user ) );
276
+
277
+ /* translators: %s: user login */
278
+ $message = sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
279
+ $message .= __( 'To set your password, visit the following address:' ) . "\r\n\r\n";
280
+ $message .= '<' . network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' ) . ">\r\n\r\n";
281
+
282
+ $message .= wp_login_url() . "\r\n";
283
+
284
+ $wp_new_user_notification_email = array(
285
+ 'to' => $user->user_email,
286
+ /* translators: Login details notification email subject. %s: Site title */
287
+ 'subject' => __( '[%s] Login Details' ),
288
+ 'message' => $message,
289
+ 'headers' => '',
290
+ );
291
+
292
+ /**
293
+ * Filters the contents of the new user notification email sent to the new user.
294
+ *
295
+ * @since 4.9.0
296
+ *
297
+ * @param array $wp_new_user_notification_email {
298
+ * Used to build wp_mail().
299
+ *
300
+ * @type string $to The intended recipient - New user email address.
301
+ * @type string $subject The subject of the email.
302
+ * @type string $message The body of the email.
303
+ * @type string $headers The headers of the email.
304
+ * }
305
+ * @param WP_User $user User object for new user.
306
+ * @param string $blogname The site title.
307
+ */
308
+ $wp_new_user_notification_email = apply_filters( 'wp_new_user_notification_email', $wp_new_user_notification_email, $user, $blogname );
309
+
310
+ wp_mail(
311
+ $wp_new_user_notification_email['to'],
312
+ wp_specialchars_decode( sprintf( $wp_new_user_notification_email['subject'], $blogname ) ),
313
+ $wp_new_user_notification_email['message'],
314
+ $wp_new_user_notification_email['headers']
315
+ );
316
+
317
+ if ( $switched_locale ) {
318
+ restore_previous_locale();
319
+ }
320
+ }
321
+
322
+ function fa_user_is_administrator($user_id=0)
323
+ {
324
+ $user = new WP_User( intval($user_id) );
325
+ $is_administrator = false;
326
+ if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
327
+ foreach ( $user->roles as $role )
328
+ if ( strtolower($role) == 'administrator') $is_administrator = true;
329
+ }
330
+ return $is_administrator;
331
+ }
332
+
333
+
334
+
335
+ if (empty($famne_options['auto_plugin_update_send_email']) ) :
336
+ /**
337
+ * Email automatic plugin update notification to admin.
338
+ *
339
+ */
340
+ //echo "auto_plugin_update_send_email off";
341
+ function fa_auto_plugin_update_send_email($notifications_enabled,$update_results_plugins)
342
+ {
343
+ if ( $notifications_enabled ) {
344
+ foreach ( $update_results_plugins as $update_result ) {
345
+ // do we have a failed update?
346
+ if ( true !== $update_result->result ) $notifications_enabled = false;
347
+ }
348
+ }
349
+ return $notifications_enabled;
350
+ }
351
+
352
+ add_filter( 'auto_plugin_update_send_email', 'fa_auto_plugin_update_send_email',10,2 );
353
+ endif;
354
+
355
+
356
+ if (empty($famne_options['auto_theme_update_send_email']) ) :
357
+ /**
358
+ * Email automatic theme update notification to admin.
359
+ *
360
+ */
361
+ //echo "auto_theme_update_send_email off";
362
+ function fa_auto_theme_update_send_email($notifications_enabled,$update_results_theme)
363
+ {
364
+ $notifications_enabled = false;
365
+
366
+ foreach ( $update_results_theme as $update_result ) {
367
+ // do we have a failed update?
368
+ if ( true !== $update_result->result ) $notifications_enabled = true;
369
+ }
370
+ return $notifications_enabled;
371
+ }
372
+
373
+ add_filter( 'auto_theme_update_send_email', 'fa_auto_theme_update_send_email',10,2 );
374
+ endif;
manage-notification-emails.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /*
3
  Plugin Name: Manage Notification E-mails
4
- Plugin URI: https://www.freeamigos.nl/wp-plugins/manage-notification-emails/1.5.1
5
  Description: This plugin gives you the option to disable some of the notification e-mails send by Wordpress. It's a simple plugin but effective.
6
- Version: 1.5.1
7
  Author: Virgial Berveling
8
  Author URI: https://www.freeamigos.nl
9
  Text Domain: manage-notification-emails
@@ -59,7 +59,7 @@ License: GPLv2
59
 
60
  if (!defined('ABSPATH')) die();
61
 
62
- define( 'FA_MNE_VERSION', '1.5.1' );
63
  define( 'FA_MNE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
64
  define( 'FA_MNE_PLUGIN_DIR', untrailingslashit( dirname( __FILE__ ) ) );
65
 
@@ -70,12 +70,14 @@ define( 'FA_MNE_PLUGIN_DIR', untrailingslashit( dirname( __FILE__ ) ) );
70
  * @since 1.0.0
71
  */
72
 
 
 
73
  function fa_mne_init() {
 
74
 
75
  if (is_admin()) :
76
-
77
- include_once( FA_MNE_PLUGIN_DIR . '/includes/class.FAMNESettingsPage.php' );
78
- $fa_MNESettingsPage = new FAMNESettingsPage();
79
  endif;
80
  }
81
 
@@ -86,7 +88,7 @@ include_once( FA_MNE_PLUGIN_DIR . '/includes/class.FAMNESettingsPage.php' );
86
  */
87
  global $wp_version;
88
  if (version_compare($wp_version, '5.2.0') >= 0) {
89
- include_once( FA_MNE_PLUGIN_DIR . '/includes/pluggable-functions-1.4.php' );
90
  }elseif (version_compare($wp_version, '4.7.0') >= 0) {
91
  include_once( FA_MNE_PLUGIN_DIR . '/includes/pluggable-functions-1.3.php' );
92
  }else {
1
  <?php
2
  /*
3
  Plugin Name: Manage Notification E-mails
4
+ Plugin URI: https://www.freeamigos.nl/wp-plugins/manage-notification-emails/1.6.0
5
  Description: This plugin gives you the option to disable some of the notification e-mails send by Wordpress. It's a simple plugin but effective.
6
+ Version: 1.6.0
7
  Author: Virgial Berveling
8
  Author URI: https://www.freeamigos.nl
9
  Text Domain: manage-notification-emails
59
 
60
  if (!defined('ABSPATH')) die();
61
 
62
+ define( 'FA_MNE_VERSION', '1.6.0' );
63
  define( 'FA_MNE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
64
  define( 'FA_MNE_PLUGIN_DIR', untrailingslashit( dirname( __FILE__ ) ) );
65
 
70
  * @since 1.0.0
71
  */
72
 
73
+ include_once( FA_MNE_PLUGIN_DIR . '/includes/class.FAMNE.php' );
74
+
75
  function fa_mne_init() {
76
+ add_action( 'plugins_loaded', 'FAMNE::update_check');
77
 
78
  if (is_admin()) :
79
+ include_once( FA_MNE_PLUGIN_DIR . '/includes/class.FAMNESettingsPage.php' );
80
+ new FAMNESettingsPage();
 
81
  endif;
82
  }
83
 
88
  */
89
  global $wp_version;
90
  if (version_compare($wp_version, '5.2.0') >= 0) {
91
+ include_once( FA_MNE_PLUGIN_DIR . '/includes/pluggable-functions-1.5.php' );
92
  }elseif (version_compare($wp_version, '4.7.0') >= 0) {
93
  include_once( FA_MNE_PLUGIN_DIR . '/includes/pluggable-functions-1.3.php' );
94
  }else {
readme.txt CHANGED
@@ -1,14 +1,14 @@
1
  === Plugin Name ===
2
  Contributors: (Virgial)
3
- Tags: notification,notify,email,user,password,moderator,postauthor,admin,e-mail,switch
4
  Requires at least: 4.0.0
5
  Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TYG56SLWNG42N
6
- Tested up to: 5.4.0
7
- Stable tag: 1.5.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Disable or enable the Wordpress notification e-mails (new user, changed password, etc.). Works perfectly in combination with a lot of other plugins!
12
 
13
  == Description ==
14
 
@@ -29,6 +29,11 @@ Watch this nice tut made by Robert Orzanna:
29
  7. E-mail address change notification to user
30
  8. Forgotten password e-mail to user
31
  9. Forgotten password e-mail to administrator
 
 
 
 
 
32
 
33
 
34
  Want regular updates? Feel free to support me with a small donation :-)
@@ -62,6 +67,9 @@ If you're one of the early installers, than you'll be happy to see that de new u
62
 
63
  == Changelog ==
64
 
 
 
 
65
  = 1.5.1 =
66
  FIXED: php-notice for missing $deprecated variable.
67
  = 1.5.0 =
1
  === Plugin Name ===
2
  Contributors: (Virgial)
3
+ Tags: notification,notify,email,user,password,moderator,postauthor,automatic updates, admin e-mail,switch
4
  Requires at least: 4.0.0
5
  Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TYG56SLWNG42N
6
+ Tested up to: 5.6
7
+ Stable tag: 1.6.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Disable or enable the Wordpress notification e-mails (new user, changed password, automatic updates, etc.). Works perfectly in combination with a lot of other plugins!
12
 
13
  == Description ==
14
 
29
  7. E-mail address change notification to user
30
  8. Forgotten password e-mail to user
31
  9. Forgotten password e-mail to administrator
32
+ 10. Automatic Wordpress core update e-mail
33
+ 11. Automatic Wordpress plugin update e-mail *NEW*
34
+ 12. Automatic Wordpress theme update e-mail *NEW*
35
+
36
+ The automatic core, plugin, and theme updates have a special built-in feature. When one of these options is disabled, successful e-mails don't get send out, but failed updates still will send an e-mail to the admin.
37
 
38
 
39
  Want regular updates? Feel free to support me with a small donation :-)
67
 
68
  == Changelog ==
69
 
70
+ = 1.6.0 =
71
+ ADDED: Automatic Wordpress plugin, and theme update e-mail options.
72
+
73
  = 1.5.1 =
74
  FIXED: php-notice for missing $deprecated variable.
75
  = 1.5.0 =
screen-1.png CHANGED
Binary file