Better Notifications for WordPress - Version 1.1.5.2

Version Description

  • Fixed: Custom Post Type Pending Posts not being sent.
  • Fixed: Post excerpt not outputting anything.
  • Removed: [closedpostboxes_page], [rich_editing], and [admin_color] as was a bit defunct and causing issues.
  • Changed: [post_author] now outputs the display name instead of the author ID.
  • Improved: Clarity of custom post type and taxonomy labels.
Download this release

Release Info

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

Code changes from version 1.1.5.1 to 1.1.5.2

README.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: voltronik
3
  Tags: notifications, email, alerts, roles, users, HTML
4
  Requires at least: 3.5
5
  Tested up to: 4.1.1
6
- Stable tag: 1.1.5.1
7
  License: GPLv2 or later
8
 
9
  Send customisable HTML emails to your users for different WordPress notifications.
@@ -147,6 +147,13 @@ It might do but this is untested.
147
 
148
  == Changelog ==
149
 
 
 
 
 
 
 
 
150
  = 1.1.5.1 =
151
  * Fix for Custom Post Type notifications not populating shortcodes.
152
  * Fix for Custom Taxonomy terms not sending out notification emails.
3
  Tags: notifications, email, alerts, roles, users, HTML
4
  Requires at least: 3.5
5
  Tested up to: 4.1.1
6
+ Stable tag: 1.1.5.2
7
  License: GPLv2 or later
8
 
9
  Send customisable HTML emails to your users for different WordPress notifications.
147
 
148
  == Changelog ==
149
 
150
+ = 1.1.5.2 =
151
+ * Fixed: Custom Post Type Pending Posts not being sent.
152
+ * Fixed: Post excerpt not outputting anything.
153
+ * Removed: `[closedpostboxes_page], [rich_editing], and [admin_color]` as was a bit defunct and causing issues.
154
+ * Changed: `[post_author]` now outputs the display name instead of the author ID.
155
+ * Improved: Clarity of custom post type and taxonomy labels.
156
+
157
  = 1.1.5.1 =
158
  * Fix for Custom Post Type notifications not populating shortcodes.
159
  * Fix for Custom Taxonomy terms not sending out notification emails.
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.1.5.1
7
  * Author: Voltronik
8
  * Author URI: http://www.voltronik.co.uk/
9
  * Author Email: plugins@voltronik.co.uk
