Version Description
- Bug fix for notifications not being sent to custom user roles or individual users of custom roles.
- Added a 'Notification Type' column to the notifications screen.
- Renamed 'User Roles' column in notifications screen to 'User Roles/Users'.
Download this release
Release Info
Developer | voltronik |
Plugin | Better Notifications for WordPress |
Version | 1.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.0 to 1.0.1
- README.txt +6 -1
- bnfw.php +2 -2
- includes/admin/class-bnfw-notification.php +56 -1
- includes/engine/class-bnfw-engine.php +27 -9
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
|
6 |
-
Stable tag: 1.0
|
7 |
License: GPLv3
|
8 |
|
9 |
Send customisable HTML emails to your users for different WordPress notifications.
|
@@ -119,6 +119,11 @@ It might do but this is untested.
|
|
119 |
|
120 |
== Changelog ==
|
121 |
|
|
|
|
|
|
|
|
|
|
|
122 |
= 1.0 =
|
123 |
* First major release - we're no longer in beta!
|
124 |
* Total overhaul. The plugin has been completely re-written.
|
3 |
Tags: notifications, email, alerts, roles, users, HTML
|
4 |
Requires at least: 3.5
|
5 |
Tested up to: 4.1
|
6 |
+
Stable tag: 1.0.1
|
7 |
License: GPLv3
|
8 |
|
9 |
Send customisable HTML emails to your users for different WordPress notifications.
|
119 |
|
120 |
== Changelog ==
|
121 |
|
122 |
+
= 1.0.1 =
|
123 |
+
* Bug fix for notifications not being sent to custom user roles or individual users of custom roles.
|
124 |
+
* Added a 'Notification Type' column to the notifications screen.
|
125 |
+
* Renamed 'User Roles' column in notifications screen to 'User Roles/Users'.
|
126 |
+
|
127 |
= 1.0 =
|
128 |
* First major release - we're no longer in beta!
|
129 |
* Total overhaul. The plugin has been completely re-written.
|
bnfw.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/**
|
3 |
Plugin Name: Better Notifications for WordPress
|
4 |
Plugin URI: http://wordpress.org/plugins/bnfw/
|
5 |
-
Description:
|
6 |
-
Version: 1.0
|
7 |
Author: Voltronik
|
8 |
Author URI: http://www.voltronik.co.uk/
|
9 |
Author Email: plugins@voltronik.co.uk
|
2 |
/**
|
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.0.1
|
7 |
Author: Voltronik
|
8 |
Author URI: http://www.voltronik.co.uk/
|
9 |
Author Email: plugins@voltronik.co.uk
|
includes/admin/class-bnfw-notification.php
CHANGED
@@ -523,8 +523,9 @@ class BNFW_Notification {
|
|
523 |
* @filter manage_{post_type}_posts_columns
|
524 |
*/
|
525 |
public function columns_header( $columns ) {
|
|
|
526 |
$columns['subject'] = __( 'Subject', 'bnfw' );
|
527 |
-
$columns['user-roles'] = __( 'User Roles', 'bnfw' );
|
528 |
|
529 |
return $columns;
|
530 |
}
|
@@ -541,6 +542,9 @@ class BNFW_Notification {
|
|
541 |
public function custom_column_row( $column, $post_id ) {
|
542 |
$setting = $this->read_settings( $post_id );
|
543 |
switch ( $column ) {
|
|
|
|
|
|
|
544 |
case 'subject':
|
545 |
echo ! empty( $setting['subject'] ) ? $setting['subject'] : '';
|
546 |
break;
|
@@ -559,6 +563,57 @@ class BNFW_Notification {
|
|
559 |
}
|
560 |
}
|
561 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
562 |
/**
|
563 |
* Custom row actions for this post type.
|
564 |
*
|
523 |
* @filter manage_{post_type}_posts_columns
|
524 |
*/
|
525 |
public function columns_header( $columns ) {
|
526 |
+
$columns['type'] = __( 'Notification Type', 'bnfw' );
|
527 |
$columns['subject'] = __( 'Subject', 'bnfw' );
|
528 |
+
$columns['user-roles'] = __( 'User Roles/Users', 'bnfw' );
|
529 |
|
530 |
return $columns;
|
531 |
}
|
542 |
public function custom_column_row( $column, $post_id ) {
|
543 |
$setting = $this->read_settings( $post_id );
|
544 |
switch ( $column ) {
|
545 |
+
case 'type':
|
546 |
+
echo $this->get_notifications_name( $setting['notification'] );
|
547 |
+
break;
|
548 |
case 'subject':
|
549 |
echo ! empty( $setting['subject'] ) ? $setting['subject'] : '';
|
550 |
break;
|
563 |
}
|
564 |
}
|
565 |
|
566 |
+
/**
|
567 |
+
* Get name of the notification based on slug.
|
568 |
+
*
|
569 |
+
* @param mixed $slug
|
570 |
+
*/
|
571 |
+
private function get_notifications_name( $slug ) {
|
572 |
+
switch ($slug) {
|
573 |
+
case 'new-comment':
|
574 |
+
return __( 'New Comment', 'bnfw' );
|
575 |
+
break;
|
576 |
+
case 'new-trackback':
|
577 |
+
return __( 'New Trackback', 'bnfw' );
|
578 |
+
break;
|
579 |
+
case 'new-pingback':
|
580 |
+
return __( 'New Pingback', 'bnfw' );
|
581 |
+
break;
|
582 |
+
case 'user-password':
|
583 |
+
return __( 'Password Reset', 'bnfw' );
|
584 |
+
break;
|
585 |
+
case 'new-user':
|
586 |
+
return __( 'User Registration', 'bnfw' );
|
587 |
+
break;
|
588 |
+
case 'new-post':
|
589 |
+
return __( 'New Post Published', 'bnfw' );
|
590 |
+
break;
|
591 |
+
case 'update-post':
|
592 |
+
return __( 'Post Updated', 'bnfw' );
|
593 |
+
break;
|
594 |
+
case 'pending-post':
|
595 |
+
return __( 'Post Pending Review', 'bnfw' );
|
596 |
+
break;
|
597 |
+
case 'new-category':
|
598 |
+
return __( 'New Category', 'bnfw' );
|
599 |
+
break;
|
600 |
+
default:
|
601 |
+
$splited = explode( '-', $slug );
|
602 |
+
switch ( $splited[1] ) {
|
603 |
+
case 'new':
|
604 |
+
return __( 'New ', 'bnfw' ) . $splited[1];
|
605 |
+
break;
|
606 |
+
case 'update':
|
607 |
+
return __( 'Updated ', 'bnfw' ) . $splited[1];
|
608 |
+
break;
|
609 |
+
case 'pending':
|
610 |
+
return $splited[1] . __( ' Pending Review', 'bnfw' );
|
611 |
+
break;
|
612 |
+
}
|
613 |
+
break;
|
614 |
+
}
|
615 |
+
}
|
616 |
+
|
617 |
/**
|
618 |
* Custom row actions for this post type.
|
619 |
*
|
includes/engine/class-bnfw-engine.php
CHANGED
@@ -190,15 +190,15 @@ class BNFW_Engine {
|
|
190 |
$emails['to'] = $this->get_emails_from_role( $setting['user-roles'] );
|
191 |
}
|
192 |
|
193 |
-
|
194 |
-
if ( ! empty( $setting['cc-email'] ) ) {
|
195 |
-
|
196 |
-
}
|
197 |
|
198 |
-
|
199 |
-
if ( ! empty( $setting['bcc-email'] ) ) {
|
200 |
-
|
201 |
-
}
|
202 |
|
203 |
return $emails;
|
204 |
}
|
@@ -230,8 +230,9 @@ class BNFW_Engine {
|
|
230 |
|
231 |
$email_list = array();
|
232 |
foreach ( $roles as $role ) {
|
|
|
233 |
$users = get_users( array(
|
234 |
-
'role' => $
|
235 |
'fields' => array( 'user_email' ),
|
236 |
));
|
237 |
|
@@ -243,6 +244,23 @@ class BNFW_Engine {
|
|
243 |
return $email_list;
|
244 |
}
|
245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
/**
|
247 |
* Generate email headers based on the emails.
|
248 |
*
|
190 |
$emails['to'] = $this->get_emails_from_role( $setting['user-roles'] );
|
191 |
}
|
192 |
|
193 |
+
//$emails['cc'] = $this->get_emails_from_role( $setting['cc-roles'] );
|
194 |
+
//if ( ! empty( $setting['cc-email'] ) ) {
|
195 |
+
//$emails['cc'][] = $setting['cc-email'];
|
196 |
+
//}
|
197 |
|
198 |
+
//$emails['bcc'] = $this->get_emails_from_role( $setting['bcc-roles'] );
|
199 |
+
//if ( ! empty( $setting['bcc-email'] ) ) {
|
200 |
+
//$emails['bcc'][] = $setting['bcc-email'];
|
201 |
+
//}
|
202 |
|
203 |
return $emails;
|
204 |
}
|
230 |
|
231 |
$email_list = array();
|
232 |
foreach ( $roles as $role ) {
|
233 |
+
$role_name = $this->get_role_name_by_label( $role );
|
234 |
$users = get_users( array(
|
235 |
+
'role' => $role_name,
|
236 |
'fields' => array( 'user_email' ),
|
237 |
));
|
238 |
|
244 |
return $email_list;
|
245 |
}
|
246 |
|
247 |
+
/**
|
248 |
+
* Get User role name by label.
|
249 |
+
*
|
250 |
+
* @param mixed $role_label
|
251 |
+
*/
|
252 |
+
protected function get_role_name_by_label( $role_label ) {
|
253 |
+
global $wp_roles;
|
254 |
+
foreach ( $wp_roles->roles as $role_name => $role_info ) {
|
255 |
+
if ( $role_label == $role_info['name'] ) {
|
256 |
+
return $role_name;
|
257 |
+
}
|
258 |
+
}
|
259 |
+
|
260 |
+
// There is something wrong
|
261 |
+
return '';
|
262 |
+
}
|
263 |
+
|
264 |
/**
|
265 |
* Generate email headers based on the emails.
|
266 |
*
|