Better Notifications for WordPress - Version 1.3.1

Version Description

  • Fixed: The P2 theme wasn't triggering new post or comment notifications.
  • Fixed: Sometimes the shortcode help link at the bottom of the notification editor wouldn't link to the help page properly.
Download this release

Release Info

Developer voltronik
Plugin Icon 128x128 Better Notifications for WordPress
Version 1.3.1
Comparing to
See all releases

Code changes from version 1.3 to 1.3.1

Files changed (3) hide show
  1. README.txt +5 -1
  2. assets/js/bnfw.js +41 -2
  3. bnfw.php +16 -4
README.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: voltronik
3
  Tags: notifications, email, mail, alerts, roles, user, users, admin, HTML, plain, wp_mail, shortcode, customize, post, page, updated, pending review, scheduled, category, tag, term, custom post type, comment, akismet, trackback, pingback, lost password, welcome, new user, bulk, notice, trigger, CC, BCC, from
4
  Requires at least: 3.5
5
  Tested up to: 4.2.2
6
- Stable tag: 1.3
7
  License: GPLv2 or later
8
 
9
  Send customisable HTML emails to your users for different WordPress notifications.
@@ -160,6 +160,10 @@ It might do but this is untested.
160
 
161
  == Changelog ==
162
 
 
 
 
 
163
  = 1.3 =
164
  * New: Option to disable notifications going to the user that triggered them.
165
  * New: Comment Reply Notification. This is a transactional notification that will only trigger when replying to the original comment (i.e. Up to 2-levels deep).
3
  Tags: notifications, email, mail, alerts, roles, user, users, admin, HTML, plain, wp_mail, shortcode, customize, post, page, updated, pending review, scheduled, category, tag, term, custom post type, comment, akismet, trackback, pingback, lost password, welcome, new user, bulk, notice, trigger, CC, BCC, from
4
  Requires at least: 3.5
5
  Tested up to: 4.2.2
6
+ Stable tag: 1.3.1
7
  License: GPLv2 or later
8
 
9
  Send customisable HTML emails to your users for different WordPress notifications.
160
 
161
  == Changelog ==
162
 
163
+ = 1.3.1 =
164
+ * Fixed: The P2 theme wasn't triggering new post or comment notifications.
165
+ * Fixed: Sometimes the shortcode help link at the bottom of the notification editor wouldn't link to the help page properly.
166
+
167
  = 1.3 =
168
  * New: Option to disable notifications going to the user that triggered them.
169
  * New: Comment Reply Notification. This is a transactional notification that will only trigger when replying to the original comment (i.e. Up to 2-levels deep).
assets/js/bnfw.js CHANGED
@@ -43,8 +43,47 @@ jQuery(document).ready(function($) {
43
  });
44
 
45
  $( '#shortcode-help' ).on( 'click', function() {
46
- var notification = $( '#notification' ).val();
 
 
47
 
48
- $(this).attr( 'href', 'http://www.voltronik.co.uk/wordpress-plugins/better-notifications-for-wordpress-shortcodes/?notification=' + notification );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  });
50
  });
43
  });
44
 
45
  $( '#shortcode-help' ).on( 'click', function() {
46
+ var notification = $( '#notification' ).val(),
47
+ notification_slug = '',
48
+ splited;
49
 
50
+ switch( notification ) {
51
+ case 'new-comment':
52
+ case 'new-trackback':
53
+ case 'new-pingback':
54
+ case 'reply-comment':
55
+ case 'user-password':
56
+ case 'admin-password':
57
+ case 'new-user':
58
+ case 'welcome-email':
59
+ case 'admin-user':
60
+ case 'new-post':
61
+ case 'update-post':
62
+ case 'pending-post':
63
+ case 'future-post':
64
+ case 'newterm-category':
65
+ case 'newterm-post_tag':
66
+ notification_slug = notification;
67
+ break;
68
+
69
+ default:
70
+ splited = notification.split( '-' );
71
+ switch( splited[0] ) {
72
+ case 'new':
73
+ case 'update':
74
+ case 'pending':
75
+ case 'future':
76
+ case 'comment':
77
+ notification_slug = splited[0] + '-post';
78
+ break;
79
+ case 'newterm':
80
+ notification_slug = 'newterm-category';
81
+ break;
82
+ }
83
+
84
+ break;
85
+ }
86
+
87
+ $(this).attr( 'href', 'http://www.voltronik.co.uk/wordpress-plugins/better-notifications-for-wordpress-shortcodes/?notification=' + notification_slug );
88
  });
89
  });
bnfw.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Better Notifications for WordPress
4
  * Plugin URI: http://wordpress.org/plugins/bnfw/
5
  * Description: Send customisable HTML emails to your users for different WordPress notifications.
6
- * Version: 1.3
7
  * Author: Voltronik
8
  * Author URI: http://www.voltronik.co.uk/
9
  * Author Email: plugins@voltronik.co.uk
@@ -94,8 +94,8 @@ class BNFW {
94
  register_activation_hook( __FILE__ , array( $this, 'activate' ) );
95
 
96
  // P2 theme directly inserts the post into db
97
- if ( class_exists( 'P2' ) ) {
98
- add_action( 'wp_insert_post' , array( $this, 'publish_post' ) );
99
  }
100
 
101
  add_action( 'draft_to_publish' , array( $this, 'publish_post' ) );
@@ -170,11 +170,23 @@ class BNFW {
170
  $this->send_notification( 'newterm-' . $taxonomy, $term_id );
171
  }
172
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  /**
174
  * Fires when a post is created for the first time.
175
  *
176
  * @since 1.0
177
- * @param unknown $post
178
  */
179
  function publish_post( $post ) {
180
  $post_id = $post->ID;
3
  * Plugin Name: Better Notifications for WordPress
4
  * Plugin URI: http://wordpress.org/plugins/bnfw/
5
  * Description: Send customisable HTML emails to your users for different WordPress notifications.
6
+ * Version: 1.3.1
7
  * Author: Voltronik
8
  * Author URI: http://www.voltronik.co.uk/
9
  * Author Email: plugins@voltronik.co.uk
94
  register_activation_hook( __FILE__ , array( $this, 'activate' ) );
95
 
96
  // P2 theme directly inserts the post into db
97
+ if ( 'P2' == get_current_theme() ) {
98
+ add_action( 'wp_insert_post' , array( $this, 'insert_post' ), 10, 3 );
99
  }
100
 
101
  add_action( 'draft_to_publish' , array( $this, 'publish_post' ) );
170
  $this->send_notification( 'newterm-' . $taxonomy, $term_id );
171
  }
172
 
173
+ /**
174
+ * Fires when a post is created for the first time.
175
+ *
176
+ * @since 1.3.1
177
+ * @param int $post_id Post ID
178
+ * @param object $post Post object
179
+ * @param bool $update Whether it was an update
180
+ */
181
+ public function insert_post( $post_id, $post, $update ) {
182
+ $this->publish_post( $post );
183
+ }
184
+
185
  /**
186
  * Fires when a post is created for the first time.
187
  *
188
  * @since 1.0
189
+ * @param object $post Post Object
190
  */
191
  function publish_post( $post ) {
192
  $post_id = $post->ID;