Version Description
- New Shortcode: [permalink].
- New Notifications: 'Scheduled Posts' and 'Scheduled Pages'.
- New Shortcodes for the above Notifications: [post_scheduled_date] and [post_scheduled_date_gmt].
- New Notification: 'New Page Published'.
- New Notification: 'Page 'Updated'.
- New Notification: 'Page Pending Review'.
- New Notification: 'New Page - Comment'.
- Fixed: A few bugs reported via the forums and some others that i've found - thanks everyone!
Download this release
Release Info
Developer | voltronik |
Plugin | Better Notifications for WordPress |
Version | 1.1.5 |
Comparing to | |
See all releases |
Code changes from version 1.1 to 1.1.5
- README.txt +21 -2
- bnfw.php +33 -9
- includes/admin/class-bnfw-notification.php +32 -6
- includes/engine/class-bnfw-engine.php +15 -3
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
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
Send customisable HTML emails to your users for different WordPress notifications.
|
@@ -38,6 +38,15 @@ Notifications that are currently available to use are:
|
|
38 |
* New Post Published
|
39 |
* Post Updated
|
40 |
* Post Pending Review
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
**Posts**
|
43 |
|
@@ -46,7 +55,7 @@ Notifications that are currently available to use are:
|
|
46 |
|
47 |
**Custom Post Types**
|
48 |
|
49 |
-
* New
|
50 |
|
51 |
If you'd like to see a notification in the list above, please drop me a line in the forums and we'll see what we can do to add it.
|
52 |
|
@@ -138,6 +147,16 @@ It might do but this is untested.
|
|
138 |
|
139 |
== Changelog ==
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
= 1.1 =
|
142 |
* Lots of cool new stuff and more to come soon!
|
143 |
* Transactional notifications (notifications intended only for the end user) have been added as a new group in the notifications select box.
|
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
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
Send customisable HTML emails to your users for different WordPress notifications.
|
38 |
* New Post Published
|
39 |
* Post Updated
|
40 |
* Post Pending Review
|
41 |
+
* Post Scheduled
|
42 |
+
|
43 |
+
**Pages**
|
44 |
+
|
45 |
+
* New Page Published
|
46 |
+
* Page Updated
|
47 |
+
* Page Pending Review
|
48 |
+
* Page Scheduled
|
49 |
+
* Page - New Comment
|
50 |
|
51 |
**Posts**
|
52 |
|
55 |
|
56 |
**Custom Post Types**
|
57 |
|
58 |
+
* New Term
|
59 |
|
60 |
If you'd like to see a notification in the list above, please drop me a line in the forums and we'll see what we can do to add it.
|
61 |
|
147 |
|
148 |
== Changelog ==
|
149 |
|
150 |
+
= 1.1.5 =
|
151 |
+
* New Shortcode: [permalink].
|
152 |
+
* New Notifications: 'Scheduled Posts' and 'Scheduled Pages'.
|
153 |
+
* New Shortcodes for the above Notifications: [post_scheduled_date] and [post_scheduled_date_gmt].
|
154 |
+
* New Notification: 'New Page Published'.
|
155 |
+
* New Notification: 'Page 'Updated'.
|
156 |
+
* New Notification: 'Page Pending Review'.
|
157 |
+
* New Notification: 'New Page - Comment'.
|
158 |
+
* Fixed: A few bugs reported via the forums and some others that i've found - thanks everyone!
|
159 |
+
|
160 |
= 1.1 =
|
161 |
* Lots of cool new stuff and more to come soon!
|
162 |
* Transactional notifications (notifications intended only for the end user) have been added as a new group in the notifications select box.
|
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
|
7 |
* Author: Voltronik
|
8 |
* Author URI: http://www.voltronik.co.uk/
|
9 |
* Author Email: plugins@voltronik.co.uk
|
@@ -96,9 +96,13 @@ class BNFW {
|
|
96 |
add_action( 'draft_to_publish' , array( $this, 'publish_post' ) );
|
97 |
add_action( 'publish_to_publish' , array( $this, 'update_post' ) );
|
98 |
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
102 |
|
103 |
add_action( 'comment_post' , array( $this, 'comment_post' ) );
|
104 |
add_action( 'trackback_post' , array( $this, 'trackback_post' ) );
|
@@ -194,10 +198,10 @@ class BNFW {
|
|
194 |
* Fires when a post is pending for review.
|
195 |
*
|
196 |
* @since 1.1
|
197 |
-
* @param
|
|
|
198 |
*/
|
199 |
-
function
|
200 |
-
$post_id = $post->ID;
|
201 |
$post_type = $post->post_type;
|
202 |
|
203 |
if ( BNFW_Notification::POST_TYPE != $post_type ) {
|
@@ -205,16 +209,36 @@ class BNFW {
|
|
205 |
}
|
206 |
}
|
207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
/**
|
209 |
* Send notification for new comments
|
210 |
*
|
211 |
* @since 1.0
|
212 |
-
* @param
|
213 |
*/
|
214 |
function comment_post( $comment_id ) {
|
215 |
$the_comment = get_comment( $comment_id );
|
216 |
if ( $this->can_send_comment_notification( $the_comment ) ) {
|
217 |
-
$
|
|
|
|
|
|
|
|
|
|
|
218 |
}
|
219 |
}
|
220 |
|
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
|
7 |
* Author: Voltronik
|
8 |
* Author URI: http://www.voltronik.co.uk/
|
9 |
* Author Email: plugins@voltronik.co.uk
|
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( '_builtin' => 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' ) );
|
198 |
* Fires when a post is pending for review.
|
199 |
*
|
200 |
* @since 1.1
|
201 |
+
* @param int $post_id Post ID
|
202 |
+
* @param object $post Post object
|
203 |
*/
|
204 |
+
function on_post_pending( $post_id, $post ) {
|
|
|
205 |
$post_type = $post->post_type;
|
206 |
|
207 |
if ( BNFW_Notification::POST_TYPE != $post_type ) {
|
209 |
}
|
210 |
}
|
211 |
|
212 |
+
/**
|
213 |
+
* Fires when a post is scheduled.
|
214 |
+
*
|
215 |
+
* @since 1.1.5
|
216 |
+
* @param int $post_id Post ID
|
217 |
+
* @param object $post Post object
|
218 |
+
*/
|
219 |
+
function on_post_scheduled( $post_id, $post ) {
|
220 |
+
$post_type = $post->post_type;
|
221 |
+
|
222 |
+
if ( BNFW_Notification::POST_TYPE != $post_type ) {
|
223 |
+
$this->send_notification( 'future-' . $post_type, $post_id );
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
/**
|
228 |
* Send notification for new comments
|
229 |
*
|
230 |
* @since 1.0
|
231 |
+
* @param int $comment_id
|
232 |
*/
|
233 |
function comment_post( $comment_id ) {
|
234 |
$the_comment = get_comment( $comment_id );
|
235 |
if ( $this->can_send_comment_notification( $the_comment ) ) {
|
236 |
+
$post = get_post( $the_comment->comment_post_ID );
|
237 |
+
$notification_type = 'new-comment'; // old notification name
|
238 |
+
if ( 'post' != $post->post_type ) {
|
239 |
+
$notification_type = 'comment-' . $post->post_type;
|
240 |
+
}
|
241 |
+
$this->send_notification( $notification_type, $comment_id );
|
242 |
}
|
243 |
}
|
244 |
|
includes/admin/class-bnfw-notification.php
CHANGED
@@ -171,9 +171,17 @@ class BNFW_Notification {
|
|
171 |
<option value="new-post" <?php selected( 'new-post', $setting['notification'] );?>><?php _e( 'New Post Published', 'bnfw' );?></option>
|
172 |
<option value="update-post" <?php selected( 'update-post', $setting['notification'] );?>><?php _e( 'Post Updated', 'bnfw' );?></option>
|
173 |
<option value="pending-post" <?php selected( 'pending-post', $setting['notification'] );?>><?php _e( 'Post Pending Review', 'bnfw' );?></option>
|
|
|
174 |
<option value="new-category" <?php selected( 'new-category', $setting['notification'] );?>><?php _e( 'New Category', 'bnfw' ); ?></option>
|
175 |
<option value="new-post_tag" <?php selected( 'new-post_tag', $setting['notification'] );?>><?php _e( 'New Tag', 'bnfw' ); ?></option>
|
176 |
</optgroup>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
<?php
|
178 |
$types = get_post_types( array(
|
179 |
'_builtin' => false,
|
@@ -189,6 +197,8 @@ class BNFW_Notification {
|
|
189 |
<option value="new-<?php echo $type; ?>" <?php selected( 'new-' . $type, $setting['notification'] );?>><?php echo __( 'New ', 'bnfw' ), "'$label'"; ?></option>
|
190 |
<option value="update-<?php echo $type; ?>" <?php selected( 'update-' . $type, $setting['notification'] );?>><?php echo "'$label' " . __( 'Update ', 'bnfw' ); ?></option>
|
191 |
<option value="pending-<?php echo $type; ?>" <?php selected( 'pending-' . $type, $setting['notification'] );?>><?php echo "'$label' ", __( 'Pending Review', 'bnfw' ); ?></option>
|
|
|
|
|
192 |
</optgroup>
|
193 |
<?php
|
194 |
}
|
@@ -370,7 +380,7 @@ class BNFW_Notification {
|
|
370 |
'notification' => $_POST['notification'],
|
371 |
'subject' => sanitize_text_field( $_POST['subject'] ),
|
372 |
'message' => $_POST['message'],
|
373 |
-
'disabled' => sanitize_text_field( $_POST['disabled'] ),
|
374 |
//'show-fields' => sanitize_text_field( $_POST['show-fields'] ),
|
375 |
);
|
376 |
|
@@ -656,6 +666,9 @@ class BNFW_Notification {
|
|
656 |
case 'pending-post':
|
657 |
return __( 'Post Pending Review', 'bnfw' );
|
658 |
break;
|
|
|
|
|
|
|
659 |
case 'new-category':
|
660 |
return __( 'New Category', 'bnfw' );
|
661 |
break;
|
@@ -664,16 +677,29 @@ class BNFW_Notification {
|
|
664 |
break;
|
665 |
default:
|
666 |
$splited = explode( '-', $slug );
|
667 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
668 |
case 'new':
|
669 |
-
return __( 'New ', 'bnfw' ) . $
|
670 |
break;
|
671 |
case 'update':
|
672 |
-
return __( 'Updated ', 'bnfw' ) . $
|
673 |
break;
|
674 |
case 'pending':
|
675 |
-
return $
|
676 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
677 |
}
|
678 |
break;
|
679 |
}
|
171 |
<option value="new-post" <?php selected( 'new-post', $setting['notification'] );?>><?php _e( 'New Post Published', 'bnfw' );?></option>
|
172 |
<option value="update-post" <?php selected( 'update-post', $setting['notification'] );?>><?php _e( 'Post Updated', 'bnfw' );?></option>
|
173 |
<option value="pending-post" <?php selected( 'pending-post', $setting['notification'] );?>><?php _e( 'Post Pending Review', 'bnfw' );?></option>
|
174 |
+
<option value="future-post" <?php selected( 'future-post', $setting['notification'] );?>><?php _e( 'Post Scheduled', 'bnfw' );?></option>
|
175 |
<option value="new-category" <?php selected( 'new-category', $setting['notification'] );?>><?php _e( 'New Category', 'bnfw' ); ?></option>
|
176 |
<option value="new-post_tag" <?php selected( 'new-post_tag', $setting['notification'] );?>><?php _e( 'New Tag', 'bnfw' ); ?></option>
|
177 |
</optgroup>
|
178 |
+
<optgroup label="Page">
|
179 |
+
<option value="new-page" <?php selected( 'new-page', $setting['notification'] );?>><?php _e( 'New Page Published', 'bnfw' );?></option>
|
180 |
+
<option value="update-page" <?php selected( 'update-page', $setting['notification'] );?>><?php _e( 'Page Updated', 'bnfw' );?></option>
|
181 |
+
<option value="pending-page" <?php selected( 'pending-page', $setting['notification'] );?>><?php _e( 'Page Pending Review', 'bnfw' );?></option>
|
182 |
+
<option value="future-page" <?php selected( 'future-page', $setting['notification'] );?>><?php _e( 'Page Scheduled', 'bnfw' );?></option>
|
183 |
+
<option value="comment-page" <?php selected( 'comment-page', $setting['notification'] );?>><?php _e( 'Page - New Comment', 'bnfw' );?></option>
|
184 |
+
</optgroup>
|
185 |
<?php
|
186 |
$types = get_post_types( array(
|
187 |
'_builtin' => false,
|
197 |
<option value="new-<?php echo $type; ?>" <?php selected( 'new-' . $type, $setting['notification'] );?>><?php echo __( 'New ', 'bnfw' ), "'$label'"; ?></option>
|
198 |
<option value="update-<?php echo $type; ?>" <?php selected( 'update-' . $type, $setting['notification'] );?>><?php echo "'$label' " . __( 'Update ', 'bnfw' ); ?></option>
|
199 |
<option value="pending-<?php echo $type; ?>" <?php selected( 'pending-' . $type, $setting['notification'] );?>><?php echo "'$label' ", __( 'Pending Review', 'bnfw' ); ?></option>
|
200 |
+
<option value="future-<?php echo $type; ?>" <?php selected( 'future-' . $type, $setting['notification'] );?>><?php echo "'$label' ", __( 'Scheduled', 'bnfw' ); ?></option>
|
201 |
+
<option value="comment-<?php echo $type; ?>" <?php selected( 'comment-' . $type, $setting['notification'] );?>><?php echo "'$label' ", __( 'New Comment', 'bnfw' ); ?></option>
|
202 |
</optgroup>
|
203 |
<?php
|
204 |
}
|
380 |
'notification' => $_POST['notification'],
|
381 |
'subject' => sanitize_text_field( $_POST['subject'] ),
|
382 |
'message' => $_POST['message'],
|
383 |
+
'disabled' => isset( $_POST['disabled'] ) ? sanitize_text_field( $_POST['disabled'] ) : 'false',
|
384 |
//'show-fields' => sanitize_text_field( $_POST['show-fields'] ),
|
385 |
);
|
386 |
|
666 |
case 'pending-post':
|
667 |
return __( 'Post Pending Review', 'bnfw' );
|
668 |
break;
|
669 |
+
case 'future-post':
|
670 |
+
return __( 'Post Scheduled', 'bnfw' );
|
671 |
+
break;
|
672 |
case 'new-category':
|
673 |
return __( 'New Category', 'bnfw' );
|
674 |
break;
|
677 |
break;
|
678 |
default:
|
679 |
$splited = explode( '-', $slug );
|
680 |
+
$label = $splited[1];
|
681 |
+
$post_obj = get_post_type_object( $splited[1] );
|
682 |
+
|
683 |
+
if ( null != $post_obj ) {
|
684 |
+
$label = $post_obj->labels->singular_name;
|
685 |
+
}
|
686 |
+
|
687 |
+
switch ( $splited[0] ) {
|
688 |
case 'new':
|
689 |
+
return __( 'New ', 'bnfw' ) . $label;
|
690 |
break;
|
691 |
case 'update':
|
692 |
+
return __( 'Updated ', 'bnfw' ) . $label;
|
693 |
break;
|
694 |
case 'pending':
|
695 |
+
return $label . __( ' Pending Review', 'bnfw' );
|
696 |
+
break;
|
697 |
+
case 'future':
|
698 |
+
return $label . __( ' Scheduled', 'bnfw' );
|
699 |
+
break;
|
700 |
+
case 'comment':
|
701 |
+
return $label . __( ' Comment', 'bnfw' );
|
702 |
+
break;
|
703 |
}
|
704 |
break;
|
705 |
}
|
includes/engine/class-bnfw-engine.php
CHANGED
@@ -109,17 +109,20 @@ class BNFW_Engine {
|
|
109 |
// handle new terms
|
110 |
$message = $this->taxonomy_shortcodes( $message, $type[1], $id );
|
111 |
|
112 |
-
} else if ( 'new' == $type[0] || 'update' == $type[0] ) {
|
113 |
// handle new, update and pending posts
|
114 |
-
$post_types = get_post_types( array( '_builtin' =>
|
115 |
$post_types = array_diff( $post_types, array( BNFW_Notification::POST_TYPE ) );
|
116 |
-
array_push( $post_types, 'post' );
|
117 |
|
118 |
if ( in_array( $type[1], $post_types ) ) {
|
119 |
$message = $this->post_shortcodes( $message, $id );
|
120 |
$post = get_post( $id );
|
121 |
$message = $this->user_shortcodes( $message, $post->post_author );
|
122 |
}
|
|
|
|
|
|
|
|
|
123 |
}
|
124 |
break;
|
125 |
}
|
@@ -164,6 +167,14 @@ class BNFW_Engine {
|
|
164 |
$message = str_replace( '[post_type]', $post->post_type, $message );
|
165 |
$message = str_replace( '[post_mime_type]', $post->post_mime_type, $message );
|
166 |
$message = str_replace( '[comment_count]', $post->comment_count, $message );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
$category_list = implode( ',', wp_get_post_categories( $post_id, array( 'fields' => 'names' ) ) );
|
169 |
$message = str_replace( '[post_category]', $category_list, $message );
|
@@ -200,6 +211,7 @@ class BNFW_Engine {
|
|
200 |
$message = str_replace( '[comment_type]', $comment->comment_type, $message );
|
201 |
$message = str_replace( '[comment_parent]', $comment->comment_parent, $message );
|
202 |
$message = str_replace( '[user_id]', $comment->user_id, $message );
|
|
|
203 |
|
204 |
return $message;
|
205 |
}
|
109 |
// handle new terms
|
110 |
$message = $this->taxonomy_shortcodes( $message, $type[1], $id );
|
111 |
|
112 |
+
} else if ( 'new' == $type[0] || 'update' == $type[0] || 'pending' == $type[0] || 'future' == $type[0] ) {
|
113 |
// handle new, update and pending posts
|
114 |
+
$post_types = get_post_types( array( '_builtin' => true ), 'names' );
|
115 |
$post_types = array_diff( $post_types, array( BNFW_Notification::POST_TYPE ) );
|
|
|
116 |
|
117 |
if ( in_array( $type[1], $post_types ) ) {
|
118 |
$message = $this->post_shortcodes( $message, $id );
|
119 |
$post = get_post( $id );
|
120 |
$message = $this->user_shortcodes( $message, $post->post_author );
|
121 |
}
|
122 |
+
} else if ( 'comment' == $type[0] ) {
|
123 |
+
$message = $this->comment_shortcodes( $message, $id );
|
124 |
+
$comment = get_comment( $id );
|
125 |
+
$message = $this->post_shortcodes( $message, $comment->comment_post_ID );
|
126 |
}
|
127 |
break;
|
128 |
}
|
167 |
$message = str_replace( '[post_type]', $post->post_type, $message );
|
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 );
|
174 |
+
} else {
|
175 |
+
$message = str_replace( '[post_scheduled_date]', 'Published', $message );
|
176 |
+
$message = str_replace( '[post_scheduled_date_gmt]', 'Published', $message );
|
177 |
+
}
|
178 |
|
179 |
$category_list = implode( ',', wp_get_post_categories( $post_id, array( 'fields' => 'names' ) ) );
|
180 |
$message = str_replace( '[post_category]', $category_list, $message );
|
211 |
$message = str_replace( '[comment_type]', $comment->comment_type, $message );
|
212 |
$message = str_replace( '[comment_parent]', $comment->comment_parent, $message );
|
213 |
$message = str_replace( '[user_id]', $comment->user_id, $message );
|
214 |
+
$message = str_replace( '[permalink]', get_comment_link( $comment->comment_ID ), $message );
|
215 |
|
216 |
return $message;
|
217 |
}
|