Better Notifications for WordPress - Version 1.0

Version Description

  • First major release - we're no longer in beta!
  • Total overhaul. The plugin has been completely re-written.
  • Auto-importer: Your old notifications will be imported when updating the plugin.
  • New 'Generator' for easily creating and editing your notifications.
  • More options and notification types as per feedback via the forums - thanks everyone!
  • Granular control over choosing either user roles or individual users you'd like to send a notification to.
  • Fully translatable.
  • Loads of bugfixes and improvements.
Download this release

Release Info

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

Code changes from version 0.1b to 1.0

README.txt CHANGED
@@ -1,39 +1,46 @@
1
- === Better Notifications for WordPress (beta) ===
2
- Contributors: voltronik, peterrocker
3
- Tags: notifications, email, roles, custom
4
  Requires at least: 3.5
5
- Tested up to: 3.5
6
- Stable tag: 0.1b
7
  License: GPLv3
8
 
9
- Send customisable HTML emails to user roles for different WordPress notifications.
10
 
11
  == Description ==
12
 
13
- Better Notifications for WordPress (beta) allows you to choose which WordPress email notifications are sent to which user roles (including custom roles) and allows you to customise the notifications using simple HTML and shortcodes. Emails are sent using wp_mail() but can be sent using SMTP using an appropriate 3rd party plugin (we recommend WP-Mail-SMTP).
14
 
15
- For example:
16
- You want Editors to be alerted via email when a new post is published and you'd like to customise it to include your branding along with the author's display name and post time - with this plugin, that's easy.
17
 
18
- Notifications that you can use are:
 
 
 
19
 
20
  * New category
21
- * New post published / post updated
 
