Better Notifications for WordPress - Version 0.2b

Version Description

Download this release

Release Info

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

Version 0.2b

README.txt ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.2b
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
+
40
+ == Installation ==
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.2 beta =
98
+ * Added an option to suppress spam comment notifications.
99
+
100
+ = 0.1 beta =
101
+ * Initial version of the plugin.
102
+ * Settings page for configuring notification types for roles.
103
+ * Email Templates page for customising emails using HTML and shortcodes.
better-wordpress-notifications.php ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Better Notifications for WordPress
4
+ Plugin URI: http://wordpress.org/extend/plugins/bnfw/
5
+ Description: Send customisable HTML emails to user roles for different WordPress notifications.
6
+ Version: 0.2 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
+
178
+ if(!bnfw_check_for_spam($the_comment)){
179
+ 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));
180
+ }
181
+
182
+ }
183
+
184
+ function bnfw_user_register($user_id){
185
+
186
+ $the_user = get_user_by('id', $user_id);
187
+ 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));
188
+
189
+ }
190
+
191
+ function bnfw_trackback_post($comment_id){
192
+
193
+ $the_comment = get_comment($comment_id);
194
+ if(!bnfw_check_for_spam($the_comment)){
195
+ 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));
196
+ }
197
+ }
198
+
199
+ function bnfw_pingback_post($comment_id){
200
+
201
+ $the_comment = get_comment($comment_id);
202
+ if(!bnfw_check_for_spam($the_comment)){
203
+ 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));
204
+ }
205
+ }
206
+
207
+ function bnfw_lostpassword_post(){
208
+ $user_data = get_user_by( 'email', trim( $_POST['user_login'] ) );
209
+ 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));
210
+ }
211
+
212
+
213
+ function bnfw_debug($content){
214
+
215
+ $bnfw_options = get_option('bnfw_settings');
216
+
217
+ if ( !isset( $wp_roles ) )
218
+ $wp_roles = new WP_Roles();
219
+ var_dump($wp_roles->get_names());
220
+
221
+ var_dump($bnfw_options);
222
+ return $content;
223
+ }
includes/admin-page.php ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-----MIIHRwYJKoZIhvcNAQcEoIIHODCCBzQCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkq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Mu30ZCgzxSr0NwQw8guDqt59FjteksFnOYH/9Oe4em8hWWN6fuGpRHGno9hK64wbsy9ZKCy2NDyljDhghNWeSOXrHmv7bKqQny6Y/DqlUJZyxSea4W8B9FT4i8IC/IWjlQs8/IG65Xw==-----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
+ <div id="other-options" class="twelvecol first">
113
+ <label for="bnfw_settings[bnfw_settings_spam]">Suppress notifications for comments marked as spam?</label>
114
+ <input id="bnfw_settings[bnfw_settings_spam]" name="bnfw_settings[bnfw_settings_spam]" type="checkbox" value="1" <?php checked(1, $bnfw_options['bnfw_settings_spam']); ?> />
115
+ </div>
116
+
117
+ <p class="submit clearfix">
118
+ <input type="submit" class="button-primary" value="Save Settings" />
119
+ </p>
120
+
121
+ </form>
122
+
123
+ </div>
124
+
125
+ <?php echo ob_get_clean();
126
+
127
+ }
128
+
129
+
130
+
131
+ /***** Email Customisation Page *****/
132
+ function bnfw_email_customise_page() {
133
+
134
+ $bnfw_options = get_option('bnfw_custom_email_settings');
135
+
136
+ ob_start(); ?>
137
+
138
+ <div class="wrap">
139
+
140
+ <?php settings_errors(); ?>
141
+
142
+ <div class="row clearfix">
143
+ <div class="eightcol first">
144
+ <h2>Better Notifications for WordPress - Email Templates</h2>
145
+ <p>Here you can customise the emails that are sent out for each of the notifications.</p>
146
+ <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>
147
+ </div>
148
+
149
+ <div id="paypal-donate" class="fourcol last">
150
+ <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>
151
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
152
+ <input type="hidden" name="cmd" value="_s-xclick">
153
+ <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHRwYJKoZIhvcNAQcEoIIHODCCBzQCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ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AEgYAycTRRP/j6HJ7uSWG24u+2qAM8kh2PR/ZMu30ZCgzxSr0NwQw8guDqt59FjteksFnOYH/9Oe4em8hWWN6fuGpRHGno9hK64wbsy9ZKCy2NDyljDhghNWeSOXrHmv7bKqQny6Y/DqlUJZyxSea4W8B9FT4i8IC/IWjlQs8/IG65Xw==-----END PKCS7-----
154
+ ">
155
+ <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.">
156
+ <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
157
+ </form>
158
+ </div>
159
+ </div>
160
+
161
+ <form method="post" action="options.php">
162
+
163
+ <?php settings_fields('bnfw_email_settings_group'); ?>
164
+
165
+ <p class="submit clearfix">
166
+ <input type="submit" class="button-primary" value="Save Settings" />
167
+ </p>
168
+
169
+ <div class="wrap clearfix">
170
+ <?php foreach ($GLOBALS['BNFW_ACTION_TYPES'] as $bnfw_events) { ?>
171
+ <div class="bnfw-email-custom-form sixcol clearfix">
172
+
173
+ <!-- Event Type -->
174
+ <h3 class="elevencol first clearfix"><?php echo $GLOBALS['BNFW_ACTION_TYPES_PRETTY'][$bnfw_events] ?></h3>
175
+
176
+ <div class="sixcol first clearfix">
177
+ <!-- Subject -->
178
+ <label class="subject twelvecol first" for="bnfw_custom_email_settings[payload-subject-<?php echo $bnfw_events; ?>]">Email Subject</label>
179
+ <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] ?>" />
180
+
181
+ <!-- Message Body -->
182
+ <label class="message-body twelvecol first" for="bnfw_custom_email_settings[payload-body-<?php echo $bnfw_events; ?>]">Email Message Body</label>
183
+ <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>
184
+ </div>
185
+
186
+ <div class="bnfw-preview left">
187
+ <h4>Email Message Body Preview</h4>
188
+
189
+ <div class="bnfw-preview-content">
190
+ <?php echo $bnfw_options['payload-body-'.$bnfw_events] ?>
191
+ </div>
192
+ </div>
193
+ </div>
194
+ <?php } ?>
195
+ </div>
196
+
197
+ <p class="submit clearfix">
198
+ <input type="submit" class="button-primary" value="Save Settings" />
199
+ </p>
200
+
201
+ </form>
202
+
203
+ </div>
204
+
205
+ <?php echo ob_get_clean();
206
+ }
includes/bnfw_engine.php ADDED
@@ -0,0 +1,626 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function bnfw_check_for_spam($the_comment){
4
+
5
+ //returns true if the comment is marked as spam AND admin has enabled suppression of spam
6
+ $bnfw_options = get_option('bnfw_settings');
7
+ return((strcmp($the_comment->comment_approved, "spam") === 0) && $bnfw_options['bnfw_settings_spam'] === "1" );
8
+
9
+ }
10
+
11
+
12
+ /*
13
+ Logic to retrieve to whom the notif should be sent
14
+ */
15
+ function bnfw_get_recipients_for_type($notification_type){
16
+
17
+ $bnfw_options = get_option('bnfw_settings');
18
+
19
+ $recipients = '';
20
+
21
+ if ( !isset( $wp_roles ) )
22
+ $wp_roles = new WP_Roles();
23
+
24
+ foreach ($wp_roles->roles as $field => $role) {
25
+
26
+ if($bnfw_options[$notification_type.'-'.$field] === "1"){
27
+
28
+ $users = get_users('role='.$field);
29
+
30
+ foreach ($users as $the_email) {
31
+ $recipients .= $the_email->user_email . ',';
32
+ }
33
+
34
+ }
35
+ }
36
+
37
+ return $recipients;
38
+ }
39
+
40
+ function bnfw_launch_payload($recipients, $subject, $payload){
41
+
42
+ $headers[] = 'content-type: text/html';
43
+ $headers[] = 'Bcc: '.$recipients;
44
+ $headers[] = 'From: '.get_option('blogname').' <'.get_option('admin_email').'>';
45
+ wp_mail("", $subject, $payload, $headers);
46
+
47
+ }
48
+
49
+ /*
50
+ * Subject getters -----------------------------------------------
51
+ */
52
+
53
+ function bnfw_get_subject_for_publish_post($the_post){
54
+
55
+ $bnfw_options = get_option('bnfw_custom_email_settings');
56
+ $user_info = get_userdata($the_post->post_author);
57
+
58
+ $message_body = $bnfw_options['payload-subject-publish_post'];
59
+
60
+ $message_body = str_replace("[ID]", $the_post->ID, $message_body);
61
+ $message_body = str_replace("[post_author]", $the_post->post_author, $message_body);
62
+ $message_body = str_replace("[post_date]", $the_post->post_date, $message_body);
63
+ $message_body = str_replace("[post_date_gmt]", $the_post->post_date_gmt, $message_body);
64
+ $message_body = str_replace("[post_content]", $the_post->post_content, $message_body);
65
+ $message_body = str_replace("[post_title]", $the_post->post_title, $message_body);
66
+
67
+ $category_list = "";
68
+
69
+ foreach ($the_post->post_category as $category_int){
70
+
71
+ $temp_term = get_term_by('id', $category_int, 'category'); $category_list .= $temp_term->name . ", ";
72
+
73
+ }
74
+
75
+ $message_body = str_replace("[post_category]", $category_list, $message_body);
76
+ $message_body = str_replace("[post_excerpt]", implode(", ", $the_post->post_excerpt), $message_body);
77
+ $message_body = str_replace("[post_status]", $the_post->post_status, $message_body);
78
+ $message_body = str_replace("[comment_status]", $the_post->comment_status, $message_body);
79
+ $message_body = str_replace("[ping_status]", $the_post->ping_status, $message_body);
80
+ $message_body = str_replace("[post_password]", $the_post->post_password, $message_body);
81
+ $message_body = str_replace("[post_name]", $the_post->post_name, $message_body);
82
+ $message_body = str_replace("[to_ping]", $the_post->to_ping, $message_body);
83
+ $message_body = str_replace("[pinged]", implode(", ", $the_post->pinged), $message_body);
84
+ $message_body = str_replace("[post_modified]", $the_post->post_modified, $message_body);
85
+ $message_body = str_replace("[post_modified_gmt]", $the_post->post_modified_gmt, $message_body);
86
+ $message_body = str_replace("[post_content_filtered]", $the_post->post_content_filtered, $message_body);
87
+ $message_body = str_replace("[post_parent]", $the_post->post_parent, $message_body);
88
+ $message_body = str_replace("[guid]", $the_post->guid, $message_body);
89
+ $message_body = str_replace("[menu_order]", $the_post->menu_order, $message_body);
90
+ $message_body = str_replace("[post_type]", $the_post->post_type, $message_body);
91
+ $message_body = str_replace("[post_mime_type]", $the_post->post_mime_type, $message_body);
92
+ $message_body = str_replace("[comment_count]", $the_post->comment_count, $message_body);
93
+
94
+ $message_body = str_replace("[user_login]", $user_info->user_login, $message_body);
95
+ $message_body = str_replace("[user_nicename]", $user_info->user_nicename, $message_body);
96
+ $message_body = str_replace("[user_email]", $user_info->user_email, $message_body);
97
+ $message_body = str_replace("[user_url]", $user_info->user_url, $message_body);
98
+ $message_body = str_replace("[user_registered]", $user_info->user_registered, $message_body);
99
+ $message_body = str_replace("[display_name]", $user_info->display_name, $message_body);
100
+ $message_body = str_replace("[user_firstname]", $user_info->user_firstname, $message_body);
101
+ $message_body = str_replace("[user_lastname]", $user_info->user_lastname, $message_body);
102
+ $message_body = str_replace("[nickname]", $user_info->nickname, $message_body);
103
+ $message_body = str_replace("[user_description]", $user_info->user_description, $message_body);
104
+ $message_body = str_replace("[wp_capabilities]", implode(", ", $user_info->wp_capabilities), $message_body);
105
+ $message_body = str_replace("[admin_color]", $user_info->admin_color, $message_body);
106
+ $message_body = str_replace("[closedpostboxes_page]", $user_info->closedpostboxes_page, $message_body);
107
+ $message_body = str_replace("[primary_blog]", implode(", ", $user_info->primary_blog), $message_body);
108
+ $message_body = str_replace("[rich_editing]", $user_info->rich_editing, $message_body);
109
+ $message_body = str_replace("[source_domain]", $user_info->source_domain, $message_body);
110
+
111
+ return $message_body;
112
+
113
+ }
114
+
115
+ function bnfw_get_subject_for_term_created($the_term){
116
+
117
+ $bnfw_options = get_option('bnfw_custom_email_settings');
118
+ $message_body = $bnfw_options['payload-subject-create_term'];
119
+
120
+ $message_body = str_replace("[slug]", $the_term->slug, $message_body);
121
+ $message_body = str_replace("[name]", $the_term->name, $message_body);
122
+ $message_body = str_replace("[description]", $the_term->description, $message_body);
123
+
124
+ return $message_body;
125
+ }
126
+
127
+
128
+ function bnfw_get_subject_for_comment_post($the_comment){
129
+
130
+ $bnfw_options = get_option('bnfw_custom_email_settings');
131
+ $message_body = $bnfw_options['payload-subject-comment_post'];
132
+ $user_info = get_userdata($the_comment->comment_author);
133
+ $the_post = get_post($the_comment->comment_post_ID);
134
+
135
+ $message_body = str_replace("[comment_ID]", $the_comment->comment_ID, $message_body);
136
+ $message_body = str_replace("[comment_post_ID]", $the_comment->comment_post_ID, $message_body);
137
+ $message_body = str_replace("[comment_author]", $the_comment->comment_author, $message_body);
138
+ $message_body = str_replace("[comment_author_email]", $the_comment->comment_author_email, $message_body);
139
+ $message_body = str_replace("[comment_author_url]", $the_comment->comment_author_url, $message_body);
140
+ $message_body = str_replace("[comment_author_IP]", $the_comment->comment_author_IP, $message_body);
141
+ $message_body = str_replace("[comment_date]", $the_comment->comment_date, $message_body);
142
+ $message_body = str_replace("[comment_date_gmt]", $the_comment->comment_date_gmt, $message_body);
143
+ $message_body = str_replace("[comment_content]", $the_comment->comment_content, $message_body);
144
+ $message_body = str_replace("[comment_karma]", $the_comment->comment_karma, $message_body);
145
+ $message_body = str_replace("[comment_approved]", str_replace(array("0", "1", "spam"), array("awaiting moderation", "approved", "spam"), $the_comment->comment_approved), $message_body);
146
+ $message_body = str_replace("[comment_agent]", $the_comment->comment_agent, $message_body);
147
+ $message_body = str_replace("[comment_type]", $the_comment->comment_type, $message_body);
148
+ $message_body = str_replace("[comment_parent]", $the_comment->comment_parent, $message_body);
149
+ $message_body = str_replace("[user_id]", $the_comment->user_id, $message_body);
150
+
151
+ $message_body = str_replace("[user_login]", $user_info->user_login, $message_body);
152
+ $message_body = str_replace("[user_nicename]", $user_info->user_nicename, $message_body);
153
+ $message_body = str_replace("[user_email]", $user_info->user_email, $message_body);
154
+ $message_body = str_replace("[user_url]", $user_info->user_url, $message_body);
155
+ $message_body = str_replace("[user_registered]", $user_info->user_registered, $message_body);
156
+ $message_body = str_replace("[display_name]", $user_info->display_name, $message_body);
157
+ $message_body = str_replace("[user_firstname]", $user_info->user_firstname, $message_body);
158
+ $message_body = str_replace("[user_lastname]", $user_info->user_lastname, $message_body);
159
+ $message_body = str_replace("[nickname]", $user_info->nickname, $message_body);
160
+ $message_body = str_replace("[user_description]", $user_info->user_description, $message_body);
161
+ $message_body = str_replace("[wp_capabilities]", implode(", ", $user_info->wp_capabilities), $message_body);
162
+ $message_body = str_replace("[admin_color]", $user_info->admin_color, $message_body);
163
+ $message_body = str_replace("[closedpostboxes_page]", $user_info->closedpostboxes_page, $message_body);
164
+ $message_body = str_replace("[primary_blog]", implode(", ", $user_info->primary_blog), $message_body);
165
+ $message_body = str_replace("[rich_editing]", $user_info->rich_editing, $message_body);
166
+ $message_body = str_replace("[source_domain]", $user_info->source_domain, $message_body);
167
+
168
+ $message_body = str_replace("[post_author]", $the_post->post_author, $message_body);
169
+ $message_body = str_replace("[post_date]", $the_post->post_date, $message_body);
170
+ $message_body = str_replace("[post_date_gmt]", $the_post->post_date_gmt, $message_body);
171
+ $message_body = str_replace("[post_content]", $the_post->post_content, $message_body);
172
+ $message_body = str_replace("[post_title]", $the_post->post_title, $message_body);
173
+ $category_list = "";
174
+
175
+ foreach ($the_post->post_category as $category_int){
176
+
177
+ $temp_term = get_term_by('id', $category_int, 'category'); $category_list .= $temp_term->name . ", ";
178
+
179
+ }
180
+
181
+ $message_body = str_replace("[post_category]", $category_list, $message_body);
182
+ $message_body = str_replace("[post_excerpt]", implode(", ", $the_post->post_excerpt), $message_body);
183
+ $message_body = str_replace("[post_status]", $the_post->post_status, $message_body);
184
+ $message_body = str_replace("[comment_status]", $the_post->comment_status, $message_body);
185
+ $message_body = str_replace("[ping_status]", $the_post->ping_status, $message_body);
186
+ $message_body = str_replace("[post_password]", $the_post->post_password, $message_body);
187
+ $message_body = str_replace("[post_name]", $the_post->post_name, $message_body);
188
+ $message_body = str_replace("[to_ping]", $the_post->to_ping, $message_body);
189
+ $message_body = str_replace("[pinged]", implode(", ", $the_post->pinged), $message_body);
190
+ $message_body = str_replace("[post_modified]", $the_post->post_modified, $message_body);
191
+ $message_body = str_replace("[post_modified_gmt]", $the_post->post_modified_gmt, $message_body);
192
+ $message_body = str_replace("[post_content_filtered]", $the_post->post_content_filtered, $message_body);
193
+ $message_body = str_replace("[post_parent]", $the_post->post_parent, $message_body);
194
+ $message_body = str_replace("[guid]", $the_post->guid, $message_body);
195
+ $message_body = str_replace("[menu_order]", $the_post->menu_order, $message_body);
196
+ $message_body = str_replace("[post_type]", $the_post->post_type, $message_body);
197
+ $message_body = str_replace("[post_mime_type]", $the_post->post_mime_type, $message_body);
198
+ $message_body = str_replace("[comment_count]", $the_post->comment_count, $message_body);
199
+
200
+ return $message_body;
201
+ }
202
+
203
+ function bnfw_get_subject_for_user_register($user_info){
204
+ $bnfw_options = get_option('bnfw_custom_email_settings');
205
+ $message_body = $bnfw_options['payload-subject-user_register'];
206
+
207
+ $message_body = str_replace("[ID]", $user_info->ID, $message_body);
208
+ $message_body = str_replace("[user_login]", $user_info->user_login, $message_body);
209
+ $message_body = str_replace("[user_nicename]", $user_info->user_nicename, $message_body);
210
+ $message_body = str_replace("[user_email]", $user_info->user_email, $message_body);
211
+ $message_body = str_replace("[user_url]", $user_info->user_url, $message_body);
212
+ $message_body = str_replace("[user_registered]", $user_info->user_registered, $message_body);
213
+ $message_body = str_replace("[display_name]", $user_info->display_name, $message_body);
214
+ $message_body = str_replace("[user_firstname]", $user_info->user_firstname, $message_body);
215
+ $message_body = str_replace("[user_lastname]", $user_info->user_lastname, $message_body);
216
+ $message_body = str_replace("[nickname]", $user_info->nickname, $message_body);
217
+ $message_body = str_replace("[user_description]", $user_info->user_description, $message_body);
218
+ $message_body = str_replace("[wp_capabilities]", implode(", ", $user_info->wp_capabilities), $message_body);
219
+ $message_body = str_replace("[admin_color]", $user_info->admin_color, $message_body);
220
+ $message_body = str_replace("[closedpostboxes_page]", $user_info->closedpostboxes_page, $message_body);
221
+ $message_body = str_replace("[primary_blog]", implode(", ", $user_info->primary_blog), $message_body);
222
+ $message_body = str_replace("[rich_editing]", $user_info->rich_editing, $message_body);
223
+ $message_body = str_replace("[source_domain]", $user_info->source_domain, $message_body);
224
+
225
+ return $message_body;
226
+ }
227
+
228
+ function bnfw_get_subject_for_trackback_post($the_comment){
229
+
230
+ $bnfw_options = get_option('bnfw_custom_email_settings');
231
+ $message_body = $bnfw_options['payload-subject-trackback_post'];
232
+ $user_info = get_userdata($the_comment->comment_author);
233
+
234
+ $message_body = str_replace("[comment_ID]", $the_comment->comment_ID, $message_body);
235
+ $message_body = str_replace("[comment_post_ID]", $the_comment->comment_post_ID, $message_body);
236
+ $message_body = str_replace("[comment_author]", $the_comment->comment_author, $message_body);
237
+ $message_body = str_replace("[comment_author_email]", $the_comment->comment_author_email, $message_body);
238
+ $message_body = str_replace("[comment_author_url]", $the_comment->comment_author_url, $message_body);
239
+ $message_body = str_replace("[comment_author_IP]", $the_comment->comment_author_IP, $message_body);
240
+ $message_body = str_replace("[comment_date]", $the_comment->comment_date, $message_body);
241
+ $message_body = str_replace("[comment_date_gmt]", $the_comment->comment_date_gmt, $message_body);
242
+ $message_body = str_replace("[comment_content]", $the_comment->comment_content, $message_body);
243
+ $message_body = str_replace("[comment_karma]", $the_comment->comment_karma, $message_body);
244
+ $message_body = str_replace("[comment_approved]", str_replace(array("0", "1", "spam"), array("awaiting moderation", "approved", "spam"), $the_comment->comment_approved), $message_body);
245
+ $message_body = str_replace("[comment_agent]", $the_comment->comment_agent, $message_body);
246
+ $message_body = str_replace("[comment_type]", $the_comment->comment_type, $message_body);
247
+ $message_body = str_replace("[comment_parent]", $the_comment->comment_parent, $message_body);
248
+ $message_body = str_replace("[user_id]", $the_comment->user_id, $message_body);
249
+
250
+ $message_body = str_replace("[user_login]", $user_info->user_login, $message_body);
251
+ $message_body = str_replace("[user_nicename]", $user_info->user_nicename, $message_body);
252
+ $message_body = str_replace("[user_email]", $user_info->user_email, $message_body);
253
+ $message_body = str_replace("[user_url]", $user_info->user_url, $message_body);
254
+ $message_body = str_replace("[user_registered]", $user_info->user_registered, $message_body);
255
+ $message_body = str_replace("[display_name]", $user_info->display_name, $message_body);
256
+ $message_body = str_replace("[user_firstname]", $user_info->user_firstname, $message_body);
257
+ $message_body = str_replace("[user_lastname]", $user_info->user_lastname, $message_body);
258
+ $message_body = str_replace("[nickname]", $user_info->nickname, $message_body);
259
+ $message_body = str_replace("[user_description]", $user_info->user_description, $message_body);
260
+ $message_body = str_replace("[wp_capabilities]", implode(", ", $user_info->wp_capabilities), $message_body);
261
+ $message_body = str_replace("[admin_color]", $user_info->admin_color, $message_body);
262
+ $message_body = str_replace("[closedpostboxes_page]", $user_info->closedpostboxes_page, $message_body);
263
+ $message_body = str_replace("[primary_blog]", implode(", ", $user_info->primary_blog), $message_body);
264
+ $message_body = str_replace("[rich_editing]", $user_info->rich_editing, $message_body);
265
+ $message_body = str_replace("[source_domain]", $user_info->source_domain, $message_body);
266
+
267
+ return $message_body;
268
+ }
269
+
270
+ function bnfw_get_subject_for_pingback_post($the_comment){
271
+ $bnfw_options = get_option('bnfw_custom_email_settings');
272
+ $message_body = $bnfw_options['payload-subject-pingback_post'];
273
+ $user_info = get_userdata($the_comment->comment_author);
274
+
275
+ $message_body = str_replace("[comment_ID]", $the_comment->comment_ID, $message_body);
276
+ $message_body = str_replace("[comment_post_ID]", $the_comment->comment_post_ID, $message_body);
277
+ $message_body = str_replace("[comment_author]", $the_comment->comment_author, $message_body);
278
+ $message_body = str_replace("[comment_author_email]", $the_comment->comment_author_email, $message_body);
279
+ $message_body = str_replace("[comment_author_url]", $the_comment->comment_author_url, $message_body);
280
+ $message_body = str_replace("[comment_author_IP]", $the_comment->comment_author_IP, $message_body);
281
+ $message_body = str_replace("[comment_date]", $the_comment->comment_date, $message_body);
282
+ $message_body = str_replace("[comment_date_gmt]", $the_comment->comment_date_gmt, $message_body);
283
+ $message_body = str_replace("[comment_content]", $the_comment->comment_content, $message_body);
284
+ $message_body = str_replace("[comment_karma]", $the_comment->comment_karma, $message_body);
285
+ $message_body = str_replace("[comment_approved]", str_replace(array("0", "1", "spam"), array("awaiting moderation", "approved", "spam"), $the_comment->comment_approved), $message_body);
286
+ $message_body = str_replace("[comment_agent]", $the_comment->comment_agent, $message_body);
287
+ $message_body = str_replace("[comment_type]", $the_comment->comment_type, $message_body);
288
+ $message_body = str_replace("[comment_parent]", $the_comment->comment_parent, $message_body);
289
+ $message_body = str_replace("[user_id]", $the_comment->user_id, $message_body);
290
+
291
+ $message_body = str_replace("[user_login]", $user_info->user_login, $message_body);
292
+ $message_body = str_replace("[user_nicename]", $user_info->user_nicename, $message_body);
293
+ $message_body = str_replace("[user_email]", $user_info->user_email, $message_body);
294
+ $message_body = str_replace("[user_url]", $user_info->user_url, $message_body);
295
+ $message_body = str_replace("[user_registered]", $user_info->user_registered, $message_body);
296
+ $message_body = str_replace("[display_name]", $user_info->display_name, $message_body);
297
+ $message_body = str_replace("[user_firstname]", $user_info->user_firstname, $message_body);
298
+ $message_body = str_replace("[user_lastname]", $user_info->user_lastname, $message_body);
299
+ $message_body = str_replace("[nickname]", $user_info->nickname, $message_body);
300
+ $message_body = str_replace("[user_description]", $user_info->user_description, $message_body);
301
+ $message_body = str_replace("[wp_capabilities]", implode(", ", $user_info->wp_capabilities), $message_body);
302
+ $message_body = str_replace("[admin_color]", $user_info->admin_color, $message_body);
303
+ $message_body = str_replace("[closedpostboxes_page]", $user_info->closedpostboxes_page, $message_body);
304
+ $message_body = str_replace("[primary_blog]", implode(", ", $user_info->primary_blog), $message_body);
305
+ $message_body = str_replace("[rich_editing]", $user_info->rich_editing, $message_body);
306
+ $message_body = str_replace("[source_domain]", $user_info->source_domain, $message_body);
307
+
308
+ return $message_body;
309
+ }
310
+
311
+ function bnfw_get_subject_for_lostpassword_post($user_info){
312
+ $bnfw_options = get_option('bnfw_custom_email_settings');
313
+ $message_body = $bnfw_options['payload-subject-lostpassword_post'];
314
+
315
+ $message_body = str_replace("[ID]", $user_info->ID, $message_body);
316
+ $message_body = str_replace("[user_login]", $user_info->user_login, $message_body);
317
+ $message_body = str_replace("[user_nicename]", $user_info->user_nicename, $message_body);
318
+ $message_body = str_replace("[user_email]", $user_info->user_email, $message_body);
319
+ $message_body = str_replace("[user_url]", $user_info->user_url, $message_body);
320
+ $message_body = str_replace("[user_registered]", $user_info->user_registered, $message_body);
321
+ $message_body = str_replace("[display_name]", $user_info->display_name, $message_body);
322
+ $message_body = str_replace("[user_firstname]", $user_info->user_firstname, $message_body);
323
+ $message_body = str_replace("[user_lastname]", $user_info->user_lastname, $message_body);
324
+ $message_body = str_replace("[nickname]", $user_info->nickname, $message_body);
325
+ $message_body = str_replace("[user_description]", $user_info->user_description, $message_body);
326
+ $message_body = str_replace("[wp_capabilities]", implode(", ", $user_info->wp_capabilities), $message_body);
327
+ $message_body = str_replace("[admin_color]", $user_info->admin_color, $message_body);
328
+ $message_body = str_replace("[closedpostboxes_page]", $user_info->closedpostboxes_page, $message_body);
329
+ $message_body = str_replace("[primary_blog]", implode(", ", $user_info->primary_blog), $message_body);
330
+ $message_body = str_replace("[rich_editing]", $user_info->rich_editing, $message_body);
331
+ $message_body = str_replace("[source_domain]", $user_info->source_domain, $message_body);
332
+
333
+ return $message_body;
334
+ }
335
+
336
+
337
+ /*
338
+ * Payload getters -----------------------------------------------
339
+ */
340
+
341
+ function bnfw_get_payload_for_publish_post($the_post){
342
+
343
+ $bnfw_options = get_option('bnfw_custom_email_settings');
344
+ $user_info = get_userdata($the_post->post_author);
345
+
346
+ $message_body = $bnfw_options['payload-body-publish_post'];
347
+
348
+ $message_body = str_replace("[ID]", $the_post->ID, $message_body);
349
+ $message_body = str_replace("[post_author]", $the_post->post_author, $message_body);
350
+ $message_body = str_replace("[post_date]", $the_post->post_date, $message_body);
351
+ $message_body = str_replace("[post_date_gmt]", $the_post->post_date_gmt, $message_body);
352
+ $message_body = str_replace("[post_content]", $the_post->post_content, $message_body);
353
+ $message_body = str_replace("[post_title]", $the_post->post_title, $message_body);
354
+ $category_list = "";
355
+
356
+ foreach ($the_post->post_category as $category_int){
357
+
358
+ $temp_term = get_term_by('id', $category_int, 'category'); $category_list .= $temp_term->name . ", ";
359
+
360
+ }
361
+
362
+ $message_body = str_replace("[post_category]", $category_list, $message_body);
363
+ $message_body = str_replace("[post_excerpt]", implode(", ", $the_post->post_excerpt), $message_body);
364
+ $message_body = str_replace("[post_status]", $the_post->post_status, $message_body);
365
+ $message_body = str_replace("[comment_status]", $the_post->comment_status, $message_body);
366
+ $message_body = str_replace("[ping_status]", $the_post->ping_status, $message_body);
367
+ $message_body = str_replace("[post_password]", $the_post->post_password, $message_body);
368
+ $message_body = str_replace("[post_name]", $the_post->post_name, $message_body);
369
+ $message_body = str_replace("[to_ping]", $the_post->to_ping, $message_body);
370
+ $message_body = str_replace("[pinged]", implode(", ", $the_post->pinged), $message_body);
371
+ $message_body = str_replace("[post_modified]", $the_post->post_modified, $message_body);
372
+ $message_body = str_replace("[post_modified_gmt]", $the_post->post_modified_gmt, $message_body);
373
+ $message_body = str_replace("[post_content_filtered]", $the_post->post_content_filtered, $message_body);
374
+ $message_body = str_replace("[post_parent]", $the_post->post_parent, $message_body);
375
+ $message_body = str_replace("[guid]", $the_post->guid, $message_body);
376
+ $message_body = str_replace("[menu_order]", $the_post->menu_order, $message_body);
377
+ $message_body = str_replace("[post_type]", $the_post->post_type, $message_body);
378
+ $message_body = str_replace("[post_mime_type]", $the_post->post_mime_type, $message_body);
379
+ $message_body = str_replace("[comment_count]", $the_post->comment_count, $message_body);
380
+
381
+ $message_body = str_replace("[user_login]", $user_info->user_login, $message_body);
382
+ $message_body = str_replace("[user_nicename]", $user_info->user_nicename, $message_body);
383
+ $message_body = str_replace("[user_email]", $user_info->user_email, $message_body);
384
+ $message_body = str_replace("[user_url]", $user_info->user_url, $message_body);
385
+ $message_body = str_replace("[user_registered]", $user_info->user_registered, $message_body);
386
+ $message_body = str_replace("[display_name]", $user_info->display_name, $message_body);
387
+ $message_body = str_replace("[user_firstname]", $user_info->user_firstname, $message_body);
388
+ $message_body = str_replace("[user_lastname]", $user_info->user_lastname, $message_body);
389
+ $message_body = str_replace("[nickname]", $user_info->nickname, $message_body);
390
+ $message_body = str_replace("[user_description]", $user_info->user_description, $message_body);
391
+ $message_body = str_replace("[wp_capabilities]", implode(", ", $user_info->wp_capabilities), $message_body);
392
+ $message_body = str_replace("[admin_color]", $user_info->admin_color, $message_body);
393
+ $message_body = str_replace("[closedpostboxes_page]", $user_info->closedpostboxes_page, $message_body);
394
+ $message_body = str_replace("[primary_blog]", implode(", ", $user_info->primary_blog), $message_body);
395
+ $message_body = str_replace("[rich_editing]", $user_info->rich_editing, $message_body);
396
+ $message_body = str_replace("[source_domain]", $user_info->source_domain, $message_body);
397
+
398
+ return $message_body;
399
+ }
400
+
401
+ function bnfw_get_payload_for_term_created($the_term){
402
+
403
+ $bnfw_options = get_option('bnfw_custom_email_settings');
404
+ $message_body = $bnfw_options['payload-body-create_term'];
405
+
406
+ $message_body = str_replace("[slug]", $the_term->slug, $message_body);
407
+ $message_body = str_replace("[name]", $the_term->name, $message_body);
408
+ $message_body = str_replace("[description]", $the_term->description, $message_body);
409
+
410
+ return $message_body;
411
+ }
412
+
413
+ function bnfw_get_payload_for_comment_post($the_comment){
414
+
415
+ $bnfw_options = get_option('bnfw_custom_email_settings');
416
+ $message_body = $bnfw_options['payload-body-comment_post'];
417
+ $user_info = get_userdata($the_comment->comment_author);
418
+ $the_post = get_post($the_comment->comment_post_ID);
419
+
420
+ $message_body = str_replace("[comment_ID]", $the_comment->comment_ID, $message_body);
421
+ $message_body = str_replace("[comment_post_ID]", $the_comment->comment_post_ID, $message_body);
422
+ $message_body = str_replace("[comment_author]", $the_comment->comment_author, $message_body);
423
+ $message_body = str_replace("[comment_author_email]", $the_comment->comment_author_email, $message_body);
424
+ $message_body = str_replace("[comment_author_url]", $the_comment->comment_author_url, $message_body);
425
+ $message_body = str_replace("[comment_author_IP]", $the_comment->comment_author_IP, $message_body);
426
+ $message_body = str_replace("[comment_date]", $the_comment->comment_date, $message_body);
427
+ $message_body = str_replace("[comment_date_gmt]", $the_comment->comment_date_gmt, $message_body);
428
+ $message_body = str_replace("[comment_content]", $the_comment->comment_content, $message_body);
429
+ $message_body = str_replace("[comment_karma]", $the_comment->comment_karma, $message_body);
430
+ $message_body = str_replace("[comment_approved]", str_replace(array("0", "1", "spam"), array("awaiting moderation", "approved", "spam"), $the_comment->comment_approved), $message_body);
431
+ $message_body = str_replace("[comment_agent]", $the_comment->comment_agent, $message_body);
432
+ $message_body = str_replace("[comment_type]", $the_comment->comment_type, $message_body);
433
+ $message_body = str_replace("[comment_parent]", $the_comment->comment_parent, $message_body);
434
+ $message_body = str_replace("[user_id]", $the_comment->user_id, $message_body);
435
+
436
+ $message_body = str_replace("[user_login]", $user_info->user_login, $message_body);
437
+ $message_body = str_replace("[user_nicename]", $user_info->user_nicename, $message_body);
438
+ $message_body = str_replace("[user_email]", $user_info->user_email, $message_body);
439
+ $message_body = str_replace("[user_url]", $user_info->user_url, $message_body);
440
+ $message_body = str_replace("[user_registered]", $user_info->user_registered, $message_body);
441
+ $message_body = str_replace("[display_name]", $user_info->display_name, $message_body);
442
+ $message_body = str_replace("[user_firstname]", $user_info->user_firstname, $message_body);
443
+ $message_body = str_replace("[user_lastname]", $user_info->user_lastname, $message_body);
444
+ $message_body = str_replace("[nickname]", $user_info->nickname, $message_body);
445
+ $message_body = str_replace("[user_description]", $user_info->user_description, $message_body);
446
+ $message_body = str_replace("[wp_capabilities]", implode(", ", $user_info->wp_capabilities), $message_body);
447
+ $message_body = str_replace("[admin_color]", $user_info->admin_color, $message_body);
448
+ $message_body = str_replace("[closedpostboxes_page]", $user_info->closedpostboxes_page, $message_body);
449
+ $message_body = str_replace("[primary_blog]", implode(", ", $user_info->primary_blog), $message_body);
450
+ $message_body = str_replace("[rich_editing]", $user_info->rich_editing, $message_body);
451
+ $message_body = str_replace("[source_domain]", $user_info->source_domain, $message_body);
452
+
453
+ $message_body = str_replace("[post_author]", $the_post->post_author, $message_body);
454
+ $message_body = str_replace("[post_date]", $the_post->post_date, $message_body);
455
+ $message_body = str_replace("[post_date_gmt]", $the_post->post_date_gmt, $message_body);
456
+ $message_body = str_replace("[post_content]", $the_post->post_content, $message_body);
457
+ $message_body = str_replace("[post_title]", $the_post->post_title, $message_body);
458
+ $category_list = "";
459
+
460
+ foreach ($the_post->post_category as $category_int){
461
+
462
+ $temp_term = get_term_by('id', $category_int, 'category'); $category_list .= $temp_term->name . ", ";
463
+
464
+ }
465
+
466
+ $message_body = str_replace("[post_category]", $category_list, $message_body);
467
+ $message_body = str_replace("[post_excerpt]", implode(", ", $the_post->post_excerpt), $message_body);
468
+ $message_body = str_replace("[post_status]", $the_post->post_status, $message_body);
469
+ $message_body = str_replace("[comment_status]", $the_post->comment_status, $message_body);
470
+ $message_body = str_replace("[ping_status]", $the_post->ping_status, $message_body);
471
+ $message_body = str_replace("[post_password]", $the_post->post_password, $message_body);
472
+ $message_body = str_replace("[post_name]", $the_post->post_name, $message_body);
473
+ $message_body = str_replace("[to_ping]", $the_post->to_ping, $message_body);
474
+ $message_body = str_replace("[pinged]", implode(", ", $the_post->pinged), $message_body);
475
+ $message_body = str_replace("[post_modified]", $the_post->post_modified, $message_body);
476
+ $message_body = str_replace("[post_modified_gmt]", $the_post->post_modified_gmt, $message_body);
477
+ $message_body = str_replace("[post_content_filtered]", $the_post->post_content_filtered, $message_body);
478
+ $message_body = str_replace("[post_parent]", $the_post->post_parent, $message_body);
479
+ $message_body = str_replace("[guid]", $the_post->guid, $message_body);
480
+ $message_body = str_replace("[menu_order]", $the_post->menu_order, $message_body);
481
+ $message_body = str_replace("[post_type]", $the_post->post_type, $message_body);
482
+ $message_body = str_replace("[post_mime_type]", $the_post->post_mime_type, $message_body);
483
+ $message_body = str_replace("[comment_count]", $the_post->comment_count, $message_body);
484
+
485
+ return $message_body;
486
+ }
487
+
488
+ function bnfw_get_payload_for_user_register($user_info){
489
+
490
+ $bnfw_options = get_option('bnfw_custom_email_settings');
491
+ $message_body = $bnfw_options['payload-body-user_register'];
492
+
493
+ $message_body = str_replace("[ID]", $user_info->ID, $message_body);
494
+ $message_body = str_replace("[user_login]", $user_info->user_login, $message_body);
495
+ $message_body = str_replace("[user_nicename]", $user_info->user_nicename, $message_body);
496
+ $message_body = str_replace("[user_email]", $user_info->user_email, $message_body);
497
+ $message_body = str_replace("[user_url]", $user_info->user_url, $message_body);
498
+ $message_body = str_replace("[user_registered]", $user_info->user_registered, $message_body);
499
+ $message_body = str_replace("[display_name]", $user_info->display_name, $message_body);
500
+ $message_body = str_replace("[user_firstname]", $user_info->user_firstname, $message_body);
501
+ $message_body = str_replace("[user_lastname]", $user_info->user_lastname, $message_body);
502
+ $message_body = str_replace("[nickname]", $user_info->nickname, $message_body);
503
+ $message_body = str_replace("[user_description]", $user_info->user_description, $message_body);
504
+ $message_body = str_replace("[wp_capabilities]", implode(", ", $user_info->wp_capabilities), $message_body);
505
+ $message_body = str_replace("[admin_color]", $user_info->admin_color, $message_body);
506
+ $message_body = str_replace("[closedpostboxes_page]", $user_info->closedpostboxes_page, $message_body);
507
+ $message_body = str_replace("[primary_blog]", implode(", ", $user_info->primary_blog), $message_body);
508
+ $message_body = str_replace("[rich_editing]", $user_info->rich_editing, $message_body);
509
+ $message_body = str_replace("[source_domain]", $user_info->source_domain, $message_body);
510
+
511
+ return $message_body;
512
+
513
+ }
514
+
515
+ function bnfw_get_payload_for_trackback_post($the_comment){$message_body = $bnfw_options['payload-body-comment_post'];
516
+
517
+ $bnfw_options = get_option('bnfw_custom_email_settings');
518
+ $message_body = $bnfw_options['payload-body-trackback_post'];
519
+ $user_info = get_userdata($the_comment->comment_author);
520
+
521
+ $message_body = str_replace("[comment_ID]", $the_comment->comment_ID, $message_body);
522
+ $message_body = str_replace("[comment_post_ID]", $the_comment->comment_post_ID, $message_body);
523
+ $message_body = str_replace("[comment_author]", $the_comment->comment_author, $message_body);
524
+ $message_body = str_replace("[comment_author_email]", $the_comment->comment_author_email, $message_body);
525
+ $message_body = str_replace("[comment_author_url]", $the_comment->comment_author_url, $message_body);
526
+ $message_body = str_replace("[comment_author_IP]", $the_comment->comment_author_IP, $message_body);
527
+ $message_body = str_replace("[comment_date]", $the_comment->comment_date, $message_body);
528
+ $message_body = str_replace("[comment_date_gmt]", $the_comment->comment_date_gmt, $message_body);
529
+ $message_body = str_replace("[comment_content]", $the_comment->comment_content, $message_body);
530
+ $message_body = str_replace("[comment_karma]", $the_comment->comment_karma, $message_body);
531
+ $message_body = str_replace("[comment_approved]", str_replace(array("0", "1", "spam"), array("awaiting moderation", "approved", "spam"), $the_comment->comment_approved), $message_body);
532
+ $message_body = str_replace("[comment_agent]", $the_comment->comment_agent, $message_body);
533
+ $message_body = str_replace("[comment_type]", $the_comment->comment_type, $message_body);
534
+ $message_body = str_replace("[comment_parent]", $the_comment->comment_parent, $message_body);
535
+ $message_body = str_replace("[user_id]", $the_comment->user_id, $message_body);
536
+
537
+ $message_body = str_replace("[user_login]", $user_info->user_login, $message_body);
538
+ $message_body = str_replace("[user_nicename]", $user_info->user_nicename, $message_body);
539
+ $message_body = str_replace("[user_email]", $user_info->user_email, $message_body);
540
+ $message_body = str_replace("[user_url]", $user_info->user_url, $message_body);
541
+ $message_body = str_replace("[user_registered]", $user_info->user_registered, $message_body);
542
+ $message_body = str_replace("[display_name]", $user_info->display_name, $message_body);
543
+ $message_body = str_replace("[user_firstname]", $user_info->user_firstname, $message_body);
544
+ $message_body = str_replace("[user_lastname]", $user_info->user_lastname, $message_body);
545
+ $message_body = str_replace("[nickname]", $user_info->nickname, $message_body);
546
+ $message_body = str_replace("[user_description]", $user_info->user_description, $message_body);
547
+ $message_body = str_replace("[wp_capabilities]", implode(", ", $user_info->wp_capabilities), $message_body);
548
+ $message_body = str_replace("[admin_color]", $user_info->admin_color, $message_body);
549
+ $message_body = str_replace("[closedpostboxes_page]", $user_info->closedpostboxes_page, $message_body);
550
+ $message_body = str_replace("[primary_blog]", implode(", ", $user_info->primary_blog), $message_body);
551
+ $message_body = str_replace("[rich_editing]", $user_info->rich_editing, $message_body);
552
+ $message_body = str_replace("[source_domain]", $user_info->source_domain, $message_body);
553
+
554
+ return $message_body;
555
+ }
556
+
557
+ function bnfw_get_payload_for_pingback_post($the_comment){
558
+
559
+ $bnfw_options = get_option('bnfw_custom_email_settings');
560
+ $message_body = $bnfw_options['payload-body-pingback_post'];
561
+ $user_info = get_userdata($the_comment->comment_author);
562
+
563
+ $message_body = str_replace("[comment_ID]", $the_comment->comment_ID, $message_body);
564
+ $message_body = str_replace("[comment_post_ID]", $the_comment->comment_post_ID, $message_body);
565
+ $message_body = str_replace("[comment_author]", $the_comment->comment_author, $message_body);
566
+ $message_body = str_replace("[comment_author_email]", $the_comment->comment_author_email, $message_body);
567
+ $message_body = str_replace("[comment_author_url]", $the_comment->comment_author_url, $message_body);
568
+ $message_body = str_replace("[comment_author_IP]", $the_comment->comment_author_IP, $message_body);
569
+ $message_body = str_replace("[comment_date]", $the_comment->comment_date, $message_body);
570
+ $message_body = str_replace("[comment_date_gmt]", $the_comment->comment_date_gmt, $message_body);
571
+ $message_body = str_replace("[comment_content]", $the_comment->comment_content, $message_body);
572
+ $message_body = str_replace("[comment_karma]", $the_comment->comment_karma, $message_body);
573
+ $message_body = str_replace("[comment_approved]", str_replace(array("0", "1", "spam"), array("awaiting moderation", "approved", "spam"), $the_comment->comment_approved), $message_body);
574
+ $message_body = str_replace("[comment_agent]", $the_comment->comment_agent, $message_body);
575
+ $message_body = str_replace("[comment_type]", $the_comment->comment_type, $message_body);
576
+ $message_body = str_replace("[comment_parent]", $the_comment->comment_parent, $message_body);
577
+ $message_body = str_replace("[user_id]", $the_comment->user_id, $message_body);
578
+
579
+ $message_body = str_replace("[user_login]", $user_info->user_login, $message_body);
580
+ $message_body = str_replace("[user_nicename]", $user_info->user_nicename, $message_body);
581
+ $message_body = str_replace("[user_email]", $user_info->user_email, $message_body);
582
+ $message_body = str_replace("[user_url]", $user_info->user_url, $message_body);
583
+ $message_body = str_replace("[user_registered]", $user_info->user_registered, $message_body);
584
+ $message_body = str_replace("[display_name]", $user_info->display_name, $message_body);
585
+ $message_body = str_replace("[user_firstname]", $user_info->user_firstname, $message_body);
586
+ $message_body = str_replace("[user_lastname]", $user_info->user_lastname, $message_body);
587
+ $message_body = str_replace("[nickname]", $user_info->nickname, $message_body);
588
+ $message_body = str_replace("[user_description]", $user_info->user_description, $message_body);
589
+ $message_body = str_replace("[wp_capabilities]", implode(", ", $user_info->wp_capabilities), $message_body);
590
+ $message_body = str_replace("[admin_color]", $user_info->admin_color, $message_body);
591
+ $message_body = str_replace("[closedpostboxes_page]", $user_info->closedpostboxes_page, $message_body);
592
+ $message_body = str_replace("[primary_blog]", implode(", ", $user_info->primary_blog), $message_body);
593
+ $message_body = str_replace("[rich_editing]", $user_info->rich_editing, $message_body);
594
+ $message_body = str_replace("[source_domain]", $user_info->source_domain, $message_body);
595
+
596
+ return $message_body;
597
+ }
598
+
599
+ function bnfw_get_payload_for_lostpassword_post($user_info){
600
+
601
+ $bnfw_options = get_option('bnfw_custom_email_settings');
602
+ $message_body = $bnfw_options['payload-body-lostpassword_post'];
603
+
604
+ $message_body = str_replace("[ID]", $user_info->ID, $message_body);
605
+ $message_body = str_replace("[user_login]", $user_info->user_login, $message_body);
606
+ $message_body = str_replace("[user_nicename]", $user_info->user_nicename, $message_body);
607
+ $message_body = str_replace("[user_email]", $user_info->user_email, $message_body);
608
+ $message_body = str_replace("[user_url]", $user_info->user_url, $message_body);
609
+ $message_body = str_replace("[user_registered]", $user_info->user_registered, $message_body);
610
+ $message_body = str_replace("[display_name]", $user_info->display_name, $message_body);
611
+ $message_body = str_replace("[user_firstname]", $user_info->user_firstname, $message_body);
612
+ $message_body = str_replace("[user_lastname]", $user_info->user_lastname, $message_body);
613
+ $message_body = str_replace("[nickname]", $user_info->nickname, $message_body);
614
+ $message_body = str_replace("[user_description]", $user_info->user_description, $message_body);
615
+ $message_body = str_replace("[wp_capabilities]", implode(", ", $user_info->wp_capabilities), $message_body);
616
+ $message_body = str_replace("[admin_color]", $user_info->admin_color, $message_body);
617
+ $message_body = str_replace("[closedpostboxes_page]", $user_info->closedpostboxes_page, $message_body);
618
+ $message_body = str_replace("[primary_blog]", implode(", ", $user_info->primary_blog), $message_body);
619
+ $message_body = str_replace("[rich_editing]", $user_info->rich_editing, $message_body);
620
+ $message_body = str_replace("[source_domain]", $user_info->source_domain, $message_body);
621
+
622
+ return $message_body;
623
+
624
+ }
625
+
626
+ ?>
includes/css/plugin_styles.css ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /******************************************************************
2
+ Stylesheet: Better Notifications for WordPress
3
+ ******************************************************************/
4
+
5
+ /*.wrap {
6
+ width: 100px;
7
+ }*/
8
+
9
+ .onecol { width: 5.801104972%; } /* 4.85%; } /* grid_1 */
10
+ .twocol { width: 14.364640883%; } /* 13.45%; } /* grid_2 */
11
+ .threecol { width: 22.928176794%; } /* 22.05%; } /* grid_3 */
12
+ .fourcol { width: 31.491712705%; } /* 30.75%; } /* grid_4 */
13
+ .fivecol { width: 40.055248616%; } /* 39.45%; } /* grid_5 */
14
+ .sixcol { width: 48.618784527%; } /* 48%; } /* grid_6 */
15
+ .sevencol { width: 57.182320438000005%; } /* 56.75%; } /* grid_7 */
16
+ .eightcol { width: 65.74585634900001%; } /* 65.4%; } /* grid_8 */
17
+ .ninecol { width: 74.30939226%; } /* 74.05%; } /* grid_9 */
18
+ .tencol { width: 82.87292817100001%; } /* 82.7%; } /* grid_10 */
19
+ .elevencol { width: 91.436464082%; } /* 91.35%; } /* grid_11 */
20
+ .twelvecol { width: 99.999999993%; } /* 100%; } /* grid_12 */
21
+
22
+ /* layout & column defaults */
23
+ .onecol, .twocol, .threecol, .fourcol, .fivecol, .sixcol, .sevencol, .eightcol, .ninecol, .tencol, .elevencol, .twelvecol {
24
+ position: relative;
25
+ float: left;
26
+ margin-left: 2.762430939%;
27
+ }
28
+
29
+ .first {
30
+ margin-left: 0;
31
+ }
32
+
33
+ .last {
34
+ float: right;
35
+ }
36
+
37
+ .row {
38
+ /* line-height: 25px;*/
39
+ }
40
+
41
+
42
+ /***** Clearfix *****/
43
+ .clearfix:before,
44
+ .clearfix:after {
45
+ content: " "; /* 1 */
46
+ display: table; /* 2 */
47
+ }
48
+
49
+ .clearfix:after {
50
+ clear: both;
51
+ }
52
+
53
+ .left {
54
+ float: left;
55
+ }
56
+
57
+ .right {
58
+ float: right;
59
+ }
60
+
61
+
62
+ /*******************
63
+ Admin Page Styling
64
+ *******************/
65
+
66
+ #paypal-donate {
67
+ margin: 10px 0 0 0;
68
+ }
69
+
70
+ #paypal-donate strong {
71
+ text-align: center;
72
+ margin-right: 20px;
73
+ }
74
+
75
+
76
+
77
+ /***** Notifications Page *****/
78
+
79
+ /* Other Options */
80
+ #other-options {
81
+ margin: 20px 0 50px 0;
82
+ }
83
+
84
+ #other-options label {
85
+ padding-right: 10px;
86
+ }
87
+
88
+ /* Grid of checkboxes on Settings page */
89
+ #role-settings {
90
+ margin: 20px 0;
91
+ }
92
+
93
+ #role-settings .twocol {
94
+ width: 8%;
95
+ }
96
+
97
+ #role-settings .row {
98
+ line-height: 25px;
99
+ }
100
+
101
+ #role-settings .event.row:nth-child(2n+1) {
102
+ background-color: #efefef;
103
+ }
104
+
105
+ /* Role labels on top row of settings page checkbox grid */
106
+ .role {
107
+ text-align: center;
108
+ }
109
+
110
+
111
+
112
+ /***** Email Templates Page *****/
113
+
114
+ /* Wrapper around email template form */
115
+ .bnfw-email-custom-form {
116
+ margin: 0 0 40px 0;
117
+ }
118
+
119
+ .bnfw-email-custom-form h3 {
120
+ background: #efefef;
121
+ margin: 0 0 0 0;
122
+ padding: 10px 5px;
123
+ }
124
+
125
+ .bnfw-email-custom-form label {
126
+ padding: 10px 0 5px 0;
127
+ font-weight: bold;
128
+ }
129
+
130
+ .bnfw-email-custom-form textarea {
131
+ width: 100% !important;
132
+ height: 250px;
133
+ }
134
+
135
+ /* Preview div */
136
+ .bnfw-preview {
137
+ background: #efefef;
138
+ margin: 10px;
139
+ width: 41.7%;
140
+ height: 318px;
141
+ overflow: scroll;
142
+ padding: 5px;
143
+ }