Manage Notification E-mails - Version 1.8.4

Version Description

UPDATED: Refactoring.

Download this release

Release Info

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

Code changes from version 1.8.3 to 1.8.4

core/class.FAMNE.php CHANGED
@@ -98,7 +98,7 @@ if ( ! class_exists( 'FAMNE' ) ) :
98
  while ( is_array( self::$notices ) && $count > 0 ) :
99
  $notice = array_pop( self::$notices );
100
  $dismissible = $notice['dismissible'] ? ' is-dismissible' : '';
101
- printf( '<div class="%1$s"><p>%2$s</p></div>', 'notice notice-' . $notice['priority'] . $dismissible, $notice['message'] );
102
  endwhile;
103
  }
104
 
@@ -254,11 +254,14 @@ if ( ! class_exists( 'FAMNE' ) ) :
254
 
255
  global $wpdb;
256
  $site_ids = $wpdb->get_col(
257
- "
258
- SELECT `blog_id`
259
- FROM `{$wpdb->blogs}`
260
- WHERE `site_id` = {$wpdb->siteid}
261
- "
 
 
 
262
  );
263
  return $site_ids;
264
  }
@@ -289,7 +292,7 @@ if ( ! class_exists( 'FAMNE' ) ) :
289
 
290
  if ( is_multisite() ) {
291
  foreach ( self::get_all_site_ids() as $id ) {
292
- delete_blog_option( $id, 'famne_options' );
293
  }
294
  }
295
  }
98
  while ( is_array( self::$notices ) && $count > 0 ) :
99
  $notice = array_pop( self::$notices );
100
  $dismissible = $notice['dismissible'] ? ' is-dismissible' : '';
101
+ printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( 'notice notice-' . $notice['priority'] . $dismissible ), esc_html( $notice['message'] ) );
102
  endwhile;
103
  }
104
 
254
 
255
  global $wpdb;
256
  $site_ids = $wpdb->get_col(
257
+ $wpdb->prepare(
258
+ "
259
+ SELECT `blog_id`
260
+ FROM `{$wpdb->blogs}`
261
+ WHERE `site_id` = %d
262
+ ",
263
+ $wpdb->siteid
264
+ )
265
  );
266
  return $site_ids;
267
  }
292
 
293
  if ( is_multisite() ) {
294
  foreach ( self::get_all_site_ids() as $id ) {
295
+ delete_blog_option( intval( $id ), 'famne_options' );
296
  }
297
  }
298
  }
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.8.3
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.8.3
7
  Author: Virgial Berveling
8
  Author URI: https://www.freeamigos.nl
9
  Text Domain: manage-notification-emails
@@ -60,7 +60,7 @@ if ( ! defined( 'ABSPATH' ) ) {
60
  die();
61
  }
62
 