22
  * New comment (and it's corresponding status)
23
- * New user registration
24
  * New trackback
25
  * New pingback
26
- * Lost password reset
 
 
 
 
27
 
28
- If you'd like to see a notification in the list above, please drop us a line in the forums and we'll see what we can do to add it.
29
 
30
- A long and handy list of shortcodes you can use is available [here](http://www.voltronik.co.uk/wordpress-plugins/better-notifications-for-wordpress/ "Shortcodes for use in Better Notifications for WordPress")
31
 
 
32
 
33
- Having problems? Please let us know via this plugin's forum so we can address them and let it act as a source of information for future reference and other users.
 
34
 
35
- Like this plugin? Please leave us a great review!
36
- Don't think the plugin is worthy of 5 stars? Let us know on the forum or drop us a line at plugins [at] voltronik.co.uk and we'll try and help.
37
 
38
 
39
 
@@ -41,60 +48,103 @@ Don't think the plugin is worthy of 5 stars? Let us know on the forum or drop us
41
 
42
  1. Upload the 'bnfw' plugin folder to the '/wp-content/plugins/' directory or download it via your WordPress installation.
43
  2. Activate the plugin through the 'Plugins' menu in WordPress
44
- 3. Use the new 'Notifications' Menu item in the sidebar to configure the plugin.
45
  4. (Optional) Install a plugin to use SMTP instead of wp_mail(). We recommend WP-Mail-SMTP.
46
- 5. Test by creating an update for the defined notification (e.g. create a new post if the new posts notification has been set-up).
47
- 6. Depending on you requirements, you may need to switch on or off some of the default WordPress settings. Please see the FAQ section for more information.
48
 
49
 
50
 
51
  == Frequently Asked Questions ==
52
 
 
 
 
 
 
 
 
 
53
  = What are some scenarios this plugin could be used for? =
54
 
55
- * Outreach: A blog/news site with 300,000 subscribers and want to use it to alert them of new blog posts.
56
- * Communication: A small, internal WordPress site and use to to alert staff of new comments.
57
- * Monitor: A website for a groundbreaking new product and use it for new trackbacks or pingbacks notifications.
58
  * Security: To receive alerts of password reset requests and their corresponding email address.
59
 
60
  The possibilities are endless!
61
 
 
 
 
 
62
  = What isn't this plugin? =
63
 
64
- It's not designed to send out newsletters. There is no send-this-out-on-this-date style functionality. There are many other great plugins available that you could use for that instead.
65
 
66
  = How do I set-up WordPress to work with this plugin correctly? =
67
 
68
- This will very much depend on what notifications you're using the plugin for. Out-of-the-box, this plugin works very well but there are a few tweaks that you will need to ensure 100% compatibility. All the below points refer to our plugin:
69
 
70
  * If you want to use the new comment notifications in BNFW, you need to switch off 'Email me whenever anyone posts a comment' and 'A comment is held for moderation' under Settings > Discussion. It's ok if you don't do this but you might receive WordPress's own email notifications along with the ones you configure using BNFW too. It also goes without saying that you need to enable comments for your posts if you want the email notifications to come through.
71
 
72
- * If you want to use the trackback / pingback BNFW notification, then you need to switch on 'Attempt to notify any blogs linked to from the article' and 'Allow link notifications from other blogs (pingbacks and trackbacks)' under Settings > Discussion.
 
 
73
 
74
- = Configured Emails aren't coming through! =
75
 
76
- Check your settings to make sure all is as it should be, then check your spam folder. Gmail and certain hosts can mark messages from new websites (or IP addresses) as spam so it's worth checking and possibly creating a filter to ensure this doesn't happen in the future.
77
 
78
- = The email previews aren't showing the contents of the shortcodes! =
79
 
80
- This is by design. In order to show the contents, the plugin would have to retrieve information for a specific notification and it's hard to tell which one you'd like to use or if there's any information in the database. The previews will show your HTML rendering, however.
81
 
82
- = Some of my shortcodes aren't working! =
 
 
 
 
83
 
84
- It's possible you're inserting a shortcode into an email for a notification that cannot use it. WordPress imposes certain limitations on information outputted for particular notifications. For example: the 'New Category' email notification cannot use any of the author or time shortcodes as WordPress only stores (and subsequently returns) the category name, category slug and category description. It's also worth checking the spelling and hyphens in any shortcodes as well as if they are wrapped in square brackets '[]'.
85
-
86
 
87
 
88
  == Screenshots ==
89
 
90
- 1. The notifications and roles settings. Set which roles you'd like to receive emails for notifications from here.
91
- 2. The email templates screen. Customise your emails using HTML and shortcodes here.
 
 
 
92
 
93
 
94
 
95
  == Changelog ==
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  = 0.1 beta =
98
  * Initial version of the plugin.
99
  * Settings page for configuring notification types for roles.
100
- * Email Templates page for customising emails using HTML and shortcodes.
 
 
 
 
 
 
 
 
 
1
+ === Better Notifications for WordPress ===
2
+ 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.
10
 
11
  == Description ==
12
 
13
+ > Recently updated to be even easier to use!
14
 
15
+ Better Notifications for WordPress allows you to generate custom HTML email notifications and send them to user roles (including custom roles) or individual users for all kinds of things happening on your WordPress website. Emails are sent out via your WordPress website (using `wp_mail`) but can be sent via SMTP using an appropriate 3rd party plugin should you wish.
 
16
 
17
+ = For example: =
18
+ You want a user with the editor role (or all users using the Editor role) to be alerted via email when a new post is published and you'd like to customise it to include your branding along with the author's display name and post time - with this plugin, that's easy.
19
+
20
+ Notifications that are currently available to use are:
21
 
22
  * New category
23
+ * New Post
24
+ * Post updated
25
  * New comment (and it's corresponding status)
 
26
  * New trackback
27
  * New pingback
28
+ * New user registration (admin)
29
+ * Lost password reset (admin)
30
+ * New custom taxonomy
31
+
32
+ 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.
33
 
34
+ A long and handy list of shortcodes you can use is available [here](http://www.voltronik.co.uk/wordpress-plugins/better-notifications-for-wordpress/ "Shortcodes for use in Better Notifications for WordPress").
35
 
 
36
 
37
+ Having problems? Please let me know via this plugin's forum so we can address them and let it act as a source of information for future reference and other users.
38
 
39
+ Like this plugin? Please leave it a great review!
40
+ Don't think the plugin is worthy of 5 stars? Let me know on the forum and we'll do our best to help.
41
 
42
+ > Want to add categories and sub-categories via the WordPress front-end?
43
+ > Try my [Front-end Categories](https://wordpress.org/plugins/front-end-categories/ "Front-end Categories WordPress Plugin") plugin.
44
 
45
 
46
 
48
 
49
  1. Upload the 'bnfw' plugin folder to the '/wp-content/plugins/' directory or download it via your WordPress installation.
50
  2. Activate the plugin through the 'Plugins' menu in WordPress
51
+ 3. Use the settings in the new 'Notifications' Menu item in the sidebar to configure the plugin.
52
  4. (Optional) Install a plugin to use SMTP instead of wp_mail(). We recommend WP-Mail-SMTP.
53
+ 5. Test by creating a notification.
 
54
 
55
 
56
 
57
  == Frequently Asked Questions ==
58
 
59
+ = What are shortcodes? Where can I use them in this plugin? =
60
+
61
+ Shortcodes are little blocks of content inserted by WordPress, contained in square brackets. For example, if you want to add the content of a post to a notification for 'New Post Published', you can use the `[post_content]` shortcode to display this in the email that is sent out.
62
+
63
+ Shortcodes can be used in the 'Subject' and 'Message Body' of your notifications.
64
+
65
+ A long and handy list of shortcodes you can use is available [here](http://www.voltronik.co.uk/wordpress-plugins/better-notifications-for-wordpress/ "Shortcodes for use in Better Notifications for WordPress").
66
+
67
  = What are some scenarios this plugin could be used for? =
68
 
69
+ * Outreach: A blog/news site with hundreds of subscribers and want to use it to alert them of new blog posts.
70
+ * Communication: A small, internal WordPress site and use it to alert staff of new comments.
71
+ * Monitor: A website for an awesome new product or service and use it for notifications of pingbacks and trackbacks.
72
  * Security: To receive alerts of password reset requests and their corresponding email address.
73
 
74
  The possibilities are endless!
75
 
76
+ = Does this plugin work with Akismet? =
77
+
78
+ Yes! There is an option for suppressing comments marked as SPAM by Akismet in the plugin settings.
79
+
80
  = What isn't this plugin? =
81
 
82
+ It's not designed to send out newsletters. There is no send-this-out-on-this-date style functionality included. There are many other great plugins available that you could use for that instead.
83
 
84
  = How do I set-up WordPress to work with this plugin correctly? =
85
 
86
+ This will very much depend on what notifications you're using the plugin for. Out-of-the-box, this plugin works very well but there are a few tweaks that you will need to ensure 100% compatibility. All the below points refer to this plugin:
87
 
88
  * If you want to use the new comment notifications in BNFW, you need to switch off 'Email me whenever anyone posts a comment' and 'A comment is held for moderation' under Settings > Discussion. It's ok if you don't do this but you might receive WordPress's own email notifications along with the ones you configure using BNFW too. It also goes without saying that you need to enable comments for your posts if you want the email notifications to come through.
89
 
90
+ = Configured emails aren't coming through! =
91
+
92
+ Check your settings to make sure all is as it should be, then check your spam folder and/or filter at your host. Gmail and certain hosts can mark messages from new websites (or IP addresses) as spam so it's worth checking and possibly creating a filter to ensure this doesn't happen in the future.
93
 
94
+ Many hosts place a limit on the number of emails that can be sent out within an hour so this may also cause some delay in emails arriving.
95
 
96
+ = Some of my shortcodes aren't working! =
97
 
98
+ It's possible you're inserting a shortcode into a notification that cannot use it. For example: the 'New Category' email notification cannot use any of the author or time shortcodes as WordPress only stores the category name, category slug and category description in the database. It's also worth checking the spelling and hyphens in any shortcodes as well as if they are wrapped in square brackets '[]'.
99
 
100
+ = Can I translate this plugin? =
101
 
102
+ Yes, of course! The plugin is completely translation-friendly and if you send me your .po file, i'll make sure to include it in the plugin and credit you on this page.
103
+
104
+ = Will this plugin work with versions WordPress less than 3.5? =
105
+
106
+ It might do but this is untested.
107
 
 
 
108
 
109
 
110
  == Screenshots ==
111
 
112
+ 1. All Notifications
113
+
114
+ 2. Add New Notification
115
+
116
+ 3. Plugin Settings
117
 
118
 
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.
125
+ * Auto-importer: Your old notifications will be imported when updating the plugin.
126
+ * New 'Generator' for easily creating and editing your notifications.
127
+ * More options and notification types as per feedback via the forums - thanks everyone!
128
+ * Granular control over choosing either user roles or individual users you'd like to send a notification to.
129
+ * Fully translatable.
130
+ * Loads of bugfixes and improvements.
131
+
132
+ = 0.2.1 beta =
133
+ * Minor Bugfixes
134
+
135
+ = 0.2 beta =
136
+ * Added an option to suppress spam comment notifications.
137
+
138
  = 0.1 beta =
139
  * Initial version of the plugin.
140
  * Settings page for configuring notification types for roles.
141
+ * Email Templates page for customising emails using HTML and shortcodes.
142
+
143
+
144
+
145
+ == Upgrade Notice ==
146
+
147
+ = Migrating from 0.2.1 to 1.0 =
148
+
149
+ Version 1 features an auto-importer which should migrate all of your notifications from any previous versions of the plugin to 1.0.
150
+ Please ensure that you check, double check and test your notifications before and after upgrading.
assets/images/select2-spinner.gif ADDED
Binary file
assets/images/select2.png ADDED
Binary file
assets/images/select2@2x.png ADDED
Binary file
assets/js/bnfw.js ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+ $(".select2").select2();
3
+
4
+ $("#bnfw_user_role_toggle, #bnfw_user_toggle").click(function() {
5
+ $("#bnfw_user_role_container").toggle();
6
+ $("#bnfw_user_container").toggle();
7
+ });
8
+ });
better-wordpress-notifications.php DELETED
@@ -1,218 +0,0 @@
1
- <?php
2
- /*
3
- Plugin Name: Better Notifications for WordPress
4
- Plugin URI: http://www.voltronik.co.uk/wordpress-plugins/better-notifications-for-wordpress/
5
- Description: Send customisable HTML emails to user roles for different WordPress notifications.
6
- Version: 0.1 Beta
7
- Author: Voltronik
8
- Author URI: http://www.voltronik.co.uk/
9
- Author Email: hello@voltronik.co.uk
10
- License: GPLv2 or later
11
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
-
13
- Copyright 2013 Voltronik Web Design (hello@voltronik.co.uk)
14
-
15
- This program is free software; you can redistribute it and/or modify
16
- it under the terms of the GNU General Public License, version 2, as
17
- published by the Free Software Foundation.
18
-
19
- This program is distributed in the hope that it will be useful,
20
- but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
- GNU General Public License for more details.
23
-
24
- You should have received a copy of the GNU General Public License
25
- along with this program; if not, write to the Free Software
26
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
-
28
- */
29
-
30
- /*
31
- hooks which we support
32
- */
33
- $GLOBALS['BNFW_ACTION_TYPES'] = array("create_term", "publish_post", "comment_post", "user_register", "trackback_post", "pingback_post", "lostpassword_post");
34
-
35
- /*
36
- pretty names for the hooks
37
- */
38
- $GLOBALS['BNFW_ACTION_TYPES_PRETTY'] = array("create_term" => "New Category",
39
- "publish_post" => "Publish / Update Post",
40
- "comment_post" => "New Comment / Awaiting Moderation",
41
- "user_register" => "New User Registration",
42
- "trackback_post" => "New Trackback",
43
- "pingback_post" => "New Pingback",
44
- "lostpassword_post" => "Lost password reset");
45
-
46
-
47
- // Load Engine
48
- require_once ('includes/bnfw_engine.php');
49
-
50
- // Load Settings page
51
- if(is_admin()){
52
- require_once ('includes/admin-page.php');
53
- }
54
-
55
- //add_filter('the_content', 'bnfw_debug');
56
-
57
- add_action('create_term', 'bnfw_term_created');
58
- add_action('publish_post', 'bnfw_publish_post');
59
- add_action('comment_post', 'bnfw_comment_post');
60
- add_action('user_register', 'bnfw_user_register');
61
- add_action('trackback_post', 'bnfw_trackback_post');
62
- add_action('pingback_post', 'bnfw_pingback_post');
63
- add_action('lostpassword_post', 'bnfw_lostpassword_post');
64
-
65
- add_filter('wp_mail', 'bnfw_disable_emails');
66
-
67
- register_activation_hook( __FILE__, 'bnfw_activate' );
68
-
69
-
70
- function bnfw_disable_emails($result = '') {
71
- extract($result);
72
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
73
- if (strstr(sprintf(__('[%s] New User Registration'), $blogname), $subject)) {
74
- $to = '';
75
- $subject = '';
76
- $message = '';
77
- $headers = '';
78
- $attachments = array ();
79
- return compact('to', 'subject', 'message', 'headers', 'attachments');
80
- }
81
- else if (strstr(sprintf(__('[%s] Password Lost/Changed'), $blogname), $subject)) {
82
- $to = '';
83
- $subject = '';
84
- $message = '';
85
- $headers = '';
86
- $attachments = array ();
87
- return compact('to', 'subject', 'message', 'headers', 'attachments');
88
- }
89
- else if (strstr(sprintf(__('[%s] Comment:'), $blogname), $subject)) {
90
- $to = '';
91
- $subject = '';
92
- $message = '';
93
- $headers = '';
94
- $attachments = array ();
95
- return compact('to', 'subject', 'message', 'headers', 'attachments');
96
- }
97
- else if (strstr(sprintf(__('[%s] Please moderate:'), $blogname), $subject)) {
98
- $to = '';
99
- $subject = '';
100
- $message = '';
101
- $headers = '';
102
- $attachments = array ();
103
- return compact('to', 'subject', 'message', 'headers', 'attachments');
104
- }
105
-
106
-
107
- return $result;
108
- }
109
-
110
- function bnfw_activate(){
111
-
112
- //set default values
113
- $bnfw_options = get_option('bnfw_settings');
114
- if($bnfw_options === false){
115
-
116
- $bnfw_options = array('create_term-administrator' => '1',
117
- 'publish_post-administrator' => '1',
118
- 'comment_post-administrator' => '1',
119
- 'user_register-administrator' => '1',
120
- 'trackback_post-administrator' => '1',
121
- 'pingback_post-administrator' => '1',
122
- 'lostpassword_post-administrator' => '1'
123
- );
124
-
125
- update_option('bnfw_settings', $bnfw_options);
126
- }
127
-
128
- $bnfw_options = get_option('bnfw_custom_email_settings');
129
- if($bnfw_options === false){
130
-
131
- $bnfw_options = array('payload-subject-publish_post' => 'A new post has been published!',
132
- 'payload-subject-create_term' => 'New category created',
133
- 'payload-subject-comment_post' => 'This is a comment notification email',
134
- 'payload-subject-user_register' => 'A new user has registered!',
135
- 'payload-subject-trackback_post' => 'You have a new trackback!',
136
- 'payload-subject-pingback_post' => 'You have a new pingback!',
137
- 'payload-subject-lostpassword_post' => '[user_login] has lost their password!',
138
- 'payload-body-publish_post' => 'A post was published by <strong>[display_name]</strong> on <strong>[post_date]</strong>
139
-
140
- <p>Here\'s an excerpt: <br /></p>
141
- <em>[post_excerpt]</em>',
142
- 'payload-body-create_term' => 'A new category has been created called: <strong>[name]</strong>',
143
- 'payload-body-comment_post' => 'A new comment was posted by <strong>[comment_author_email]</strong>.
144
- <p>It\'s status has been set to: <strong>[comment_approved]</strong>.</p>',
145
- 'payload-body-user_register' => 'Say hello to <strong>[user_login]</strong>!',
146
- 'payload-body-trackback_post' => 'From: <strong>[comment_author_url]</strong>',
147
- 'payload-body-pingback_post' => 'From: <strong>[comment_author_url]</strong>',
148
- 'payload-body-lostpassword_post' => '<strong>[user_login]</strong> has lost their password.
149
-
150
- <p>An email has been sent to them so they can reset their password.</p>'
151
- );
152
-
153
- update_option('bnfw_custom_email_settings', $bnfw_options);
154
-
155
- }
156
-
157
- }
158
-
159
-
160
- function bnfw_term_created($termID){
161
-
162
- $the_term = get_term_by('id', $termID, 'category');
163
- bnfw_launch_payload(bnfw_get_recipients_for_type('create_term'), bnfw_get_subject_for_term_created($the_term), bnfw_get_payload_for_term_created($the_term));
164
-
165
- }
166
-
167
- function bnfw_publish_post($postID){
168
-
169
- $the_post = get_post($postID);
170
- bnfw_launch_payload(bnfw_get_recipients_for_type('publish_post'), bnfw_get_subject_for_publish_post($the_post), bnfw_get_payload_for_publish_post($the_post));
171
-
172
- }
173
-
174
- function bnfw_comment_post($comment_id){
175
-
176
- $the_comment = get_comment($comment_id);
177
- bnfw_launch_payload(bnfw_get_recipients_for_type('comment_post'), bnfw_get_subject_for_comment_post($the_comment), bnfw_get_payload_for_comment_post($the_comment));
178
-
179
- }
180
-
181
- function bnfw_user_register($user_id){
182
-
183
- $the_user = get_user_by('id', $user_id);
184
- bnfw_launch_payload(bnfw_get_recipients_for_type('user_register'), bnfw_get_subject_for_user_register($the_user), bnfw_get_payload_for_user_register($the_user));
185
-
186
- }
187
-
188
- function bnfw_trackback_post($comment_id){
189
-
190
- $the_comment = get_comment($comment_id);
191
- bnfw_launch_payload(bnfw_get_recipients_for_type('trackback_post'), bnfw_get_subject_for_trackback_post($the_comment), bnfw_get_payload_for_trackback_post($the_comment));
192
-
193
- }
194
-
195
- function bnfw_pingback_post($comment_id){
196
-
197
- $the_comment = get_comment($comment_id);
198
- bnfw_launch_payload(bnfw_get_recipients_for_type('pingback_post'), bnfw_get_subject_for_pingback_post($the_comment), bnfw_get_payload_for_pingback_post($the_comment));
199
-
200
- }
201
-
202
- function bnfw_lostpassword_post(){
203
- $user_data = get_user_by( 'email', trim( $_POST['user_login'] ) );
204
- bnfw_launch_payload(bnfw_get_recipients_for_type('lostpassword_post'), bnfw_get_subject_for_lostpassword_post($user_data), bnfw_get_payload_for_lostpassword_post($user_data));
205
- }
206
-
207
-
208
- function bnfw_debug($content){
209
-
210
- $bnfw_options = get_option('bnfw_settings');
211
-
212
- if ( !isset( $wp_roles ) )
213
- $wp_roles = new WP_Roles();
214
- var_dump($wp_roles->get_names());
215
-
216
- var_dump($bnfw_options);
217
- return $content;
218
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bnfw.php ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ Plugin Name: Better Notifications for WordPress
4
+ Plugin URI: http://wordpress.org/plugins/bnfw/
5
+ Description: Customise the default WordPress email notifications and create new ones with HTML and shortcodes.
6
+ Version: 1.0
7
+ Author: Voltronik
8
+ Author URI: http://www.voltronik.co.uk/
9
+ Author Email: plugins@voltronik.co.uk
10
+ License: GPLv2 or later
11
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
+ Text Domain: bnfw
13
+ Domain Path: languages/
14
+ **/
15
+
16
+ /**
17
+ Copyright © 2014 Voltronik (plugins@voltronik.co.uk)
18
+
19
+ This program is free software; you can redistribute it and/or modify
20
+ it under the terms of the GNU General Public License, version 2, as
21
+ published by the Free Software Foundation.
22
+
23
+ This program is distributed in the hope that it will be useful,
24
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
25
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
+ GNU General Public License for more details.
27
+
28
+ You should have received a copy of the GNU General Public License
29
+ along with this program; if not, write to the Free Software
30
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31
+ */
32
+
33
+ class BNFW {
34
+
35
+ /**
36
+ * Constructor.
37
+ *
38
+ * @since 1.0
39
+ */
40
+ function __construct() {
41
+ $this->load_textdomain();
42
+ $this->includes();
43
+ $this->hooks();
44
+
45
+ $this->notifier = new BNFW_Notification;
46
+ $this->engine = new BNFW_Engine;
47
+ }
48
+
49
+ /**
50
+ * Loads the plugin language files
51
+ *
52
+ * @since 1.0
53
+ */
54
+ public function load_textdomain() {
55
+ // Load localization domain
56
+ $this->translations = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
57
+ load_plugin_textdomain( 'bnfw', false, $this->translations );
58
+ }
59
+
60
+ /**
61
+ * Include required files.
62
+ *
63
+ * @since 1.0
64
+ */
65
+ public function includes() {
66
+ // Load Engine and post type
67
+ require_once( 'includes/engine/class-bnfw-engine.php' );
68
+ require_once( 'includes/admin/class-bnfw-notification.php' );
69
+
70
+ // Load Admin Pages
71
+ if ( is_admin() ) {
72
+ require_once( 'includes/admin/bnfw-settings.php' );
73
+ }
74
+
75
+ // uncomment for debugging
76
+ //require_once ('includes/debug.php');
77
+ }
78
+
79
+ /**
80
+ * Register Hooks.
81
+ *
82
+ * @since 1.0
83
+ */
84
+ public function hooks() {
85
+ register_activation_hook( __FILE__, array( $this, 'activate' ) );
86
+
87
+ add_action( 'draft_to_publish' , array( $this, 'publish_post' ) );
88
+ add_action( 'publish_to_publish' , array( $this, 'update_post' ) );
89
+
90
+ add_action( 'comment_post' , array( $this, 'comment_post' ) );
91
+ add_action( 'trackback_post' , array( $this, 'trackback_post' ) );
92
+ add_action( 'pingback_post' , array( $this, 'pingback_post' ) );
93
+
94
+ add_action( 'user_register' , array( $this, 'user_register' ) );
95
+ add_action( 'lostpassword_post' , array( $this, 'lost_password' ) );
96
+
97
+ add_action( 'create_term' , array( $this, 'create_term' ), 10, 3 );
98
+
99
+ add_filter( 'plugin_action_links' , array( $this, 'plugin_action_links' ), 10, 4 );
100
+ }
101
+
102
+ /**
103
+ * Run this on first-time plugin activation
104
+ *
105
+ * @since 1.0
106
+ */
107
+ // importer
108
+ public function activate() {
109
+ require_once( dirname( __FILE__ ) . '/includes/import.php' );
110
+ $importer = new BNFW_Import;
111
+ $importer->import();
112
+ }
113
+
114
+ /**
115
+ * Add 'Settings' link below BNFW in Plugins list.
116
+ *
117
+ * @since 1.0
118
+ */
119
+ public function plugin_action_links( $links, $file ) {
120
+ $plugin_file = 'bnfw/bnfw.php';
121
+ if ( $file == $plugin_file ) {
122
+ $settings_link = '<a href="' . admin_url( 'admin.php?page=bnfw-settings' ) . '">' . 'Settings' . '</a>';
123
+ array_unshift( $links, $settings_link );
124
+ }
125
+ return $links;
126
+ }
127
+
128
+ /**
129
+ * When a new term is created.
130
+ *
131
+ * @since 1.0
132
+ */
133
+ public function create_term( $term_id, $tt_id, $taxonomy ) {
134
+ if ( 'category' == $taxonomy ) {
135
+ $this->send_notification( 'new-category', $term_id );
136
+ } else {
137
+ $this->send_notification( 'new-term', $term_id );
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Fires when a post is created for the first time.
143
+ *
144
+ * @since 1.0
145
+ */
146
+ function publish_post( $post ) {
147
+ $post_id = $post->ID;
148
+ $post_type = $post->post_type;
149
+
150
+ if ( BNFW_Notification::POST_TYPE != $post_type ) {
151
+ $this->send_notification( 'new-' . $post_type, $post_id );
152
+ }
153
+ }
154
+
155
+ /**
156
+ * Fires when a post is updated.
157
+ *
158
+ * @since 1.0
159
+ */
160
+ function update_post( $post ) {
161
+ $post_id = $post->ID;
162
+ $post_type = $post->post_type;
163
+
164
+ if ( BNFW_Notification::POST_TYPE != $post_type ) {
165
+ $this->send_notification( 'update-' . $post_type, $post_id );
166
+ }
167
+ }
168
+
169
+ /**
170
+ * Send notification for new comments
171
+ *
172
+ * @since 1.0
173
+ */
174
+ function comment_post( $comment_id ) {
175
+ $the_comment = get_comment( $comment_id );
176
+ if ( $this->can_send_comment_notification( $the_comment ) ) {
177
+ $this->send_notification( 'new-comment', $comment_id );
178
+ }
179
+ }
180
+
181
+ /**
182
+ * Send notification for new trackback
183
+ *
184
+ * @since 1.0
185
+ */
186
+ function trackback_post( $comment_id ){
187
+ $the_comment = get_comment( $comment_id );
188
+ if ( $this->can_send_comment_notification( $the_comment ) ) {
189
+ $this->send_notification( 'new-trackback', $comment_id );
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Send notification for new pingbacks
195
+ *
196
+ * @since 1.0
197
+ */
198
+ function pingback_post( $comment_id ) {
199
+ $the_comment = get_comment( $comment_id );
200
+ if ( $this->can_send_comment_notification( $the_comment ) ) {
201
+ $this->send_notification( 'new-pingback', $comment_id );
202
+ }
203
+ }
204
+
205
+ /**
206
+ * Send notification for lost password.
207
+ *
208
+ * @since 1.0
209
+ */
210
+ function lost_password() {
211
+ $user = get_user_by( 'login', trim( $_POST['user_login'] ) );
212
+ if ( $user ) {
213
+ $this->send_notification( 'user-password', $user->ID );
214
+ }
215
+ }
216
+
217
+ /**
218
+ * Send notification for new uses.
219
+ *
220
+ * @since 1.0
221
+ */
222
+ function user_register( $user_id ) {
223
+ $this->send_notification( 'new-user', $user_id );
224
+ }
225
+
226
+ /**
227
+ * Send notification based on type and ref id
228
+ *
229
+ * @access private
230
+ * @since 1.0
231
+ */
232
+ private function send_notification( $type, $ref_id ) {
233
+ $notifications = $this->notifier->get_notifications( $type );
234
+ foreach ( $notifications as $notification ) {
235
+ $this->engine->send_notification( $this->notifier->read_settings( $notification->ID ), $ref_id );
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Can send comment notification or not
241
+ *
242
+ * @since 1.0
243
+ */
244
+ private function can_send_comment_notification( $comment ) {
245
+ // Returns false if the comment is marked as spam AND admin has enabled suppression of spam
246
+ $suppress_spam = get_option( 'bnfw_suppress_spam' );
247
+ if ( '1' === $suppress_spam && ( 0 === strcmp( $comment->comment_approved, 'spam' ) ) ) {
248
+ return false;
249
+ }
250
+ return true;
251
+ }
252
+ }
253
+
254
+ /* ------------------------------------------------------------------------ *
255
+ * Fire up the plugin
256
+ * ------------------------------------------------------------------------ */
257
+ new BNFW;
includes/admin-page.php DELETED
@@ -1,201 +0,0 @@
1
- <?php
2
-
3
- /* Register the plugin pages */
4
- function bnfw_admin_menu() {
5
- add_menu_page( 'Better Notifications for WordPress Notifications', // The Menu Title
6
- 'Notifications', // The Page title
7
- 'manage_options', // The capability required for access to this item
8
- 'bnfw-admin', // the slug to use for the page in the URL
9
- 'bnfw_callback', // The function to call to render the page
10
- '', // Icon URL
11
- '100.111111' // Position in Admin Menu
12
- );
13
-
14
- add_submenu_page( 'bnfw-admin', 'Notifications', 'Notifications', 'manage_options', 'bnfw-admin', 'bnfw_callback');
15
- add_submenu_page( 'bnfw-admin', 'Email Templates', 'Email Templates', 'manage_options', 'bnfw-email-customise', 'bnfw_email_customise_page');
16
-
17
- /* Enqueue scripts action */
18
- add_action( 'admin_enqueue_scripts', 'bnfw_admin_scripts' );
19
-
20
- }
21
-
22
- // Create the Admin menu pages action
23
- add_action( 'admin_menu', 'bnfw_admin_menu' );
24
-
25
- // Call the settings page and create it
26
- function bnfw_callback() {
27
- bnfw_settings_page();
28
- }
29
-
30
- function bnfw_admin_scripts($hook) {
31
-
32
- if( strpos($hook, 'bnfw') === false){
33
- return;
34
- }
35
-
36
- wp_enqueue_style('bnfw-admin-css', plugin_dir_url(__FILE__) . 'css/plugin_styles.css');
37
- }
38
-
39
- // creates our settings in the options table
40
- function bnfw_register_settings() {
41
- register_setting('bnfw_settings_group', 'bnfw_settings');
42
- register_setting('bnfw_email_settings_group', 'bnfw_custom_email_settings');
43
-
44
- }
45
- add_action('admin_init', 'bnfw_register_settings');
46
-
47
-
48
-
49
- /***** Settings Page *****/
50
- function bnfw_settings_page() {
51
-
52
- $bnfw_options = get_option('bnfw_settings');
53
-
54
- ob_start(); ?>
55
-
56
-
57
- <div class="wrap">
58
-
59
- <?php settings_errors(); ?>
60
-
61
- <div class="row clearfix">
62
- <div class="eightcol first">
63
- <h2>Better Notifications for WordPress - Notifications</h2>
64
- <h3>Email Settings for User Roles</h3>
65
- <p>Here, you can set which user roles you'd like to receive emails notifications for.</p>
66
- </div>
67
-
68
- <div id="paypal-donate" class="fourcol last">
69
- <strong class="sevencol first">We worked really hard on this plugin. If you found it useful, please consider donating via the button to the right. Thanks!</strong>
70
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
71
- <input type="hidden" name="cmd" value="_s-xclick">
72
- <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----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-----END PKCS7-----
73
- ">
74
- <input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
75
- <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
76
- </form>
77
- </div>
78
- </div>
79
-
80
- <form method="post" action="options.php">
81
-
82
- <?php settings_fields('bnfw_settings_group'); ?>
83
-
84
- <div id="role-settings" class="twelvecol">
85
-
86
- <div id="roles" class="row clearfix">
87
- <div class="threecol first clearfix">&nbsp;</div>
88
- <?php foreach ($GLOBALS['BNFW_ACTION_TYPES'] as $bnfw_events) { ?>
89
- <div class="role twocol clearfix">
90
- <strong><?php echo $GLOBALS['BNFW_ACTION_TYPES_PRETTY'][$bnfw_events] ?></strong>
91
- </div>
92
- <?php } ?>
93
- </div>
94
-
95
- <?php $getted_roles = get_editable_roles(); foreach (get_editable_roles() as $field => $roles) { ?>
96
-
97
- <div class="event row clearfix">
98
- <div class="first threecol clearfix"><strong><?php echo $getted_roles[$field]['name']; ?></strong></div>
99
-
100
- <?php foreach ($GLOBALS['BNFW_ACTION_TYPES'] as $bnfw_events) { ?>
101
- <div class="role twocol clearfix">
102
- <input id="bnfw_settings[<?php echo $bnfw_events ?>-<?php echo $field ?>]" name="bnfw_settings[<?php echo $bnfw_events ?>-<?php echo $field ?>]" type="checkbox" value="1" <?php checked(1, $bnfw_options[$bnfw_events.'-'.$field]); ?> />
103
- </div>
104
- <?php } ?>
105
-
106
- </div>
107
-
108
- <?php } ?>
109
-
110
- </div>
111
-
112
- <p class="submit clearfix">
113
- <input type="submit" class="button-primary" value="Save Settings" />
114
- </p>
115
-
116
- </form>
117
-
118
- </div>
119
-
120
- <?php echo ob_get_clean();
121
-
122
- }
123
-
124
-
125
-
126
- /***** Email Customisation Page *****/
127
- function bnfw_email_customise_page() {
128
-
129
- $bnfw_options = get_option('bnfw_custom_email_settings');
130
-
131
- ob_start(); ?>
132
-
133
- <div class="wrap">
134
-
135
- <?php settings_errors(); ?>
136
-
137
- <div class="row clearfix">
138
- <div class="eightcol first">
139
- <h2>Better Notifications for WordPress - Email Templates</h2>
140
- <p>Here you can customise the emails that are sent out for each of the notifications.</p>
141
- <p>Email are sent out in HTML (you can add HTML tags) and can include shortcodes to insert more detail where required. For a full list of all shortcodes available, please go <a href="http://www.voltronik.co.uk/wordpress-plugins/better-notifications-for-wordpress/" title="Better Notifications for WordPress - Shortcodes" target="_blank">here</a>. <br />PLEASE NOTE: Not all shortcodes can be used with all notification types due to restrictions imposed by WordPress.</p>
142
- </div>
143
-
144
- <div id="paypal-donate" class="fourcol last">
145
- <strong class="sevencol first">We worked really hard on this plugin. If you found it useful, please consider donating via the button to the right. Thanks!</strong>
146
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
147
- <input type="hidden" name="cmd" value="_s-xclick">
148
- <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----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-----END PKCS7-----
149
- ">
150
- <input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
151
- <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
152
- </form>
153
- </div>
154
- </div>
155
-
156
- <form method="post" action="options.php">
157
-
158
- <?php settings_fields('bnfw_email_settings_group'); ?>
159
-
160
- <p class="submit clearfix">
161
- <input type="submit" class="button-primary" value="Save Settings" />
162
- </p>
163
-
164
- <div class="wrap clearfix">
165
- <?php foreach ($GLOBALS['BNFW_ACTION_TYPES'] as $bnfw_events) { ?>
166
- <div class="bnfw-email-custom-form sixcol clearfix">
167
-
168
- <!-- Event Type -->
169
- <h3 class="elevencol first clearfix"><?php echo $GLOBALS['BNFW_ACTION_TYPES_PRETTY'][$bnfw_events] ?></h3>
170
-
171
- <div class="sixcol first clearfix">
172
- <!-- Subject -->
173
- <label class="subject twelvecol first" for="bnfw_custom_email_settings[payload-subject-<?php echo $bnfw_events; ?>]">Email Subject</label>
174
- <input type="text" id="bnfw_custom_email_settings[payload-subject-<?php echo $bnfw_events; ?>]" name="bnfw_custom_email_settings[payload-subject-<?php echo $bnfw_events; ?>]" value="<?php echo $bnfw_options['payload-subject-'.$bnfw_events] ?>" />
175
-
176
- <!-- Message Body -->
177
- <label class="message-body twelvecol first" for="bnfw_custom_email_settings[payload-body-<?php echo $bnfw_events; ?>]">Email Message Body</label>
178
- <textarea id="bnfw_custom_email_settings[payload-body-<?php echo $bnfw_events; ?>]" name="bnfw_custom_email_settings[payload-body-<?php echo $bnfw_events; ?>]"><?php echo $bnfw_options['payload-body-'.$bnfw_events] ?></textarea>
179
- </div>
180
-
181
- <div class="bnfw-preview left">
182
- <h4>Email Message Body Preview</h4>
183
-
184
- <div class="bnfw-preview-content">
185
- <?php echo $bnfw_options['payload-body-'.$bnfw_events] ?>
186
- </div>
187
- </div>
188
- </div>
189
- <?php } ?>
190
- </div>
191
-
192
- <p class="submit clearfix">
193
- <input type="submit" class="button-primary" value="Save Settings" />
194
- </p>
195
-
196
- </form>
197
-
198
- </div>
199
-
200
- <?php echo ob_get_clean();
201
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin/bnfw-settings.php ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* ------------------------------------------------------------------------ *
3
+ * Register the Admin pages and load the scripts action
4
+ * ------------------------------------------------------------------------ */
5
+
6
+ // Sub-menu pages
7
+ function bnfw_admin_menu() {
8
+
9
+ // New Notifications Sub-menu
10
+ add_submenu_page(
11
+ 'edit.php?post_type=bnfw_notification',
12
+ __( 'Notification Settings', 'bnfw' ),
13
+ __( 'Settings', 'bnfw' ),
14
+ 'manage_options',
15
+ 'bnfw-settings',
16
+ 'bnfw_settings_page'
17
+ );
18
+ }
19
+ // Add the Admin pages to the WordPress menu
20
+ add_action( 'admin_menu', 'bnfw_admin_menu' );
21
+
22
+ /* ------------------------------------------------------------------------ *
23
+ * Menu Pages
24
+ * ------------------------------------------------------------------------ */
25
+
26
+ // Settings Page
27
+ function bnfw_settings_page() {
28
+ ob_start(); ?>
29
+
30
+ <div class="wrap">
31
+ <?php screen_icon(); ?>
32
+ <h2><?php _e( 'BNFW Settings', 'bnfw'); ?></h2>
33
+
34
+ <form method="post" action="options.php" class="bnfw-form">
35
+ <?php
36
+ settings_errors();
37
+ settings_fields('bnfw-settings');
38
+ do_settings_sections( 'bnfw-settings' );
39
+
40
+ submit_button( 'Save Settings' );
41
+ ?>
42
+ </form>
43
+ </div>
44
+
45
+ <?php echo ob_get_clean();
46
+ }
47
+
48
+ /* ------------------------------------------------------------------------ *
49
+ * Settings Page - Setting Registration
50
+ * ------------------------------------------------------------------------ */
51
+ function bnfw_general_options() {
52
+
53
+ // Set-up - General Options Section
54
+ add_settings_section (
55
+ 'bnfw_general_options_section', // Section ID
56
+ '', // Title above settings section
57
+ 'bnfw_general_options_callback', // Name of function that renders a description of the settings section
58
+ 'bnfw-settings' // Page to show on
59
+ );
60
+
61
+ // Add - Specify Name, Email, CC and BCC Checkbox
62
+ //add_settings_field (
63
+ //'bnfw_specify_email_headers', // Field ID
64
+ //__( 'Email Headers', 'bnfw' ), // Label to the left
65
+ //'bnfw_general_options_section_checkbox', // Name of function that renders options on the page
66
+ //'bnfw-settings', // Page to show on
67
+ //'bnfw_general_options_section', // Associate with which settings section?
68
+ //array(
69
+ //__( 'Do you want to specify a Name, Email, CC and BCC for each notification?', 'bnfw' )
70
+ //)
71
+ //);
72
+
73
+ // Suppress notifications for SPAM comments
74
+ add_settings_field (
75
+ 'bnfw_suppress_spam', // Field ID
76
+ __( 'Suppress SPAM comment notification', 'bnfw' ), // Label to the left
77
+ 'bnfw_suppress_spam_checkbox', // Name of function that renders options on the page
78
+ 'bnfw-settings', // Page to show on
79
+ 'bnfw_general_options_section', // Associate with which settings section?
80
+ array(
81
+ __( "Don't send notifications for comments marked as SPAM by Akismet", 'bnfw' )
82
+ )
83
+ );
84
+
85
+ //// Add - Minimum access role dropdown
86
+ //add_settings_field (
87
+ //'bnfw_choose_admin', // Field ID
88
+ //__( 'Set minimum role to have access to this plugin', 'bnfw' ), // Label to the left
89
+ //'bnfw_choose_admin_dropdown', // Name of function that renders options on the page
90
+ //'bnfw-settings', // Page to show on
91
+ //'bnfw_general_options_section' // Associate with which settings section?
92
+ //);
93
+
94
+ // Register - Specify Name, Email, CC and BCC Checkbox
95
+ //register_setting (
96
+ //'bnfw-settings',
97
+ //'bnfw_specify_email_headers'
98
+ //);
99
+
100
+ // Register - Suppress SPAM Checkbox
101
+ register_setting (
102
+ 'bnfw-settings',
103
+ 'bnfw_suppress_spam'
104
+ );
105
+
106
+ //// Register - Minimum access role dropdown
107
+ //register_setting (
108
+ //'bnfw-settings',
109
+ //'bnfw_choose_admin'
110
+ //);
111
+ }
112
+ add_action('admin_init', 'bnfw_general_options');
113
+
114
+ /* ------------------------------------------------------------------------ *
115
+ * Settings Page - Settings Section Callbacks
116
+ * ------------------------------------------------------------------------ */
117
+
118
+ function bnfw_general_options_callback() {}
119
+
120
+ /* ------------------------------------------------------------------------ *
121
+ * Settings Page - Settings Field Callbacks
122
+ * ------------------------------------------------------------------------ */
123
+
124
+ // Specify Name, Email, CC and BCC Checkbox
125
+ function bnfw_general_options_section_checkbox($args) {
126
+ echo '<input type="checkbox" id="bnfw_specify_email_headers" name="bnfw_specify_email_headers" value="1" ' . checked(1, get_option('bnfw_specify_email_headers'), false) . '/>';
127
+ echo '<label for="bnfw_specify_email_headers"> ' . $args[0] . '</label>';
128
+ }
129
+
130
+ /**
131
+ * Suppress SPAM checkbox.
132
+ *
133
+ * @since 1.0
134
+ */
135
+ function bnfw_suppress_spam_checkbox( $args ) {
136
+ ?>
137
+ <input type="checkbox" id="bnfw_suppress_spam" name="bnfw_suppress_spam" value="1" <?php checked( 1, get_option( 'bnfw_suppress_spam' ), true );?>>
138
+ <label for="bnfw_suppress_spam"><?php echo $args[0]; ?></label>
139
+ <?php
140
+ }
141
+
142
+ // Minimum access role dropdown
143
+ function bnfw_choose_admin_dropdown($args) {
144
+
145
+ echo '<select id="bnfw_choose_admin" name="bnfw_choose_admin">';
146
+ global $wp_roles;
147
+ $roles = $wp_roles->get_names();
148
+
149
+ foreach($roles as $role) {
150
+ echo '<option value="'.$role.'"' . selected(get_option('bnfw_choose_admin'), $role , false) . '>' . $role . '</option>';
151
+ }
152
+ echo '</select>';
153
+ }
154
+
155
+ /* ------------------------------------------------------------------------ *
156
+ * Notification Generator - Setting Registration
157
+ * ------------------------------------------------------------------------ */
158
+ function bnfw_generator_options() {
159
+
160
+ // Set-up - Generator Section
161
+ add_settings_section (
162
+ 'bnfw_generator_section', // Section ID
163
+ '', // Title above settings section
164
+ 'bnfw_generator_callback', // Name of function that renders a description of the settings section
165
+ 'bnfw-generator' // Page to show on
166
+ );
167
+
168
+ // Add - Notification Name Text
169
+ add_settings_field (
170
+ 'bnfw_notification_name', // Field ID
171
+ __( 'Notification Name', 'bnfw' ), // Label to the left
172
+ 'bnfw_generator_notification_name', // Name of function that renders options on the page
173
+ 'bnfw-generator', // Page to show on
174
+ 'bnfw_generator_section' // Associate with which settings section?
175
+ );
176
+
177
+ // Add - Notification User Roles
178
+ add_settings_field (
179
+ 'bnfw_user_roles', // Field ID
180
+ __( 'User Roles', 'bnfw' ), // Label to the left
181
+ 'bnfw_generator_user_roles', // Name of function that renders options on the page
182
+ 'bnfw-generator', // Page to show on
183
+ 'bnfw_generator_section' // Associate with which settings section?
184
+ );
185
+
186
+ // Add - Notification Users
187
+ add_settings_field (
188
+ 'bnfw_users', // Field ID
189
+ __( 'User', 'bnfw' ), // Label to the left
190
+ 'bnfw_generator_users', // Name of function that renders options on the page
191
+ 'bnfw-generator', // Page to show on
192
+ 'bnfw_generator_section' // Associate with which settings section?
193
+ );
194
+
195
+
196
+ // Register - All Generator Fields
197
+ register_setting ( 'bnfw-generator', 'bnfw_notification_name' );
198
+ register_setting ( 'bnfw-generator', 'bnfw_user_roles' );
199
+ register_setting ( 'bnfw-generator', 'bnfw_users' );
200
+ }
201
+ add_action('admin_init', 'bnfw_generator_options');
202
+
203
+ /* ------------------------------------------------------------------------ *
204
+ * Notification Generator - Form Section Callbacks
205
+ * ------------------------------------------------------------------------ */
206
+
207
+ function bnfw_generator_callback() {}
208
+
209
+ /* ------------------------------------------------------------------------ *
210
+ * Notification Generator - Field Callbacks
211
+ * ------------------------------------------------------------------------ */
212
+
213
+ function bnfw_generator_notification_name($args) {
214
+
215
+ $settings = get_option( 'bnfw_notification_name' );
216
+ // Show this field if page isn't bnfw-notifications.php
217
+ if (strcmp(basename($_SERVER['PHP_SELF']), "bnfw-notifications.php") != 0) {
218
+ echo '<input type="text" name="bnfw_notification_name" value="'. $settings .'">';
219
+ }
220
+ }
221
+
222
+ function bnfw_generator_user_roles($args) {
223
+
224
+ $settings = get_option( 'bnfw_user_roles' );
225
+
226
+ echo '<select multiple name="bnfw_user_roles" id="' . $settings . '" class="select2 populate">';
227
+ global $wp_roles;
228
+ $roles = $wp_roles->get_names();
229
+
230
+ echo '<option value="'.$settings.'" selected>' . $settings . '</option>';
231
+
232
+ foreach($roles as $role) {
233
+ echo '<option value="'.$role.'">' . $role . '</option>';
234
+ }
235
+ echo '</select>';
236
+ }
237
+
238
+
239
+ function bnfw_generator_users($args) {
240
+
241
+ $user_roles = get_option( 'bnfw_user_roles' );
242
+ $single_users = get_option( 'bnfw_users' );
243
+
244
+ // Enable Users Checkbox
245
+ echo '<div id="bnfw-users-enable" class="checkbox bnfw-field">
246
+ <label for="bnfw-users-enable-checkbox">',
247
+ __( 'Do you want to specify individual users from the user roles selected above?', 'bnfw' ),
248
+ '</label>
249
+ <input type="checkbox" id="bnfw-users-enable-checkbox">
250
+ </div>';
251
+
252
+ echo '<select multiple name="bnfw_users" id="' . $single_users . '" class="select2 populate">';
253
+ global $wp_roles;
254
+ $roles = $wp_roles->get_names();
255
+
256
+ echo '<option value="'.$single_users.'" selected>' . $single_users . '</option>';
257
+
258
+ foreach($roles as $role) {
259
+ echo '<option value="'.$role.'">' . $role . '</option>';
260
+ }
261
+ echo '</select>';
262
+ }
includes/admin/class-bnfw-notification.php ADDED
@@ -0,0 +1,581 @@