@@ -95,14 +95,8 @@ class BNFW {
95
 
96
  add_action( 'draft_to_publish' , array( $this, 'publish_post' ) );
97
  add_action( 'publish_to_publish' , array( $this, 'update_post' ) );
98
-
99
- $post_types = get_post_types( array( 'public' => true ), 'names' );
100
- $post_types = array_diff( $post_types, array( BNFW_Notification::POST_TYPE ) );
101
-
102
- foreach ( $post_types as $post_type ) {
103
- add_action( 'pending_' . $post_type, array( $this, 'on_post_pending' ), 10, 2 );
104
- add_action( 'future_' . $post_type, array( $this, 'on_post_scheduled' ), 10, 2 );
105
- }
106
 
107
  add_action( 'comment_post' , array( $this, 'comment_post' ) );
108
  add_action( 'trackback_post' , array( $this, 'trackback_post' ) );
@@ -115,16 +109,23 @@ class BNFW {
115
  add_filter( 'retrieve_password_title' , array( $this, 'change_password_email_title' ) );
116
  add_filter( 'retrieve_password_message' , array( $this, 'change_password_email_message' ), 10, 4 );
117
 
118
- add_action( 'create_term' , array( $this, 'create_term' ), 10, 3 );
119
-
120
  add_filter( 'plugin_action_links' , array( $this, 'plugin_action_links' ), 10, 4 );
121
  }
122
 
123
  /**
124
- * Run this on first-time plugin activation
125
  *
126
- * @since 1.0
127
  */
 
 
 
 
 
 
 
 
 
128
 
129
  /**
130
  * importer
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.1.5.2
7
  * Author: Voltronik
8
  * Author URI: http://www.voltronik.co.uk/
9
  * Author Email: plugins@voltronik.co.uk
95
 
96
  add_action( 'draft_to_publish' , array( $this, 'publish_post' ) );
97
  add_action( 'publish_to_publish' , array( $this, 'update_post' ) );
98
+ add_action( 'init' , array( $this, 'custom_post_type_hooks' ), 100 );
99
+ add_action( 'create_term' , array( $this, 'create_term' ), 10, 3 );
 
 
 
 
 
 
100
 
101
  add_action( 'comment_post' , array( $this, 'comment_post' ) );
102
  add_action( 'trackback_post' , array( $this, 'trackback_post' ) );
109
  add_filter( 'retrieve_password_title' , array( $this, 'change_password_email_title' ) );
110
  add_filter( 'retrieve_password_message' , array( $this, 'change_password_email_message' ), 10, 4 );
111
 
 
 
112
  add_filter( 'plugin_action_links' , array( $this, 'plugin_action_links' ), 10, 4 );
113
  }
114
 
115
  /**
116
+ * Setup hooks for custom post types.
117
  *
118
+ * @since 1.2
119
  */
120
+ function custom_post_type_hooks() {
121
+ $post_types = get_post_types( array( 'public' => true ), 'names' );
122
+ $post_types = array_diff( $post_types, array( BNFW_Notification::POST_TYPE ) );
123
+
124
+ foreach ( $post_types as $post_type ) {
125
+ add_action( 'pending_' . $post_type, array( $this, 'on_post_pending' ), 10, 2 );
126
+ add_action( 'future_' . $post_type, array( $this, 'on_post_scheduled' ), 10, 2 );
127
+ }
128
+ }
129
 
130
  /**
131
  * importer
includes/admin/class-bnfw-notification.php CHANGED
@@ -194,7 +194,7 @@ class BNFW_Notification {
194
  $post_obj = get_post_type_object( $type );
195
  $label = $post_obj->labels->singular_name;
196
  ?>
197
- <optgroup label="<?php _e( 'Custom Post Type - ', 'bnfw' ); echo $type; ?>">
198
  <option value="new-<?php echo $type; ?>" <?php selected( 'new-' . $type, $setting['notification'] );?>><?php echo __( 'New ', 'bnfw' ), "'$label'"; ?></option>
199
  <option value="update-<?php echo $type; ?>" <?php selected( 'update-' . $type, $setting['notification'] );?>><?php echo "'$label' " . __( 'Update ', 'bnfw' ); ?></option>
200
  <option value="pending-<?php echo $type; ?>" <?php selected( 'pending-' . $type, $setting['notification'] );?>><?php echo "'$label' ", __( 'Pending Review', 'bnfw' ); ?></option>
@@ -218,7 +218,7 @@ class BNFW_Notification {
218
  foreach ( $taxs as $tax ) {
219
  $tax_name = 'newterm-' . $tax->name;
220
  ?>
221
- <option value="<?php echo $tax_name; ?>" <?php selected( $tax_name, $setting['notification'] );?>><?php printf( '%s %s', __( 'New', 'bnfw' ), $tax->labels->name ); ?></option>
222
  <?php
223
  }
224
  ?>
@@ -705,6 +705,9 @@ class BNFW_Notification {
705
  case 'comment':
706
  return $label . __( ' Comment', 'bnfw' );
707
  break;
 
 
 
708
  }
709
  break;
710
  }
@@ -713,7 +716,6 @@ class BNFW_Notification {
713
  /**
714
  * Custom row actions for this post type.
715
  *
716
- *
717
  * @since 1.0
718
  * @filter post_row_actions
719
  * @param array $actions
194
  $post_obj = get_post_type_object( $type );
195
  $label = $post_obj->labels->singular_name;
196
  ?>
197
+ <optgroup label="<?php printf( "%s - '%s'", __( 'Custom Post Type', 'bnfw' ), $label ); ?>">
198
  <option value="new-<?php echo $type; ?>" <?php selected( 'new-' . $type, $setting['notification'] );?>><?php echo __( 'New ', 'bnfw' ), "'$label'"; ?></option>
199
  <option value="update-<?php echo $type; ?>" <?php selected( 'update-' . $type, $setting['notification'] );?>><?php echo "'$label' " . __( 'Update ', 'bnfw' ); ?></option>
200
  <option value="pending-<?php echo $type; ?>" <?php selected( 'pending-' . $type, $setting['notification'] );?>><?php echo "'$label' ", __( 'Pending Review', 'bnfw' ); ?></option>
218
  foreach ( $taxs as $tax ) {
219
  $tax_name = 'newterm-' . $tax->name;
220
  ?>
221
+ <option value="<?php echo $tax_name; ?>" <?php selected( $tax_name, $setting['notification'] );?>><?php printf( "%s '%s'", __( 'New', 'bnfw' ), $tax->labels->name ); ?></option>
222
  <?php
223
  }
224
  ?>
705
  case 'comment':
706
  return $label . __( ' Comment', 'bnfw' );
707
  break;
708
+ case 'newterm':
709
+ return __( 'New term in ', 'bnfw' ) . $splited[1];
710
+ break;
711
  }
712
  break;
713
  }
716
  /**
717
  * Custom row actions for this post type.
718
  *
 
719
  * @since 1.0
720
  * @filter post_row_actions
721
  * @param array $actions
includes/engine/class-bnfw-engine.php CHANGED
@@ -139,18 +139,17 @@ class BNFW_Engine {
139
  * @return unknown
140
  */
141
  private function post_shortcodes( $message, $post_id ) {
142
- $post = get_post( $post_id );
143
 
144
  $post_content = apply_filters( 'the_content', $post->post_content );
145
  $post_content = str_replace( ']]>', ']]&gt;', $post_content );
146
 
147
  $message = str_replace( '[ID]', $post->ID, $message );
148
- $message = str_replace( '[post_author]', $post->post_author, $message );
149
  $message = str_replace( '[post_date]', $post->post_date, $message );
150
  $message = str_replace( '[post_date_gmt]', $post->post_date_gmt, $message );
151
  $message = str_replace( '[post_content]', $post_content, $message );
152
  $message = str_replace( '[post_title]', $post->post_title, $message );
153
- $message = str_replace( '[post_excerpt]', $post->post_excerpt, $message );
154
  $message = str_replace( '[post_status]', $post->post_status, $message );
155
  $message = str_replace( '[comment_status]', $post->comment_status, $message );
156
  $message = str_replace( '[ping_status]', $post->ping_status, $message );
@@ -168,6 +167,7 @@ class BNFW_Engine {
168
  $message = str_replace( '[post_mime_type]', $post->post_mime_type, $message );
169
  $message = str_replace( '[comment_count]', $post->comment_count, $message );
170
  $message = str_replace( '[permalink]', get_permalink( $post->ID ), $message );
 
171
  if ( 'future' == $post->post_status ) {
172
  $message = str_replace( '[post_scheduled_date]', $post->post_date, $message );
173
  $message = str_replace( '[post_scheduled_date_gmt]', $post->post_date_gmt, $message );
@@ -182,6 +182,9 @@ class BNFW_Engine {
182
  $tag_list = implode( ',', wp_get_post_tags( $post_id, array( 'fields' => 'names' ) ) );
183
  $message = str_replace( '[post_tag]', $tag_list, $message );
184
 
 
 
 
185
  return $message;
186
  }
187
 
@@ -242,9 +245,6 @@ class BNFW_Engine {
242
  if ( is_array( $user_info->wp_capabilities ) ) {
243
  $message = str_replace( '[wp_capabilities]', implode( ',', $user_info->wp_capabilities ), $message );
244
  }
245
- $message = str_replace( '[admin_color]', $user_info->admin_color, $message );
246
- $message = str_replace( '[closedpostboxes_page]', $user_info->closedpostboxes_page, $message );
247
- $message = str_replace( '[rich_editing]', $user_info->rich_editing, $message );
248
 
249
  return $message;
250
  }
139
  * @return unknown
140
  */
141
  private function post_shortcodes( $message, $post_id ) {
142
+ $post = get_post( $post_id );
143
 
144
  $post_content = apply_filters( 'the_content', $post->post_content );
145
  $post_content = str_replace( ']]>', ']]&gt;', $post_content );
146
 
147
  $message = str_replace( '[ID]', $post->ID, $message );
 
148
  $message = str_replace( '[post_date]', $post->post_date, $message );
149
  $message = str_replace( '[post_date_gmt]', $post->post_date_gmt, $message );
150
  $message = str_replace( '[post_content]', $post_content, $message );
151
  $message = str_replace( '[post_title]', $post->post_title, $message );
152
+ $message = str_replace( '[post_excerpt]', ( $post->post_excerpt ? $post->post_excerpt : wp_trim_words( $post_content ) ), $message );
153
  $message = str_replace( '[post_status]', $post->post_status, $message );
154
  $message = str_replace( '[comment_status]', $post->comment_status, $message );
155
  $message = str_replace( '[ping_status]', $post->ping_status, $message );
167
  $message = str_replace( '[post_mime_type]', $post->post_mime_type, $message );
168
  $message = str_replace( '[comment_count]', $post->comment_count, $message );
169
  $message = str_replace( '[permalink]', get_permalink( $post->ID ), $message );
170
+
171
  if ( 'future' == $post->post_status ) {
172
  $message = str_replace( '[post_scheduled_date]', $post->post_date, $message );
173
  $message = str_replace( '[post_scheduled_date_gmt]', $post->post_date_gmt, $message );
182
  $tag_list = implode( ',', wp_get_post_tags( $post_id, array( 'fields' => 'names' ) ) );
183
  $message = str_replace( '[post_tag]', $tag_list, $message );
184
 
185
+ $user_info = get_userdata( $post->post_author );
186
+ $message = str_replace( '[post_author]', $user_info->display_name, $message );
187
+
188
  return $message;
189
  }
190
 
245
  if ( is_array( $user_info->wp_capabilities ) ) {
246
  $message = str_replace( '[wp_capabilities]', implode( ',', $user_info->wp_capabilities ), $message );
247
  }
 
 
 
248
 
249
  return $message;
250
  }