63
- define( 'FA_MNE_VERSION', '1.8.3' );
64
  define( 'FA_MNE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
65
  define( 'FA_MNE_PLUGIN_DIR', untrailingslashit( dirname( __FILE__ ) ) );
66
  define( 'FA_MNE_SLUG', 'manage-notification-emails' );
1
  <?php
2
  /*
3
  Plugin Name: Manage Notification E-mails
4
+ Plugin URI: https://www.freeamigos.nl/wp-plugins/manage-notification-emails/1.8.4
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.8.4
7
  Author: Virgial Berveling
8
  Author URI: https://www.freeamigos.nl
9
  Text Domain: manage-notification-emails
60
  die();
61
  }
62
 
63
+ define( 'FA_MNE_VERSION', '1.8.4' );
64
  define( 'FA_MNE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
65
  define( 'FA_MNE_PLUGIN_DIR', untrailingslashit( dirname( __FILE__ ) ) );
66
  define( 'FA_MNE_SLUG', 'manage-notification-emails' );
modules/export-settings.php CHANGED
@@ -45,14 +45,14 @@ function load_mod_famne_export_settings() {
45
  return;
46
  }
47
 
48
- $downloadlink = $pagenow . '?' . 'page=' . sanitize_text_field( $_GET['page'] ) . '&export-settings=famne';
49
 
50
  ?>
51
  <div class="card">
52
  <h2 class="title"><?php esc_html_e( 'Export and import settings', 'manage-notification-emails' ); ?></h2>
53
  <?php esc_html_e( 'Here you can export or import your Manage notification e-mails settings.', 'manage-notification-emails' ); ?>
54
  <br/><br/><strong><?php esc_html_e( 'Export your settings in JSON format', 'manage-notification-emails' ); ?></strong><br/>
55
- <a href="<?php echo $downloadlink; ?>" class="button" target="_blank" rel="noopener"><?php esc_html_e( 'Export settings file', 'manage-notification-emails' ); ?></a>
56
  <br/><br/><strong><?php esc_html_e( 'Import setting in JSON format', 'manage-notification-emails' ); ?></strong><br/>
57
  <input type="file" id="settings-upload-file" name="settings-upload-file" accept="application/JSON" data-message="<?php esc_html_e( 'Do you want to overwrite your current settings?', 'manage-notification-emails' ); ?>"/>
58
  <input type="submit" class="button button-primary" id="settings-upload-submit" disabled="disabled" value="<?php esc_html_e( 'Start import', 'manage-notification-emails' ); ?>" />
@@ -92,7 +92,6 @@ function load_mod_famne_export_settings() {
92
 
93
  // Get file data.
94
 
95
-
96
  // Check errors.
97
  if ( $file['error'] ) {
98
  wp_die( __( 'Error uploading file. Please try again.', 'manage-notification-emails' ) );
@@ -103,7 +102,6 @@ function load_mod_famne_export_settings() {
103
  wp_die( __( 'Incorrect file type.', 'manage-notification-emails' ) );
104
  }
105
 
106
-
107
  // Check file size.
108
  if ( $file['size'] > 100000 ) {
109
  wp_die( __( 'File size exceeds maximum upload limit.', 'manage-notification-emails' ) );
@@ -131,7 +129,7 @@ function load_mod_famne_export_settings() {
131
 
132
  // Get all available options.
133
  $available_options = array();
134
- foreach ( FAMNE::default_options() as $key=>$o ) :
135
  $available_options[] = $key;
136
  endforeach;
137
  foreach ( FAMNE::getModules() as $mod ) :
45
  return;
46
  }
47
 
48
+ $downloadlink = $pagenow . '?page=' . sanitize_text_field( $_GET['page'] ) . '&export-settings=famne';
49
 
50
  ?>
51
  <div class="card">
52
  <h2 class="title"><?php esc_html_e( 'Export and import settings', 'manage-notification-emails' ); ?></h2>
53
  <?php esc_html_e( 'Here you can export or import your Manage notification e-mails settings.', 'manage-notification-emails' ); ?>
54
  <br/><br/><strong><?php esc_html_e( 'Export your settings in JSON format', 'manage-notification-emails' ); ?></strong><br/>
55
+ <a href="<?php echo esc_url( $downloadlink ); ?>" class="button" target="_blank" rel="noopener"><?php esc_html_e( 'Export settings file', 'manage-notification-emails' ); ?></a>
56
  <br/><br/><strong><?php esc_html_e( 'Import setting in JSON format', 'manage-notification-emails' ); ?></strong><br/>
57
  <input type="file" id="settings-upload-file" name="settings-upload-file" accept="application/JSON" data-message="<?php esc_html_e( 'Do you want to overwrite your current settings?', 'manage-notification-emails' ); ?>"/>
58
  <input type="submit" class="button button-primary" id="settings-upload-submit" disabled="disabled" value="<?php esc_html_e( 'Start import', 'manage-notification-emails' ); ?>" />
92
 
93
  // Get file data.
94
 
 
95
  // Check errors.
96
  if ( $file['error'] ) {
97
  wp_die( __( 'Error uploading file. Please try again.', 'manage-notification-emails' ) );
102
  wp_die( __( 'Incorrect file type.', 'manage-notification-emails' ) );
103
  }
104
 
 
105
  // Check file size.
106
  if ( $file['size'] > 100000 ) {
107
  wp_die( __( 'File size exceeds maximum upload limit.', 'manage-notification-emails' ) );
129
 
130
  // Get all available options.
131
  $available_options = array();
132
+ foreach ( FAMNE::default_options() as $key => $o ) :
133
  $available_options[] = $key;
134
  endforeach;
135
  foreach ( FAMNE::getModules() as $mod ) :
modules/settings-page/class.FAMNESettingsPage.php CHANGED
@@ -146,7 +146,7 @@ if ( ! class_exists( 'FAMNESettingsPage' ) ) :
146
  self::MENU_SLUG // Page.
147
  );
148
 
149
- if ( isset( $_GET['famne_reset'] ) && strval( $_GET['famne_reset'] ) === '1' ) {
150
  $this->reset_settings();
151
  }
152
  }
@@ -229,8 +229,8 @@ if ( ! class_exists( 'FAMNESettingsPage' ) ) :
229
 
230
  if ( ! empty( $_POST ) && check_admin_referer( 'famnenetwork_save', 'famnenetwork' ) ) {
231
 
232
- $network_activated = FAMNE::get_option( 'famne_network_managed');
233
- $network_managed = ! empty( $_POST['famne_options'] ) && '1' === $_POST['famne_options']['network_managed'] ? '1' : null;
234
  FAMNE::update_option( 'famne_network_managed', $network_managed );
235
 
236
  if ( $network_managed ) :
@@ -265,13 +265,12 @@ if ( ! class_exists( 'FAMNESettingsPage' ) ) :
265
  }
266
  }
267
 
268
- private function reset_settings()
269
- {
270
- if ( ! isset ( $_GET['famne_reset'] ) || strval( $_GET['famne_reset'] ) !== '1' || ! isset( $_GET['nonce'] ) ):
271
  return;
272
  endif;
273
 
274
- if ( ! wp_verify_nonce( $_GET['nonce'], 'famne_reset' )) :
275
  wp_nonce_ays( '' );
276
  die();
277
  endif;
@@ -336,16 +335,18 @@ if ( ! class_exists( 'FAMNESettingsPage' ) ) :
336
 
337
  ksort( self::$sections );
338
  foreach ( self::$sections as &$section ) {
339
- $icon = ! empty( $section['icon'] ) ? 'data-icon="' . $section['icon'] . '"' : '';
340
  echo PHP_EOL;
341
- echo '<div class="sections-container" id="sections-' . $section['slug'] . '" title="' . ucfirst( __( $section['title'] ) ) . '" ' . $icon . '>';
342
 
343
  if ( ! empty( $section['view_file'] ) ) :
344
-
345
- include_once FA_MNE_PLUGIN_DIR . '/modules/settings-page/' . '/views/' . basename( $section['view_file'] );
 
 
346
  endif;
347
  if ( ! empty( $section['html'] ) ) {
348
- echo $section['html'];
349
  }
350
  echo '</div>';
351
  echo PHP_EOL;
146
  self::MENU_SLUG // Page.
147
  );
148
 
149
+ if ( isset( $_GET['famne_reset'] ) && is_string( $_GET['famne_reset'] ) && '1' === $_GET['famne_reset'] ) {
150
  $this->reset_settings();
151
  }
152
  }
229
 
230
  if ( ! empty( $_POST ) && check_admin_referer( 'famnenetwork_save', 'famnenetwork' ) ) {
231
 
232
+ $network_activated = FAMNE::get_option( 'famne_network_managed' );
233
+ $network_managed = ! empty( $_POST['famne_options'] ) && '1' === $_POST['famne_options']['network_managed'] ? '1' : null;
234
  FAMNE::update_option( 'famne_network_managed', $network_managed );
235
 
236
  if ( $network_managed ) :
265
  }
266
  }
267
 
268
+ private function reset_settings() {
269
+ if ( ! isset( $_GET['famne_reset'] ) || ! is_string( $_GET['famne_reset'] ) || '1' !== $_GET['famne_reset'] || ! isset( $_GET['nonce'] ) ) :
 
270
  return;
271
  endif;
272
 
273
+ if ( ! wp_verify_nonce( $_GET['nonce'], 'famne_reset' ) ) :
274
  wp_nonce_ays( '' );
275
  die();
276
  endif;
335
 
336
  ksort( self::$sections );
337
  foreach ( self::$sections as &$section ) {
338
+ $icon = ! empty( $section['icon'] ) ? 'data-icon="' . esc_attr( $section['icon'] ) . '"' : '';
339
  echo PHP_EOL;
340
+ echo '<div class="sections-container" id="' . esc_attr( 'sections-' . $section['slug'] ) . '" title="' . esc_attr( ucfirst( __( $section['title'] ) ) ) . '" ' . $icon . '>';
341
 
342
  if ( ! empty( $section['view_file'] ) ) :
343
+ $view_file = FA_MNE_PLUGIN_DIR . '/modules/settings-page/views/' . basename( $section['view_file'] );
344
+ if ( file_exists( $view_file ) ) {
345
+ include_once $view_file;
346
+ }
347
  endif;
348
  if ( ! empty( $section['html'] ) ) {
349
+ echo esc_html( $section['html'] );
350
  }
351
  echo '</div>';
352
  echo PHP_EOL;
modules/settings-page/views/extra.php CHANGED
@@ -29,7 +29,7 @@ $modules = FAMNE::getModules();
29
  foreach ( $modules as $module ) :
30
  $icon = $module->licensed ? 'dashicons-products"' : 'dashicons-admin-plugins';
31
  ?>
32
- <li><span class="dashicons-before <?php echo $icon; ?>"></span><?php echo $module->name; ?> (<?php echo $module->version; ?>)</li>
33
  <?php endforeach; ?>
34
  </ul>
35
  </div>
29
  foreach ( $modules as $module ) :
30
  $icon = $module->licensed ? 'dashicons-products"' : 'dashicons-admin-plugins';
31
  ?>
32
+ <li><span class="dashicons-before <?php echo $icon; ?>"></span><?php echo esc_html( $module->name ); ?> (<?php echo esc_html( $module->version ); ?>)</li>
33
  <?php endforeach; ?>
34
  </ul>
35
  </div>
modules/settings-page/views/settings.php CHANGED
@@ -67,9 +67,10 @@ if ( is_multisite() && ! FAMNE::network_managed() ) {
67
  </div>
68
  <p style="float:right"><a href="#" onclick="resetToDefaults();return false" class="button"><?php _e( 'Reset settings', 'manage-notification-emails' ); ?></a></p>
69
  </div>
70
- <?php
71
  $admin_page = FAMNESettingsPage::is_famne_network_settings_page() ? 'network/settings.php?page=famne-network-admin&famne_reset=1' : 'options-general.php?page=famne-admin&famne_reset=1';
72
- $reset_url = str_replace( '&amp;', '&', wp_nonce_url( admin_url( $admin_page ), 'famne_reset', 'nonce') ) . '#settings';?>
 
73
  <script>
74
  function resetToDefaults(){
75
  var r = confirm('reset to default settings?');
67
  </div>
68
  <p style="float:right"><a href="#" onclick="resetToDefaults();return false" class="button"><?php _e( 'Reset settings', 'manage-notification-emails' ); ?></a></p>
69
  </div>
70
+ <?php
71
  $admin_page = FAMNESettingsPage::is_famne_network_settings_page() ? 'network/settings.php?page=famne-network-admin&famne_reset=1' : 'options-general.php?page=famne-admin&famne_reset=1';
72
+ $reset_url = str_replace( '&amp;', '&', wp_nonce_url( admin_url( $admin_page ), 'famne_reset', 'nonce' ) ) . '#settings';
73
+ ?>
74
  <script>
75
  function resetToDefaults(){
76
  var r = confirm('reset to default settings?');
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: notification,notify,email,user,password,moderator,postauthor,automatic upd
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: 6.0.2
7
- Stable tag: 1.8.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -74,6 +74,9 @@ Some other plugins also use their custom notifications which overwrite the core
74
  If you're one of the early installers, than you'll be happy to see that de new user notification is now splitted in admin and user e-mail management.
75
 
76
  == Changelog ==
 
 
 
77
  = 1.8.3 =
78
  FIXED: (CSRF) Security fix. Special thanks to Muhammad Daffa (Patchstack Alliance) for reporting this.
79
 
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: 6.0.2
7
+ Stable tag: 1.8.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
74
  If you're one of the early installers, than you'll be happy to see that de new user notification is now splitted in admin and user e-mail management.
75
 
76
  == Changelog ==
77
+ = 1.8.4 =
78
+ UPDATED: Refactoring.
79
+
80
  = 1.8.3 =
81
  FIXED: (CSRF) Security fix. Special thanks to Muhammad Daffa (Patchstack Alliance) for reporting this.
82