Subscribe2 - Version 9.0

Version Description

Download this release

Release Info

Developer MattyRob
Plugin Icon 128x128 Subscribe2
Version 9.0
Comparing to
See all releases

Code changes from version 8.9.1 to 9.0

ChangeLog.txt CHANGED
@@ -1,3 +1,37 @@
1
= Version 8.9.1 by Matthew Robinson =
2
3
* Check for the existence of the mb_encode_mimeheader function before use as it's optional in PHP builds - thanks to derekmacewen
@@ -13,6 +47,7 @@
13
* Fix internationalisation of subscribers list table - thanks to Milan Dinić
14
* Use mb_encode_mimeheader on email sender name - thanks to xl32
15
* Trim email addresses before sanitising them - thanks to byarts
16
17
= Version 8.8 by Matthew Robinson =
18
1
+ = Version 9.0 by Matthew Robinson =
2
+
3
+ * Added capability to send emails with attachments from Send Email page
4
+ * Added feature that removes unconfirmed public subscribers after 28 days (time frame can be altered with a filter)
5
+ * Added ability to bulk delete Registered Users/Subscribers
6
+ * Use {IMAGE} tag in HTML excerpt emails and digests only, images would be stripped in plain text and included anyway in full content HTML - applies to Subscribe2 HTML only
7
+ * Added help tabs on the plugins admin pages
8
+ * Improved the comparison of barred domains to subscribing email addresses - thanks to SashainSydney
9
+ * Added Text Domain to the plugin header to allow information on plugin page to translate - thanks to qwertysimo
10
+ * Applied a fix to ensure translation of all strings - thanks to qwertysimo
11
+ * Improved some strings to use sprintf() - thanks to Tom Adams (tomdxw)
12
+ * Use jQuery.noConflict(); when AJAX is enabled
13
+ * Removed excess span tag from the Counter Widget - thanks to dimagsv
14
+ * Allow filtering of admin email address for the emails sent when users confirm a subscription or unsubscription - suggested by 3cstudio
15
+ * Fixed default email notification subject text - thanks to Steve C @ 3Cstudio
16
+ * Fixed ability to have translation files in WP_LANG folder
17
+ * Fixed an issue with pagination of search results - thanks to sijpie
18
+ * Fixed 'Add Registered User' button in Subscribe2->Subscribers, Registered Tab - thanks to qwik3r
19
+ * Improved pages dropdown to an ordered and hierarchical display - thanks to xavierlh1
20
+ * Improved control over digest email scheduling - proposed by Jason Lemahieu
21
+ * Fixed Subscriber Dropdown counts for Compulsory categories
22
+ * Added a link to Tranlation files to the plugin page and the miscellaneous tab of the Subscribe2->Settings page - props eyephone21
23
+ * Added {KEYWORD} checking in the template to warn users of disallowed keywords - proposed by Jason Lemahieu
24
+ * Fixed some notices in the Send Email page - thanks to Bryan Hadaway (bhadaway)
25
+ * Added anti-spam measures to the sign up form - thanks to Bryan Hadaway (bhadaway)
26
+ * Update query_filter() function to hook into the 'request' filter instead of the deprecated 'query_filter'
27
+ * Added a default 'Select a page' option to the page dropdown to highlight the need to have a published page select
28
+ * Added filters to the subscription and unsubscription confirmation messages to allow personalisation - see FAQs for example functions
29
+ * Remove Simple Facebook Connect action during subscription and unsubscription confirmation to ensure user messages are displayed
30
+ * Improved white space stripping in the plaintext full content email
31
+ * Fixed a PHP notice on the Subscribe2->Subscribers page - thanks to emile.swain
32
+ * Fixes the non-working 'check all' boxes in WordPress 3.6 and above
33
+ * NOTE Version 9.0 needs WordPress 3.3 or above
34
+
35
= Version 8.9.1 by Matthew Robinson =
36
37
* Check for the existence of the mb_encode_mimeheader function before use as it's optional in PHP builds - thanks to derekmacewen
47
* Fix internationalisation of subscribers list table - thanks to Milan Dinić
48
* Use mb_encode_mimeheader on email sender name - thanks to xl32
49
* Trim email addresses before sanitising them - thanks to byarts
50
+ * Optimised the upgrade() function for large sites
51
52
= Version 8.8 by Matthew Robinson =
53
ReadMe.txt CHANGED
@@ -1,16 +1,15 @@
1
=== Subscribe2 ===
2
- Contributors: MattyRob, Skippy, RavanH
3
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2387904
4
Tags: posts, subscription, email, subscribe, notify, notification
5
- Requires at least: 3.1
6
- Tested up to: 3.5.1
7
- Stable tag: 8.9.1
8
License: GPL3
9
10
Sends a list of subscribers an email notification when new posts are published to your blog
11
12
== Description ==
13
-
14
Subscribe2 provides a comprehensive subscription management and email notification system for WordPress blogs that sends email notifications to a list of subscribers when you publish new content to your blog.
15
16
Email Notifications can be sent on a per-post basis or periodically in a Digest email. Additionally, certain categories can be excluded from inclusion in the notification and posts can be excluded on an individual basis by setting a custom field.
@@ -27,7 +26,6 @@ The format of the email can also be customised for per-post notifications, Subsc
27
If you want to send full content HTML emails to Public Subscribers too then upgrade to [Subscribe2 HTML](http://semperplugins.com/plugins/subscribe2-html/).
28
29
== Installation ==
30
-
31
AUTOMATIC INSTALLATION
32
33
1. Log in to your WordPress blog and visit Plugins->Add New.
@@ -53,9 +51,7 @@ This token will automatically be replaced by dynamic subscription information an
53
8. In the WordPress "Settings" area for Subscribe2 select the page name in the "Appearance" section that of the WordPress page created in step 7.
54
55
== Frequently Asked Questions ==
56
-
57
= I want HTML email to be the default email type =
58
-
59
You need to pay for the [Subscribe2 HTML version](http://semperplugins.com/plugins/subscribe2-html/).
60
61
= Where can I get help? =
@@ -65,12 +61,15 @@ Next you could search in the [WordPress forums](http://wordpress.org/support/),
65
66
If you can't find an answer then post a new topic at the [WordPress forums](http://wordpress.org/support/) or make a [donation](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2387904) to get my attention!
67
68
- = Where can I get more information about the plugin features? =
69
70
- A comprehensive guide that covers many, if not all, of the Subscribe2 features is available to purchase from the [My WP Works](http://mywpworks.com/store/subscribe2-ebook/)
71
72
- = Sending post notifications or email with Subscribe2 =
73
74
Subscribe2 sends an email at the very moment the post is published. Since Subscribe2 sends live mail with no un-do, it's important to use the Preview function in WordPress to make sure the post has been edited to perfection *before* moving it from Draft to Published mode.
75
76
Mail is sent when a post is published - it will not be re-sent if you Update the post later. If you need to send a mailing a second time (e.g. during testing), switch the post to Draft mode, then re-publish it.
@@ -78,7 +77,6 @@ Mail is sent when a post is published - it will not be re-sent if you Update the
78
You can also manually send emails to groups of your subscribers using the Send Email page that the plugin creates in the WordPress administration area.
79
80
= Where can I find the HTML and CSS templates? =
81
-
82
While the template field in Settings | Subscribe2 does not display HTML by default, feel free to add HTML to it as needed. You can insert references to static images for use as banners, wrap sections of the template in divs or other elements, or do whatever you like.
83
84
There is no need to include HTML header data or body tags - just focus on the HTML content, in conjunction with the template tags documented on the settings page.
@@ -107,15 +105,13 @@ Batches will occur for each group of message as described above. A site like th
107
**Restrictions on the number of messages sent**. In order to combat spam many hosts are now implementing time based limitations. This means you are only allowed to send a certain number of messages per unit time, 500 per hour for example. Subscribe2 does not have a work around for this inbuilt but see the next question.
108
109
= My host has a limit of X emails per hour / day, can I limit the way Subscribe2 sends emails? =
110
-
111
This is the second most common question I get asked (the first being about emails not being sent which quote often ends up here anyway!). This is more commonly called 'throttling' or 'choking'. PHP is a scripting language and while it is technically possible to throttle emails using script it is not very efficient. It is much better in terms of speed and server overhead (CPU cycles and RAM) to throttle using a server side application.
112
113
In the first instance you should try to solve the problem by speaking to your hosting provider about changing the restrictions, move to a less restricting hosting package or change hosting providers.
114
115
- If the above has not put you off then I spent some time writing a Mail Queue script for Subscribe2 that adds the mails to a database table and sends then in periodic batches. It is available, at a price, [here](http://wpplugins.com/plugin/76/wordpress-mail-queue-wpmq).
116
117
= My Digest emails fail to send, why? =
118
-
119
If you have already worked through all of the above email trouble shooting tips, and you are still not seeing your periodic digest emails send there may be an issue with the WordPress pseudo-cron functions on your server.
120
121
The pseudo-cron is WordPress is named after the cron jobs on servers. These are tasks that are run periodically to automate certain functions. In WordPress these tasks include checking for core and plugin updates, publishing scheduled posts and in the case of Subscribe2 sending the digest email. so, if the psuedo-cron is not working the email won't send.
@@ -123,7 +119,6 @@ The pseudo-cron is WordPress is named after the cron jobs on servers. These are
123
some reasons why your pseudo-cron may not be working are explained [here](http://wordpress.org/support/topic/296236#post-1175405). You can also try overcoming these by calling the wp-cron.php file directly and there are even [instructions](http://www.satollo.net/how-to-make-the-wordpress-cron-work) about how to set up a server cron job to do this periodically to restore WordPress pseudo-cron to a working state.
124
125
= I'd like to send the Digest email but on a different interval to the ones listed. Is this possible? =
126
-
127
Yes, this is possible, it just requires a little bit of code. Subscribe2 uses the intervals that are currently defined in WordPress (and by any plugins that create additional intervals), so all you need to do is add to the available intervals. Use code like this and simply change the interval time (in seconds) and description.
128
129
`function add_my_new_sched($sched) {
@@ -133,7 +128,6 @@ Yes, this is possible, it just requires a little bit of code. Subscribe2 uses th
133
add_filter('cron_schedules', 'add_my_new_sched');`
134
135
= I'd like to change the size of the image inserted by the {IMAGE} keyword in the paid version of the code. Is this possible? =
136
-
137
Yes, this is possible, it just requires a little bit of code. Subscribe2 introduced a filter in version 8.6 that allows on-the-fly customisation of the image size. Use the code below in a plugin of your own.
138
139
`function my_s2_image_size() {
@@ -149,21 +143,17 @@ Yes, this is possible, it just requires a little bit of code. Subscribe2 introdu
149
add_filter('s2_image_size', 'my_s2_image_size');`
150
151
= When I click on Send Preview in Susbcribe2->Settings I get 4 emails, why =
152
-
153
Subscribe2 supports 4 potential email formats for Susbcribers so you will get a preview for each of the different possibilities.
154
155
= Why do I need to create a WordPress Page =
156
-
157
Subscribe2 uses a filter system to display dynamic output to your readers. The token may result in the display of the subscription form, a subscription message, confirmation that an email has been sent, a prompt to log in. This information needs a static location for the output of the filter and a WordPress page is the ideal place for this to happen.
158
159
If you decide to use Subscribe2 only using the widget you must still have at least one WordPress page on your site for Subscribe2 to work correctly.
160
161
= Why is my admin address getting emails from Subscribe2? =
162
-
163
This plugin sends emails to your subscribers using the BCC (Blind Carbon Copy) header in email messages. Each email is sent TO: the admin address. There may be emails for a plain text excerpt notification, plain text full text and HTML format emails and additionally if the number of recipients per email has been set due to hosting restrictions duplicate copies of these emails will be sent to the admin address.
164
165
= I can't find my subscribers / the options / something else =
166
-
167
Subscribe2 creates four (4) new admin menus in the back end of WordPress. These are all under the top level menu header **Subscribe2**.
168
169
* Your Subscriptions : Allows the currently logged in user to manage their own subscriptions
@@ -174,7 +164,6 @@ Subscribe2 creates four (4) new admin menus in the back end of WordPress. These
174
**Note:** In versions of the plugin prior to version 7.0 the menus are under the WordPress system at Posts -> Mail Subscribers, Tools -> Subscribers, Users -> Subscriptions and Settings -> Subscribe2.
175
176
= I'm confused, what are all the different types of subscriber? =
177
-
178
There are basically only 2 types of subscriber. Public Subscribers and Registered Subscribers.
179
180
Public Subscribers have provided their email address for email notification of your new posts. When they enter there address on your site they are sent an email asking them to confirm their request and added to a list of Unconfirmed Subscribers. Once they complete their request by clicking on the link in their email they will become Confirmed Subscribers. They will receive a limited email notification when new post is made or periodically (unless that post is assigned to one of the excluded categories you defined). These Public Subscribers will receive a plaintext email with an excerpt of the post: either the excerpt you created when making the post, the portion of text before a <!--more--> tag (if present), or the first 50 words or so of the post.
@@ -184,15 +173,12 @@ Registered Users have registered with your WordPress blog (provided you have ena
184
**Note** You can send HTML emails to Public Subscribers with the paid [Subscribe2 HTML version](http://semperplugins.com/plugins/subscribe2-html/) of the plugin.
185
186
= Can I put the form elsewhere? (header, footer, sidebar without the widget) =
187
-
188
The simple answer is yes you can but this is not supported so you need to figure out any problems that are caused by doing this on your own. Read <a href="http://subscribe2.wordpress.com/2006/09/19/sidebar-without-a-widget/">here</a> for the basic approach.
189
190
= I'd like to be able to collect more information from users when they subscribe, can I? =
191
-
192
Get them to register with your blog rather than using the Subscribe2 form. Additional fields would require much more intensive form processing, checking and entry into the database and since you won't then be able to easily use this information to personalise emails there really isn't any point in collecting this data.
193
194
= How do I use the Subscribe2 shortcode? =
195
-
196
In version 6.1 of Subscribe2 the new standard WordPress shortcode [subscribe2] was introduced. By default, it behaves same as old Subscribe2 token, `<--subscribe2-->`, which means that it will show the same Subscribe2 output in your chosen page in WordPress or in the Widget.
197
198
But it also has advanced options, which are related to form. The default form contains two buttons for subscribing and unsubscribing. You may, for example, only want form that handles unsubscribing, so the shortcode accepts a **hide** parameter to hide one of the buttons.
@@ -208,21 +194,26 @@ There are many scenarios in which to use new options, but here is an example:
208
* In the Subscribe2 email template for new post, add text "You can unsubscribe on a following page:" which is followed with link to "Unsubscribe" page
209
210
= I can't find or insert the Subscribe2 token or shortcode, help! =
211
-
212
If, for some reason the Subscribe2 button does not appear in your browser window try refreshing your browser and cache (Shift and Reload in Firefox). If this still fails then insert the token manually. In the Rich Text Editor (TinyMCE) make sure you switch to the "code" view and type in [subscribe2] or <!--subscribe2-->.
213
214
= My digest email didn't send, how can I resend it? =
215
216
- In order to force sending you'd need to change the date of publication on the posts from last week or amend the date stamp in the database regarding when the posts should be included from.
217
-
218
- If you opt for the latter way look in the options table for the subscribe2_options settings (it's an array) and you'll need to change the 'last_s2cron' value to a timestamp for last week. Then force the cron event to run again with [WP-Crontrol](http://wordpress.org/extend/plugins/wp-crontrol/).
219
220
= I would really like Registered users to have the Subscription page themed like my site, is this possible? =
221
222
- Yes, it is. There is a small extension to Subscribe2 that delivers exactly this functionality. It is available from [Theme Tailors](http://stiofan.themetailors.com/store/products/tt-subscribe2-front-end-plugin/) for just $2.
223
224
- = How do I make use of the support for Custom Post Types =
225
226
In a plugin file for your site or perhaps functions.php in your theme add the following code where 'my_post_type' is change to the name of your custom post type.
227
228
`function my_post_types($types) {
@@ -232,7 +223,6 @@ In a plugin file for your site or perhaps functions.php in your theme add the fo
232
add_filter('s2_post_types', 'my_post_types');`
233
234
= How can I make use of the support for Custom Taxonomies =
235
-
236
In a plugin file for your site or perhaps functions.php in your theme add the following code where 'my_
237
taxonomy_type' is change to the name of your custom taxonomy type.
238
@@ -242,8 +232,22 @@ taxonomy_type' is change to the name of your custom taxonomy type.
242
}
243
add_filter('s2_taxonomies', 'my_taxonomy_types');`
244
245
- = How do I make use of the new option to AJAXify the form? =
246
247
The first thing you will need to do is visit the options page and enable the AJAX setting where it says "Enable AJAX style subscription form?", this will load the necessary javascript onto your WordPress site.
248
249
Next you need to decide if you want the link to be on a WordPress page or in your Sidebar with the Widget.
@@ -266,7 +270,6 @@ Well, you need to write a little code and provide a link to the Google API or Mi
266
add_filter('s2_jqueryui_css', 'custom_ajax_css');`
267
268
= I want to change the kinds of users who can access the Subscribe2 menus. Is that possible? =
269
-
270
Yes, it is possible with a little bit for code either in a custom plugin or your functions.php file in your theme. You use the add_filter() command that is part of WordPress to change the [capability](http://codex.wordpress.org/Roles_and_Capabilities#Capabilities) that allows access to each of the Subscribe2 menus.
271
272
`function s2_admin_changes( $capability, $menu ) {
@@ -288,8 +291,25 @@ Yes, it is possible with a little bit for code either in a custom plugin or your
288
289
add_filter('s2_capability', 's2_admin_changes', 10, 2);`
290
291
- = I want to change the email subject, how do I do that? =
292
293
You can change the email subject with the 's2_email_subject' filter. Something like this:
294
295
`function s2_subject_changes($subject) {
@@ -299,15 +319,12 @@ You can change the email subject with the 's2_email_subject' filter. Something l
299
add_filter('s2_email_subject', 's2_subject_changes');`
300
301
= Can I suggest you add X as a feature =
302
-
303
I'm open to suggestions but since the software is written by me for use on my site and then shared for free because others may find it useful as it comes don't expect your suggestion to be implemented unless I'll find it useful.
304
305
= I'd like to be able to send my subscribers notifications in HTML =
306
-
307
By default Public Subscribers get plain text emails and only Registered Subscribers can opt to receive email in HTML format. If you really want HTML for all you need to pay for the [Subscribe2 HTML version](http://semperplugins.com/plugins/subscribe2-html/).
308
309
= Which version should I be using, I'm on WordPress x.x.x? =
310
-
311
WordPress 3.1 and up requires Subscribe2 from the 7.x or 8.x stable branch. The most recent version is hosted via [Wordpress.org](http://wordpress.org/extend/plugins/subscribe2/).
312
313
WordPress 2.8 and up requires Subscribe2 from the 6.x stable branch. The most recent version is [6.5](http://downloads.wordpress.org/plugin/subscribe2.6.5.zip).
@@ -324,16 +341,13 @@ This is usually caused by one of two things. Firstly, it is possible that the fo
324
Secondly, make sure that the token ([subscribe2] or <!--subscribe2-->) is correctly entered in your page with a blank line above and below. The easiest way to do this is to deactivate the plugin, visit your WordPress page and view the source. The token should be contained in the source code of the page. If it is not there you either have not correctly entered the token or you have another plugin that is stripping the token from the page code.
325
326
== Screenshots ==
327
-
328
1. The Subscribe2->Mail Subscribers admin page generated by the plugin.
329
2. The Subscribe2->Subscribers admin page generated by the plugin.
330
3. The Subscribe2->Subscriptions admin page generated by the plugin.
331
4. The Subscribe2->Subscribe2 admin page generated by the plugin.
332
333
== Changelog ==
334
-
335
See [ChangeLog.txt](http://plugins.svn.wordpress.org/subscribe2/trunk/ChangeLog.txt)
336
337
== Upgrade Notice ==
338
-
339
See Version History
1
=== Subscribe2 ===
2
+ Contributors: MattyRob, Skippy, RavanH, bhadaway
3
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904
4
Tags: posts, subscription, email, subscribe, notify, notification
5
+ Requires at least: 3.3
6
+ Tested up to: 3.6.1
7
+ Stable tag: 9.0
8
License: GPL3
9
10
Sends a list of subscribers an email notification when new posts are published to your blog
11
12
== Description ==
13
Subscribe2 provides a comprehensive subscription management and email notification system for WordPress blogs that sends email notifications to a list of subscribers when you publish new content to your blog.
14
15
Email Notifications can be sent on a per-post basis or periodically in a Digest email. Additionally, certain categories can be excluded from inclusion in the notification and posts can be excluded on an individual basis by setting a custom field.
26
If you want to send full content HTML emails to Public Subscribers too then upgrade to [Subscribe2 HTML](http://semperplugins.com/plugins/subscribe2-html/).
27
28
== Installation ==
29
AUTOMATIC INSTALLATION
30
31
1. Log in to your WordPress blog and visit Plugins->Add New.
51
8. In the WordPress "Settings" area for Subscribe2 select the page name in the "Appearance" section that of the WordPress page created in step 7.
52
53
== Frequently Asked Questions ==
54
= I want HTML email to be the default email type =
55
You need to pay for the [Subscribe2 HTML version](http://semperplugins.com/plugins/subscribe2-html/).
56
57
= Where can I get help? =
61
62
If you can't find an answer then post a new topic at the [WordPress forums](http://wordpress.org/support/) or make a [donation](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2387904) to get my attention!
63
64
+ = Where can I get translation files for Subscribe2, and what do I do with them? =
65
+ All of the translation files I have been given are available at [http://plugins.trac.wordpress.org/browser/subscribe2/i18n/](http://plugins.trac.wordpress.org/browser/subscribe2/i18n/).
66
67
+ You need to download the *.mo file and place it on your server either in a folder called languages/ in the wp-content/plugins/subscribe2/ folder or you can place it in the subscribe2/ folder.
68
69
+ = What if there isn't a translation file for my language? =
70
+ If your language isn't list then you will need to make your own translation by use the *.pot file the is distributed with every release of the code. [This](http://codex.wordpress.org/Translating_WordPress) WordPress Codex page gives more background on how you make translation files.
71
72
+ = Sending post notifications or email with Subscribe2 =
73
Subscribe2 sends an email at the very moment the post is published. Since Subscribe2 sends live mail with no un-do, it's important to use the Preview function in WordPress to make sure the post has been edited to perfection *before* moving it from Draft to Published mode.
74
75
Mail is sent when a post is published - it will not be re-sent if you Update the post later. If you need to send a mailing a second time (e.g. during testing), switch the post to Draft mode, then re-publish it.
77
You can also manually send emails to groups of your subscribers using the Send Email page that the plugin creates in the WordPress administration area.
78
79
= Where can I find the HTML and CSS templates? =
80
While the template field in Settings | Subscribe2 does not display HTML by default, feel free to add HTML to it as needed. You can insert references to static images for use as banners, wrap sections of the template in divs or other elements, or do whatever you like.
81
82
There is no need to include HTML header data or body tags - just focus on the HTML content, in conjunction with the template tags documented on the settings page.
105
**Restrictions on the number of messages sent**. In order to combat spam many hosts are now implementing time based limitations. This means you are only allowed to send a certain number of messages per unit time, 500 per hour for example. Subscribe2 does not have a work around for this inbuilt but see the next question.
106
107
= My host has a limit of X emails per hour / day, can I limit the way Subscribe2 sends emails? =
108
This is the second most common question I get asked (the first being about emails not being sent which quote often ends up here anyway!). This is more commonly called 'throttling' or 'choking'. PHP is a scripting language and while it is technically possible to throttle emails using script it is not very efficient. It is much better in terms of speed and server overhead (CPU cycles and RAM) to throttle using a server side application.
109
110
In the first instance you should try to solve the problem by speaking to your hosting provider about changing the restrictions, move to a less restricting hosting package or change hosting providers.
111
112
+ If the above has not put you off then I spent some time writing a Mail Queue script for Subscribe2 that adds the mails to a database table and sends then in periodic batches. It is available, at a price, [here](http://semperplugins.com/plugins/wordpress-mail-queue-wpmq/).
113
114
= My Digest emails fail to send, why? =
115
If you have already worked through all of the above email trouble shooting tips, and you are still not seeing your periodic digest emails send there may be an issue with the WordPress pseudo-cron functions on your server.
116
117
The pseudo-cron is WordPress is named after the cron jobs on servers. These are tasks that are run periodically to automate certain functions. In WordPress these tasks include checking for core and plugin updates, publishing scheduled posts and in the case of Subscribe2 sending the digest email. so, if the psuedo-cron is not working the email won't send.
119
some reasons why your pseudo-cron may not be working are explained [here](http://wordpress.org/support/topic/296236#post-1175405). You can also try overcoming these by calling the wp-cron.php file directly and there are even [instructions](http://www.satollo.net/how-to-make-the-wordpress-cron-work) about how to set up a server cron job to do this periodically to restore WordPress pseudo-cron to a working state.
120
121
= I'd like to send the Digest email but on a different interval to the ones listed. Is this possible? =
122
Yes, this is possible, it just requires a little bit of code. Subscribe2 uses the intervals that are currently defined in WordPress (and by any plugins that create additional intervals), so all you need to do is add to the available intervals. Use code like this and simply change the interval time (in seconds) and description.
123
124
`function add_my_new_sched($sched) {
128
add_filter('cron_schedules', 'add_my_new_sched');`
129
130
= I'd like to change the size of the image inserted by the {IMAGE} keyword in the paid version of the code. Is this possible? =
131
Yes, this is possible, it just requires a little bit of code. Subscribe2 introduced a filter in version 8.6 that allows on-the-fly customisation of the image size. Use the code below in a plugin of your own.
132
133
`function my_s2_image_size() {
143
add_filter('s2_image_size', 'my_s2_image_size');`
144
145
= When I click on Send Preview in Susbcribe2->Settings I get 4 emails, why =
146
Subscribe2 supports 4 potential email formats for Susbcribers so you will get a preview for each of the different possibilities.
147
148
= Why do I need to create a WordPress Page =
149
Subscribe2 uses a filter system to display dynamic output to your readers. The token may result in the display of the subscription form, a subscription message, confirmation that an email has been sent, a prompt to log in. This information needs a static location for the output of the filter and a WordPress page is the ideal place for this to happen.
150
151
If you decide to use Subscribe2 only using the widget you must still have at least one WordPress page on your site for Subscribe2 to work correctly.
152
153
= Why is my admin address getting emails from Subscribe2? =
154
This plugin sends emails to your subscribers using the BCC (Blind Carbon Copy) header in email messages. Each email is sent TO: the admin address. There may be emails for a plain text excerpt notification, plain text full text and HTML format emails and additionally if the number of recipients per email has been set due to hosting restrictions duplicate copies of these emails will be sent to the admin address.
155
156
= I can't find my subscribers / the options / something else =
157
Subscribe2 creates four (4) new admin menus in the back end of WordPress. These are all under the top level menu header **Subscribe2**.
158
159
* Your Subscriptions : Allows the currently logged in user to manage their own subscriptions
164
**Note:** In versions of the plugin prior to version 7.0 the menus are under the WordPress system at Posts -> Mail Subscribers, Tools -> Subscribers, Users -> Subscriptions and Settings -> Subscribe2.
165
166
= I'm confused, what are all the different types of subscriber? =
167
There are basically only 2 types of subscriber. Public Subscribers and Registered Subscribers.
168
169
Public Subscribers have provided their email address for email notification of your new posts. When they enter there address on your site they are sent an email asking them to confirm their request and added to a list of Unconfirmed Subscribers. Once they complete their request by clicking on the link in their email they will become Confirmed Subscribers. They will receive a limited email notification when new post is made or periodically (unless that post is assigned to one of the excluded categories you defined). These Public Subscribers will receive a plaintext email with an excerpt of the post: either the excerpt you created when making the post, the portion of text before a <!--more--> tag (if present), or the first 50 words or so of the post.
173
**Note** You can send HTML emails to Public Subscribers with the paid [Subscribe2 HTML version](http://semperplugins.com/plugins/subscribe2-html/) of the plugin.
174
175
= Can I put the form elsewhere? (header, footer, sidebar without the widget) =
176
The simple answer is yes you can but this is not supported so you need to figure out any problems that are caused by doing this on your own. Read <a href="http://subscribe2.wordpress.com/2006/09/19/sidebar-without-a-widget/">here</a> for the basic approach.
177
178
= I'd like to be able to collect more information from users when they subscribe, can I? =
179
Get them to register with your blog rather than using the Subscribe2 form. Additional fields would require much more intensive form processing, checking and entry into the database and since you won't then be able to easily use this information to personalise emails there really isn't any point in collecting this data.
180
181
= How do I use the Subscribe2 shortcode? =
182
In version 6.1 of Subscribe2 the new standard WordPress shortcode [subscribe2] was introduced. By default, it behaves same as old Subscribe2 token, `<--subscribe2-->`, which means that it will show the same Subscribe2 output in your chosen page in WordPress or in the Widget.
183
184
But it also has advanced options, which are related to form. The default form contains two buttons for subscribing and unsubscribing. You may, for example, only want form that handles unsubscribing, so the shortcode accepts a **hide** parameter to hide one of the buttons.
194
* In the Subscribe2 email template for new post, add text "You can unsubscribe on a following page:" which is followed with link to "Unsubscribe" page
195
196
= I can't find or insert the Subscribe2 token or shortcode, help! =
197
If, for some reason the Subscribe2 button does not appear in your browser window try refreshing your browser and cache (Shift and Reload in Firefox). If this still fails then insert the token manually. In the Rich Text Editor (TinyMCE) make sure you switch to the "code" view and type in [subscribe2] or <!--subscribe2-->.
198
199
= My digest email didn't send, how can I resend it? =
200
+ If for some reason you wish to resend the last digest email you should find a Resend Digest button on the Subscribe2->Settings page under the Email Settings tab. If the button is not there then you are either in per-post mode or there isn't a previous digest to re-send.
201
202
+ In per post mode, to resend edit the post you want to re-send and change the status to draft and save, then publish the post again.
203
204
= I would really like Registered users to have the Subscription page themed like my site, is this possible? =
205
+ Yes, it is. There is a small extension to Subscribe2 that delivers exactly this functionality. It is available from [Theme Tailors](http://stiofan.themetailors.com/store/products/tt-subscribe2-front-end-plugin/) for just $5.
206
207
+ = I'd like to change the length of the excerpt included in the email notification. Can I do that? =
208
+ Yes, you can. There is a filter in Subscribe2 that allow you to change from the default of approximately 55 words. An example of the filter code you need would look like this:
209
210
+ `function my_excerpt() {
211
+ // return whatever number of words you want the excerpt length to be
212
+ return 30;
213
+ }
214
+ add_filter('s2_excerpt_length', 'my_excerpt');`
215
216
+ = How do I make use of the support for Custom Post Types =
217
In a plugin file for your site or perhaps functions.php in your theme add the following code where 'my_post_type' is change to the name of your custom post type.
218
219
`function my_post_types($types) {
223
add_filter('s2_post_types', 'my_post_types');`
224
225
= How can I make use of the support for Custom Taxonomies =
226
In a plugin file for your site or perhaps functions.php in your theme add the following code where 'my_
227
taxonomy_type' is change to the name of your custom taxonomy type.
228
232
}
233
add_filter('s2_taxonomies', 'my_taxonomy_types');`
234
235
+ = I want to personalise the message displayed when someone subscribes or unsubscribes, how do I do that? =
236
+ There is a filter for both of these in Subscribe2 from version 9.0 and upwards. To use it you need to create a little filter code plugin, an example is below:
237
238
+ `function subscribe_change($message) {
239
+ $message .= "<p>A warm welcome to our blog. We hope you enjoy our emails.</p>";
240
+ return $message;
241
+ }
242
+ add_filter('s2_subscribe_confirmed', 'subscribe_change');
243
+
244
+ function unsubscribe_change($message) {
245
+ $message .= "<p>We're sorry to see you leave, come back anytime.</p>";
246
+ return $message;
247
+ }
248
+ add_filter('s2_unsubscribe_confirmed', 'unsubscribe_change');`
249
+
250
+ = How do I make use of the new option to AJAXify the form? =
251
The first thing you will need to do is visit the options page and enable the AJAX setting where it says "Enable AJAX style subscription form?", this will load the necessary javascript onto your WordPress site.
252
253
Next you need to decide if you want the link to be on a WordPress page or in your Sidebar with the Widget.
270
add_filter('s2_jqueryui_css', 'custom_ajax_css');`
271
272
= I want to change the kinds of users who can access the Subscribe2 menus. Is that possible? =
273
Yes, it is possible with a little bit for code either in a custom plugin or your functions.php file in your theme. You use the add_filter() command that is part of WordPress to change the [capability](http://codex.wordpress.org/Roles_and_Capabilities#Capabilities) that allows access to each of the Subscribe2 menus.
274
275
`function s2_admin_changes( $capability, $menu ) {
291
292
add_filter('s2_capability', 's2_admin_changes', 10, 2);`
293
294
+ = I want to change the Administrator users that get notifications of new subscriptions and unsubscriptions, how do I do that? =
295
+ In Subscribe2->Settings you can turn off email notifications to Administrator level users when a Public Subscriber joins or leaves but what if you still want an email but to different people? Subscribe2 has a filter that allows you to add and remove users immediately before sending like this:
296
+
297
+ `function my_admin_filter($recipients = array(), $email) {
298
+ // $recipients is an array of admin email addresses
299
+ // $email will be 'subscribe' or 'unsubscribe'
300
+ if ($email == 'subscribe') {
301
+ foreach ($recipients as $key => $email) {
302
+ if ( $email == 'admin@mysite.com') {
303
+ unset($recipients[$key]);
304
+ }
305
+ }
306
+ $recipients[] = 'different.user@mysite.com';
307
+ }
308
+ return $recipients;
309
+ }
310
+ add_filter('s2_admin_email', 'my_admin_filter', 10, 2);`
311
312
+ = I want to change the email subject, how do I do that? =
313
You can change the email subject with the 's2_email_subject' filter. Something like this:
314
315
`function s2_subject_changes($subject) {
319
add_filter('s2_email_subject', 's2_subject_changes');`
320
321
= Can I suggest you add X as a feature =
322
I'm open to suggestions but since the software is written by me for use on my site and then shared for free because others may find it useful as it comes don't expect your suggestion to be implemented unless I'll find it useful.
323
324
= I'd like to be able to send my subscribers notifications in HTML =
325
By default Public Subscribers get plain text emails and only Registered Subscribers can opt to receive email in HTML format. If you really want HTML for all you need to pay for the [Subscribe2 HTML version](http://semperplugins.com/plugins/subscribe2-html/).
326
327
= Which version should I be using, I'm on WordPress x.x.x? =
328
WordPress 3.1 and up requires Subscribe2 from the 7.x or 8.x stable branch. The most recent version is hosted via [Wordpress.org](http://wordpress.org/extend/plugins/subscribe2/).
329
330
WordPress 2.8 and up requires Subscribe2 from the 6.x stable branch. The most recent version is [6.5](http://downloads.wordpress.org/plugin/subscribe2.6.5.zip).
341
Secondly, make sure that the token ([subscribe2] or <!--subscribe2-->) is correctly entered in your page with a blank line above and below. The easiest way to do this is to deactivate the plugin, visit your WordPress page and view the source. The token should be contained in the source code of the page. If it is not there you either have not correctly entered the token or you have another plugin that is stripping the token from the page code.
342
343
== Screenshots ==
344
1. The Subscribe2->Mail Subscribers admin page generated by the plugin.
345
2. The Subscribe2->Subscribers admin page generated by the plugin.
346
3. The Subscribe2->Subscriptions admin page generated by the plugin.
347
4. The Subscribe2->Subscribe2 admin page generated by the plugin.
348
349
== Changelog ==
350
See [ChangeLog.txt](http://plugins.svn.wordpress.org/subscribe2/trunk/ChangeLog.txt)
351
352
== Upgrade Notice ==
353
See Version History
admin/send_email.php CHANGED
@@ -40,18 +40,51 @@ if ( isset($_POST['s2_admin']) && 'mail' == $_POST['s2_admin'] ) {
40
global $user_email;
41
$recipients[] = $user_email;
42
}
43
- $status = $this->mail($recipients, $subject, $body, 'text');
44
if ( $status ) {
45
if ( isset($_POST['preview']) ) {
46
$message = "<p class=\"s2_message\">" . __('Preview message sent!', 'subscribe2') . "</p>";
47
} else {
48
$message = $this->mail_sent;
49
}
50
- } elseif ( empty($body) ) {
51
- $message = __('Your email was empty', 'subscribe2');
52
} else {
53
global $phpmailer;
54
- $message = $this->mail_failed . $phpmailer->ErrorInfo;
55
}
56
echo "<div id=\"message\" class=\"updated\"><strong><p>" . $message . "</p></strong></div>\r\n";
57
}
@@ -60,7 +93,7 @@ if ( isset($_POST['s2_admin']) && 'mail' == $_POST['s2_admin'] ) {
60
echo "<div class=\"wrap\">";
61
echo "<div id=\"icon-edit\" class=\"icon32\"></div>";
62
echo "<h2>" . __('Send an email to subscribers', 'subscribe2') . "</h2>\r\n";
63
- echo "<form method=\"post\">\r\n";
64
if ( function_exists('wp_nonce_field') ) {
65
wp_nonce_field('subscribe2-write_subscribers' . $s2nonce);
66
}
@@ -74,15 +107,27 @@ if ( !isset($_POST['content']) ) {
74
}
75
echo "<p>" . __('Subject', 'subscribe2') . ": <input type=\"text\" size=\"69\" name=\"subject\" value=\"" . $subject . "\" /> <br /><br />";
76
echo "<textarea rows=\"12\" cols=\"75\" name=\"content\">" . $body . "</textarea>";
77
echo "<br /><br />\r\n";
78
echo __('Recipients:', 'subscribe2') . " ";
79
$this->display_subscriber_dropdown('registered', false);
80
echo "<input type=\"hidden\" name=\"s2_admin\" value=\"mail\" />";
81
- echo "</p>";
82
echo "<p class=\"submit\"><input type=\"submit\" class=\"button-secondary\" name=\"preview\" value=\"" . __('Preview', 'subscribe2') . "\" />&nbsp;<input type=\"submit\" class=\"button-primary\" name=\"send\" value=\"" . __('Send', 'subscribe2') . "\" /></p>";
83
echo "</form></div>\r\n";
84
echo "<div style=\"clear: both;\"><p>&nbsp;</p></div>";
85
-
86
include(ABSPATH . 'wp-admin/admin-footer.php');
87
// just to be sure
88
die;
40
global $user_email;
41
$recipients[] = $user_email;
42
}
43
+
44
+ $uploads = array();
45
+ foreach ($_FILES['file']['name'] as $key => $value) {
46
+ if ( $_FILES['file']['error'][$key] === 0 ) {
47
+ $file = array(
48
+ 'name' => $_FILES['file']['name'][$key],
49
+ 'type' => $_FILES['file']['type'][$key],
50
+ 'tmp_name' => $_FILES['file']['tmp_name'][$key],
51
+ 'error' => $_FILES['file']['error'][$key],
52
+ 'size' => $_FILES['file']['size'][$key]
53
+ );
54
+ $uploads[] = wp_handle_upload($file, array('test_form' => false));
55
+ }
56
+ }
57
+ $attachments = array();
58
+ if ( !empty($uploads) ) {
59
+ foreach ( $uploads as $upload ) {
60
+ if ( !isset($upload['error']) ) {
61
+ $attachments[] = $upload['file'];
62
+ } else {
63
+ $upload_error = $upload['error'];
64
+ }
65
+ }
66
+ }
67
+
68
+ if ( empty($body) ) {
69
+ $error_message = __('Your email was empty', 'subscribe2');
70
+ $status = false;
71
+ } elseif ( isset($upload_error) ) {
72
+ $error_message = $upload_error;
73
+ $status = false;
74
+ } else {
75
+ $status = $this->mail($recipients, $subject, $body, 'text', $attachments);
76
+ $error_message = __('Check your settings and check with your hosting provider', 'subscribe2');
77
+ }
78
+
79
if ( $status ) {
80
if ( isset($_POST['preview']) ) {
81
$message = "<p class=\"s2_message\">" . __('Preview message sent!', 'subscribe2') . "</p>";
82
} else {
83
$message = $this->mail_sent;
84
}
85
} else {
86
global $phpmailer;
87
+ $message = $this->mail_failed . $error_message . $phpmailer->ErrorInfo;
88
}
89
echo "<div id=\"message\" class=\"updated\"><strong><p>" . $message . "</p></strong></div>\r\n";
90
}
93
echo "<div class=\"wrap\">";
94
echo "<div id=\"icon-edit\" class=\"icon32\"></div>";
95
echo "<h2>" . __('Send an email to subscribers', 'subscribe2') . "</h2>\r\n";
96
+ echo "<form method=\"post\" enctype=\"multipart/form-data\">\r\n";
97
if ( function_exists('wp_nonce_field') ) {
98
wp_nonce_field('subscribe2-write_subscribers' . $s2nonce);
99
}
107
}
108
echo "<p>" . __('Subject', 'subscribe2') . ": <input type=\"text\" size=\"69\" name=\"subject\" value=\"" . $subject . "\" /> <br /><br />";
109
echo "<textarea rows=\"12\" cols=\"75\" name=\"content\">" . $body . "</textarea>";
110
+ echo "<br /><div id=\"upload_files\"><input type=\"file\" name=\"file[]\"></div>\r\n";
111
+ echo "<input type=\"button\" class=\"button-secondary\" name=\"addmore\" value=\"" . __('Add More Files', 'subscribe2') . "\" onClick=\"add_file_upload();\" />\r\n";
112
echo "<br /><br />\r\n";
113
echo __('Recipients:', 'subscribe2') . " ";
114
$this->display_subscriber_dropdown('registered', false);
115
echo "<input type=\"hidden\" name=\"s2_admin\" value=\"mail\" />";
116
echo "<p class=\"submit\"><input type=\"submit\" class=\"button-secondary\" name=\"preview\" value=\"" . __('Preview', 'subscribe2') . "\" />&nbsp;<input type=\"submit\" class=\"button-primary\" name=\"send\" value=\"" . __('Send', 'subscribe2') . "\" /></p>";
117
echo "</form></div>\r\n";
118
echo "<div style=\"clear: both;\"><p>&nbsp;</p></div>";
119
+ ?>
120
+ <script type="text/javascript">
121
+ //<![CDATA[
122
+ function add_file_upload() {
123
+ var div = document.getElementById('upload_files');
124
+ var field = div.getElementsByTagName('input')[0];
125
+ div.appendChild(document.createElement("br"));
126
+ div.appendChild(field.cloneNode(false));
127
+ }
128
+ //]]>
129
+ </script>
130
+ <?php
131
include(ABSPATH . 'wp-admin/admin-footer.php');
132
// just to be sure
133
die;
admin/settings.php CHANGED
@@ -74,7 +74,10 @@ if ( isset( $_POST['s2_admin']) ) {
74
// send per-post or digest emails
75
$email_freq = $_POST['email_freq'];
76
$scheduled_time = wp_next_scheduled('s2_digest_cron');
77
- if ( $email_freq != $this->subscribe2_options['email_freq'] || $_POST['hour'] != date('H', wp_next_scheduled('s2_digest_cron')) ) {
78
$this->subscribe2_options['email_freq'] = $email_freq;
79
wp_clear_scheduled_hook('s2_digest_cron');
80
$scheds = (array)wp_get_schedules();
@@ -86,7 +89,11 @@ if ( isset( $_POST['s2_admin']) ) {
86
} else {
87
// if we are using digest schedule the event and prime last_cron as now
88
$time = time() + $interval;
89
- $timestamp = mktime($_POST['hour'], 0, 0, date('m', $time), date('d', $time), date('Y', $time));
90
while ($timestamp < time()) {
91
// if we are trying to set the time in the past increment it forward
92
// by the interval period until it is in the future
@@ -117,6 +124,21 @@ if ( empty($id) ) {
117
echo "<div id=\"page_message\" class=\"error\"><p class=\"s2_error\"><strong>$this->no_page</strong></p></div>";
118
}
119
120
// send error message if sender email address is off-domain
121
if ( $this->subscribe2_options['sender'] == 'blogname' ) {
122
$sender = get_bloginfo('admin_email');
@@ -160,7 +182,7 @@ switch ($current_tab) {
160
// settings for outgoing emails
161
echo "<div class=\"s2_admin\" id=\"s2_notification_settings\">\r\n";
162
echo "<p>\r\n";
163
- echo __('Restrict the number of recipients per email to (0 for unlimited)', 'subscribe2') . ': ';
164
echo "<span id=\"s2bcclimit_1\"><span id=\"s2bcclimit\" style=\"background-color: #FFFBCC\">" . $this->subscribe2_options['bcclimit'] . "</span> ";
165
echo "<a href=\"#\" onclick=\"s2_show('bcclimit'); return false;\">" . __('Edit', 'subscribe2') . "</a></span>\n";
166
echo "<span id=\"s2bcclimit_2\">\r\n";
@@ -220,11 +242,11 @@ switch ($current_tab) {
220
if ( function_exists('wp_schedule_event') ) {
221
echo __('Send Emails', 'subscribe2') . ": <br /><br />\r\n";
222
$this->display_digest_choices();
223
- echo __('For digest notifications, date order for posts is', 'subscribe2') . ": \r\n";
224
echo "<label><input type=\"radio\" name=\"cron_order\" value=\"desc\"" . checked($this->subscribe2_options['cron_order'], 'desc', false) . " /> ";
225
echo __('Descending', 'subscribe2') . "</label>&nbsp;&nbsp;";
226
echo "<label><input type=\"radio\" name=\"cron_order\" value=\"asc\"" . checked($this->subscribe2_options['cron_order'], 'asc', false) . " /> ";
227
- echo __('Ascending', 'subscribe2') . "</label><br /><br />\r\n";
228
}
229
echo __('Add Tracking Parameters to the Permalink', 'subscribe2') . ": ";
230
echo "<input type=\"text\" name=\"tracking\" value=\"" . stripslashes($this->subscribe2_options['tracking']) . "\" size=\"50\" /> ";
@@ -255,7 +277,7 @@ switch ($current_tab) {
255
echo "<dt><b>{POST}</b></dt><dd>" . __("the excerpt or the entire post<br />(<i>based on the subscriber's preferences</i>)", 'subscribe2') . "</dd>\r\n";
256
echo "<dt><b>{POSTTIME}</b></dt><dd>" . __("the excerpt of the post and the time it was posted<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
257
echo "<dt><b>{TABLE}</b></dt><dd>" . __("a list of post titles<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
258
- echo "<dt><b>{TABLELINKS}</b></dt><dd>" . __("a list of post titles followed by links to the atricles<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
259
echo "<dt><b>{PERMALINK}</b></dt><dd>" . __("the post's permalink<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
260
echo "<dt><b>{TINYLINK}</b></dt><dd>" . __("the post's permalink after conversion by TinyURL", 'subscribe2') . "</dd>\r\n";
261
echo "<dt><b>{DATE}</b></dt><dd>" . __("the date the post was made<br />(<i>for per-post emails only</i>)", "subscribe2") . "</dd>\r\n";
@@ -437,6 +459,7 @@ switch ($current_tab) {
437
echo "</p>";
438
echo "<h3>" . __('Links', 'subscribe2') . "</h3>\r\n";
439
echo "<a href=\"http://wordpress.org/extend/plugins/subscribe2/\">" . __('Plugin Site', 'subscribe2') . "</a><br />";
440
echo "<a href=\"http://wordpress.org/support/plugin/subscribe2\">" . __('Plugin Forum', 'subscribe2') . "</a><br />";
441
echo "<a href=\"http://subscribe2.wordpress.com/\">" . __('Plugin Blog', 'subscribe2') . "</a><br />";
442
echo "<a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904\">" . __('Make a donation via PayPal', 'subscribe2') . "</a>";
74
// send per-post or digest emails
75
$email_freq = $_POST['email_freq'];
76
$scheduled_time = wp_next_scheduled('s2_digest_cron');
77
+ $timestamp_offset = get_option('gmt_offset') * 60 * 60;
78
+ $crondate = (isset($_POST['crondate'])) ? $_POST['crondate'] : 0;
79
+ $crontime = (isset($_POST['crondate'])) ? $_POST['crontime'] : 0;
80
+ if ( $email_freq != $this->subscribe2_options['email_freq'] || $crondate != date_i18n(get_option('date_format'), $scheduled_time + $timestamp_offset) || $crontime != date('G', $scheduled_time + $timestamp_offset) ) {
81
$this->subscribe2_options['email_freq'] = $email_freq;
82
wp_clear_scheduled_hook('s2_digest_cron');
83
$scheds = (array)wp_get_schedules();
89
} else {
90
// if we are using digest schedule the event and prime last_cron as now
91
$time = time() + $interval;
92
+ $srttimestamp = strtotime($crondate) + ($crontime * 60 * 60);
93
+ if ( $srttimestamp === false || $srttimestamp === 0 ) {
94
+ $srttimestamp == time();
95
+ }
96
+ $timestamp = $srttimestamp - $timestamp_offset;
97
while ($timestamp < time()) {
98
// if we are trying to set the time in the past increment it forward
99
// by the interval period until it is in the future
124
echo "<div id=\"page_message\" class=\"error\"><p class=\"s2_error\"><strong>$this->no_page</strong></p></div>";
125
}
126
127
+ if ( $this->subscribe2_options['email_freq'] != 'never' ) {
128
+ $disallowed_keywords = array('{TITLE}', '{PERMALINK}', '{DATE}', '{TIME}', '{LINK}', '{ACTION}');
129
+ } else {
130
+ $disallowed_keywords = array('{POSTTIME}', '{TABLE}', '{TABLELINKS}', '{COUNT}', '{LINK}', '{ACTION}');
131
+ }
132
+ $disallowed = false;
133
+ foreach ( $disallowed_keywords as $disallowed_keyword ) {
134
+ if ( strstr($this->subscribe2_options['mailtext'], $disallowed_keyword) !== false ) {
135
+ $disallowed[] = $disallowed_keyword;
136
+ }
137
+ }
138
+ if ( $disallowed !== false ) {
139
+ echo "<div id=\"keyword_message\" class=\"error\"><p class=\"s2_error\"><strong>$this->disallowed_keywords</strong><br>" . implode($disallowed, ', ') . "</p></div>";
140
+ }
141
+
142
// send error message if sender email address is off-domain
143
if ( $this->subscribe2_options['sender'] == 'blogname' ) {
144
$sender = get_bloginfo('admin_email');
182
// settings for outgoing emails
183
echo "<div class=\"s2_admin\" id=\"s2_notification_settings\">\r\n";
184
echo "<p>\r\n";
185
+ echo __('Restrict the number of <strong>recipients per email</strong> to (0 for unlimited)', 'subscribe2') . ': ';
186
echo "<span id=\"s2bcclimit_1\"><span id=\"s2bcclimit\" style=\"background-color: #FFFBCC\">" . $this->subscribe2_options['bcclimit'] . "</span> ";
187
echo "<a href=\"#\" onclick=\"s2_show('bcclimit'); return false;\">" . __('Edit', 'subscribe2') . "</a></span>\n";
188
echo "<span id=\"s2bcclimit_2\">\r\n";
242
if ( function_exists('wp_schedule_event') ) {
243
echo __('Send Emails', 'subscribe2') . ": <br /><br />\r\n";
244
$this->display_digest_choices();
245
+ echo "<p>" . __('For digest notifications, date order for posts is', 'subscribe2') . ": \r\n";
246
echo "<label><input type=\"radio\" name=\"cron_order\" value=\"desc\"" . checked($this->subscribe2_options['cron_order'], 'desc', false) . " /> ";
247
echo __('Descending', 'subscribe2') . "</label>&nbsp;&nbsp;";
248
echo "<label><input type=\"radio\" name=\"cron_order\" value=\"asc\"" . checked($this->subscribe2_options['cron_order'], 'asc', false) . " /> ";
249
+ echo __('Ascending', 'subscribe2') . "</label></p>\r\n";
250
}
251
echo __('Add Tracking Parameters to the Permalink', 'subscribe2') . ": ";
252
echo "<input type=\"text\" name=\"tracking\" value=\"" . stripslashes($this->subscribe2_options['tracking']) . "\" size=\"50\" /> ";
277
echo "<dt><b>{POST}</b></dt><dd>" . __("the excerpt or the entire post<br />(<i>based on the subscriber's preferences</i>)", 'subscribe2') . "</dd>\r\n";
278
echo "<dt><b>{POSTTIME}</b></dt><dd>" . __("the excerpt of the post and the time it was posted<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
279
echo "<dt><b>{TABLE}</b></dt><dd>" . __("a list of post titles<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
280
+ echo "<dt><b>{TABLELINKS}</b></dt><dd>" . __("a list of post titles followed by links to the articles<br />(<i>for digest emails only</i>)", 'subscribe2') . "</dd>\r\n";
281
echo "<dt><b>{PERMALINK}</b></dt><dd>" . __("the post's permalink<br />(<i>for per-post emails only</i>)", 'subscribe2') . "</dd>\r\n";
282
echo "<dt><b>{TINYLINK}</b></dt><dd>" . __("the post's permalink after conversion by TinyURL", 'subscribe2') . "</dd>\r\n";
283
echo "<dt><b>{DATE}</b></dt><dd>" . __("the date the post was made<br />(<i>for per-post emails only</i>)", "subscribe2") . "</dd>\r\n";
459
echo "</p>";
460
echo "<h3>" . __('Links', 'subscribe2') . "</h3>\r\n";
461
echo "<a href=\"http://wordpress.org/extend/plugins/subscribe2/\">" . __('Plugin Site', 'subscribe2') . "</a><br />";
462
+ echo "<a href='http://plugins.trac.wordpress.org/browser/subscribe2/i18n/'>" . __('Translation Files', 'subscribe2') . "</a><br />";
463
echo "<a href=\"http://wordpress.org/support/plugin/subscribe2\">" . __('Plugin Forum', 'subscribe2') . "</a><br />";
464
echo "<a href=\"http://subscribe2.wordpress.com/\">" . __('Plugin Blog', 'subscribe2') . "</a><br />";
465
echo "<a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904\">" . __('Make a donation via PayPal', 'subscribe2') . "</a>";
admin/subscribers.php CHANGED
@@ -5,6 +5,9 @@ if ( !function_exists('add_action') ) {
5
6
global $wpdb, $subscribers, $what, $current_tab;
7
8
// was anything POSTed ?
9
if ( isset($_POST['s2_admin']) ) {
10
check_admin_referer('bulk-subscribers');
@@ -37,12 +40,29 @@ if ( isset($_POST['s2_admin']) ) {
37
}
38
echo $message;
39
$_POST['what'] = 'confirmed';
40
- } elseif ( $_POST['action'] === 'delete' || $_POST['action2'] === 'delete' ) {
41
- foreach ( $_POST['subscriber'] as $address ) {
42
- $this->delete($address);
43
}
44
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) deleted!', 'subscribe2') . "</strong></p></div>";
45
- } elseif ( $_POST['action'] === 'toggle' || $_POST['action2'] === 'toggle' ) {
46
global $current_user;
47
$this->ip = $current_user->user_login;
48
foreach ( $_POST['subscriber'] as $address ) {
@@ -67,8 +87,6 @@ if ( isset($_POST['s2_admin']) ) {
67
}
68
}
69
70
- // detect or define which tab we are in
71
- $current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'public';
72
if ( $current_tab == 'registered' ) {
73
// Get Registered Subscribers
74
$registered = $this->get_registered();
@@ -120,13 +138,22 @@ if ( isset($_REQUEST['what']) ) {
120
}
121
}
122
123
- if ( !empty($_POST['s']) ) {
124
- foreach ( $subscribers as $subscriber ) {
125
- if ( is_numeric(stripos($subscriber, $_POST['s'])) ) {
126
- $result[] = $subscriber;
127
}
128
}
129
- $subscribers = $result;
130
}
131
132
if ( !class_exists('WP_List_Table') ) {
@@ -178,7 +205,7 @@ switch ($current_tab) {
178
case 'registered':
179
echo "<div class=\"s2_admin\" id=\"s2_add_subscribers\">\r\n";
180
echo "<h2>" . __('Add/Remove Subscribers', 'subscribe2') . "</h2>\r\n";
181
- echo "<p class=\"submit\" style=\"border-top: none;\"><input type=\"button\" class=\"button-primary\" name=\"add_user\" value=\"" . __('Add Registered User', 'subscribe2') . "\" formaction=\"" . admin_url() . "user-new.php\" /></p>\r\n";
182
183
echo "</div>\r\n";
184
5
6
global $wpdb, $subscribers, $what, $current_tab;
7
8
+ // detect or define which tab we are in
9
+ $current_tab = isset( $_GET['tab'] ) ? esc_attr($_GET['tab']) : 'public';
10
+
11
// was anything POSTed ?
12
if ( isset($_POST['s2_admin']) ) {
13
check_admin_referer('bulk-subscribers');
40
}
41
echo $message;
42
$_POST['what'] = 'confirmed';
43
+ } elseif ( (isset($_POST['action']) && $_POST['action'] === 'delete') || (isset($_POST['action2']) && $_POST['action2'] === 'delete') ) {
44
+ if ( $current_tab === 'public' ) {
45
+ foreach ( $_POST['subscriber'] as $address ) {
46
+ $this->delete($address);
47
+ }
48
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . __('Address(es) deleted!', 'subscribe2') . "</strong></p></div>";
49
+ } elseif ( $current_tab === 'registered' ) {
50
+ global $current_user;
51
+ $users_deleted_error = '';
52
+ $users_deleted = '';
53
+ foreach ( $_POST['subscriber'] as $address ) {
54
+ $user = get_user_by('email', $address);
55
+ if ( !current_user_can('delete_user', $user->ID) || $user->ID == $current_user->ID ) {
56
+ $users_deleted_error = __('Delete failed! You cannot delete some or all of these users', 'subscribe2') . "<br />";
57
+ continue;
58
+ } else {
59
+ $users_deleted = __('User(s) deleted! Any posts made by these users were assigned to you', 'subscribe2');
60
+ //wp_delete_user($user->$id, $current_user->ID);
61
+ }
62
+ }
63
+ echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . $users_deleted_error . $users_deleted . "</strong></p></div>";
64
}
65
+ } elseif ( (isset($_POST['action']) && $_POST['action'] === 'toggle') || (isset($_POST['action2']) && $_POST['action2'] === 'toggle') ) {
66
global $current_user;
67
$this->ip = $current_user->user_login;
68
foreach ( $_POST['subscriber'] as $address ) {
87
}
88
}
89
90
if ( $current_tab == 'registered' ) {
91
// Get Registered Subscribers
92
$registered = $this->get_registered();
138
}
139
}
140
141
+ if ( !empty($_REQUEST['s']) ) {
142
+ if ( !empty($_POST['s']) ) {
143
+ foreach ( $subscribers as $subscriber ) {
144
+ if ( is_numeric(stripos($subscriber, $_POST['s'])) ) {
145
+ $result[] = $subscriber;
146
+ }
147
+ }
148
+ $subscribers = $result;
149
+ } else {
150
+ foreach ( $subscribers as $subscriber ) {
151
+ if ( is_numeric(stripos($subscriber, $_REQUEST['s'])) ) {
152
+ $result[] = $subscriber;
153
+ }
154
}
155
+ $subscribers = $result;
156
}
157
}
158
159
if ( !class_exists('WP_List_Table') ) {
205
case 'registered':
206
echo "<div class=\"s2_admin\" id=\"s2_add_subscribers\">\r\n";
207
echo "<h2>" . __('Add/Remove Subscribers', 'subscribe2') . "</h2>\r\n";
208
+ echo "<p class=\"submit\" style=\"border-top: none;\"><a class=\"button-primary\" href=\"" . admin_url() . "user-new.php\">" . __('Add Registered User', 'subscribe2') . "</a></p>\r\n";
209
210
echo "</div>\r\n";
211
classes/class-s2-admin.php CHANGED
@@ -10,20 +10,120 @@ class s2_admin extends s2class {
10
$s2user = add_submenu_page('s2', __('Your Subscriptions', 'subscribe2'), __('Your Subscriptions', 'subscribe2'), apply_filters('s2_capability', "read", 'user'), 's2', array(&$this, 'user_menu'), S2URL . 'include/email_edit.png');
11
add_action("admin_print_scripts-$s2user", array(&$this, 'checkbox_form_js'));
12
add_action("admin_print_styles-$s2user", array(&$this, 'user_admin_css'));
13
14
$s2subscribers = add_submenu_page('s2', __('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), apply_filters('s2_capability', "manage_options", 'manage'), 's2_tools', array(&$this, 'subscribers_menu'));
15
add_action("admin_print_scripts-$s2subscribers", array(&$this, 'checkbox_form_js'));
16
17
$s2settings = add_submenu_page('s2', __('Settings', 'subscribe2'), __('Settings', 'subscribe2'), apply_filters('s2_capability', "manage_options", 'settings'), 's2_settings', array(&$this, 'settings_menu'));
18
add_action("admin_print_scripts-$s2settings", array(&$this, 'checkbox_form_js'));
19
add_action("admin_print_scripts-$s2settings", array(&$this, 'option_form_js'));
20
add_filter('plugin_row_meta', array(&$this, 'plugin_links'), 10, 2);
21
22
- add_submenu_page('s2', __('Send Email', 'subscribe2'), __('Send Email', 'subscribe2'), apply_filters('s2_capability', "publish_posts", 'send'), 's2_posts', array(&$this, 'write_menu'));
23
24
$s2nonce = wp_hash('subscribe2');
25
} // end admin_menu()
26
27
/**
28
Hook for Admin Drop Down Icons
29
*/
@@ -35,7 +135,7 @@ class s2_admin extends s2class {
35
Insert Javascript and CSS into admin_header
36
*/
37
function checkbox_form_js() {
38
- wp_register_script('s2_checkbox', S2URL . 'include/s2_checkbox' . $this->script_debug . '.js', array('jquery'), '1.2');
39
wp_enqueue_script('s2_checkbox');
40
} //end checkbox_form_js()
41
@@ -47,6 +147,10 @@ class s2_admin extends s2class {
47
function option_form_js() {
48
wp_register_script('s2_edit', S2URL . 'include/s2_edit' . $this->script_debug . '.js', array('jquery'), '1.1');
49
wp_enqueue_script('s2_edit');
50
} // end option_form_js()
51
52
/**
@@ -55,6 +159,7 @@ class s2_admin extends s2class {
55
function plugin_links($links, $file) {
56
if ( $file == S2DIR.'subscribe2.php' ) {
57
$links[] = "<a href='admin.php?page=s2_settings'>" . __('Settings', 'subscribe2') . "</a>";
58
$links[] = "<a href='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904'><b>" . __('Donate', 'subscribe2') . "</b></a>";
59
}
60
return $links;
@@ -102,12 +207,7 @@ class s2_admin extends s2class {
102
add_filter('mce_external_plugins', array(&$this, 'mce3_plugin'));
103
add_filter('mce_buttons', array(&$this, 'mce3_button'));
104
} else {
105
- if ( version_compare($this->wp_release, '3.3', '<') ) {
106
- wp_enqueue_script('subscribe2_button', S2URL . 'include/s2_button' . $this->script_debug . '.js', array('quicktags'), '1.0' );
107
- } else {
108
- // use QTags.addButton for WordPress 3.3 and greater
109
- wp_enqueue_script('subscribe2_button', S2URL . 'include/s2_button2' . $this->script_debug . '.js', array('quicktags'), '2.0' );
110
- }
111
}
112
} // end button_init()
113
@@ -134,7 +234,7 @@ class s2_admin extends s2class {
134
if ( stripos($_SERVER['REQUEST_URI'], 'widgets.php' ) !== false ) {
135
wp_enqueue_style('farbtastic');
136
wp_enqueue_script('farbtastic');
137
- wp_register_script('s2_colorpicker', S2URL . 'include/s2_colorpicker' . $this->script_debug . '.js', array('farbtastic'), '1.0'); //my js
138
wp_enqueue_script('s2_colorpicker');
139
}
140
} // end widget_s2_counter_css_and_js()
@@ -183,6 +283,42 @@ class s2_admin extends s2class {
183
} // end s2_meta_box_handler()
184
185
/* ===== WordPress menu helper functions ===== */
186
/**
187
Display a table of categories with checkboxes
188
Optionally pre-select those categories specified
@@ -375,20 +511,29 @@ class s2_admin extends s2class {
375
$count['all_users'] = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");
376
}
377
if ( $this->s2_mu ) {
378
- $count['registered'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key='" . $wpdb->prefix . "capabilities' AND meta_key=%s", $this->get_usermeta_keyname('s2_subscribed')));
379
} else {
380
- $count['registered'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key=%s", $this->get_usermeta_keyname('s2_subscribed')));
381
}
382
$count['all'] = ($count['confirmed'] + $count['unconfirmed'] + $count['all_users']);
383
// get subscribers to individual categories but only if we are using per-post notifications
384
if ( $this->subscribe2_options['email_freq'] == 'never' ) {
385
if ( $this->s2_mu ) {
386
foreach ( $all_cats as $cat ) {
387
- $count[$cat->name] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(a.meta_key) FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id WHERE a.meta_key='" . $wpdb->prefix . "capabilities' AND b.meta_key=%s", $this->get_usermeta_keyname('s2_cat') . $cat->term_id));
388
}
389
} else {
390
foreach ( $all_cats as $cat ) {
391
- $count[$cat->name] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key=%s", $this->get_usermeta_keyname('s2_cat') . $cat->term_id));
392
}
393
}
394
}
@@ -484,26 +629,34 @@ class s2_admin extends s2class {
484
echo "<label><input type=\"radio\" name=\"email_freq\" value=\"" . $key . "\"" . checked($this->subscribe2_options['email_freq'], $key, false) . " />";
485
echo " " . $value['display'] . "</label><br />\r\n";
486
}
487
- echo "<br />" . __('Send Digest Notification at UTC', 'subscribe2') . ": \r\n";
488
- $hours = array('12am', '1am', '2am', '3am', '4am', '5am', '6am', '7am', '8am', '9am', '10am', '11am', '12pm', '1pm', '2pm', '3pm', '4pm', '5pm', '6pm', '7pm', '8pm', '9pm', '10pm', '11pm');
489
- echo "<select name=\"hour\">\r\n";
490
- foreach ( $hours as $key => $value ) {
491
- echo "<option value=\"" . $key . "\"";
492
- if ( !empty($scheduled_time) && $key == date('H', $scheduled_time) ) {
493
- echo " selected=\"selected\"";
494
- }
495
- echo ">" . $value . "</option>\r\n";
496
- }
497
- echo "</select>\r\n";
498
- echo "<strong><em style=\"color: red\">" . __('Chosen time will be scheduled to a future date in relation to the current UTC time', 'subscribe2') . "</em></strong>\r\n";
499
if ( $scheduled_time ) {
500
- $datetime = get_option('date_format') . ' @ ' . get_option('time_format');
501
echo "<p>" . __('Current UTC time is', 'subscribe2') . ": \r\n";
502
- echo "<strong>" . date_i18n($datetime, false, 'gmt') . "</strong></p>\r\n";
503
echo "<p>" . __('Current blog time is', 'subscribe2') . ": \r\n";
504
- echo "<strong>" . date_i18n($datetime) . "</strong></p>\r\n";
505
echo "<p>" . __('Next email notification will be sent when your blog time is after', 'subscribe2') . ": \r\n";
506
- echo "<strong>" . date_i18n($datetime, $scheduled_time + $offset) . "</strong></p>\r\n";
507
if ( !empty($this->subscribe2_options['previous_s2cron']) ) {
508
echo "<p>" . __('Attempt to resend the last Digest Notification email', 'subscribe2') . ": ";
509
echo "<input type=\"submit\" class=\"button-secondary\" name=\"resend\" value=\"" . __('Resend Digest', 'subscribe2') . "\" /></p>\r\n";
@@ -517,19 +670,23 @@ class s2_admin extends s2class {
517
Create and display a dropdown list of pages
518
*/
519
function pages_dropdown($s2page) {
520
- global $wpdb;
521
- $sql = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type='page' AND post_status='publish'";
522
- $pages = $wpdb->get_results($sql);
523
-
524
if ( empty($pages) ) { return; }
525
526
- $option = '';
527
foreach ( $pages as $page ) {
528
$option .= "<option value=\"" . $page->ID . "\"";
529
if ( $page->ID == $s2page ) {
530
$option .= " selected=\"selected\"";
531
}
532
- $option .= ">" . $page->post_title . "</option>\r\n";
533
}
534
535
echo $option;
@@ -665,9 +822,21 @@ class s2_admin extends s2class {
665
*/
666
function new_category($new_category='') {
667
if ( 'no' == $this->subscribe2_options['show_autosub'] ) { return; }
668
- // don't subscribe to individual new categories if we are doing digest emails
669
- if ( $this->subscribe2_options['email_freq'] != 'never' ) { return; }
670
global $wpdb;
671
672
if ( 'yes' == $this->subscribe2_options['show_autosub'] ) {
673
if ( $this->s2_mu ) {
10
$s2user = add_submenu_page('s2', __('Your Subscriptions', 'subscribe2'), __('Your Subscriptions', 'subscribe2'), apply_filters('s2_capability', "read", 'user'), 's2', array(&$this, 'user_menu'), S2URL . 'include/email_edit.png');
11
add_action("admin_print_scripts-$s2user", array(&$this, 'checkbox_form_js'));
12
add_action("admin_print_styles-$s2user", array(&$this, 'user_admin_css'));
13
+ add_action('load-' . $s2user, array(&$this, 'user_help'));
14
15
$s2subscribers = add_submenu_page('s2', __('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), apply_filters('s2_capability', "manage_options", 'manage'), 's2_tools', array(&$this, 'subscribers_menu'));
16
add_action("admin_print_scripts-$s2subscribers", array(&$this, 'checkbox_form_js'));
17
+ add_action('load-' . $s2subscribers, array(&$this, 'subscribers_help'));
18
19
$s2settings = add_submenu_page('s2', __('Settings', 'subscribe2'), __('Settings', 'subscribe2'), apply_filters('s2_capability', "manage_options", 'settings'), 's2_settings', array(&$this, 'settings_menu'));
20
add_action("admin_print_scripts-$s2settings", array(&$this, 'checkbox_form_js'));
21
add_action("admin_print_scripts-$s2settings", array(&$this, 'option_form_js'));
22
add_filter('plugin_row_meta', array(&$this, 'plugin_links'), 10, 2);
23
+ add_action('load-' . $s2settings, array(&$this, 'settings_help'));
24
25
+ $s2mail = add_submenu_page('s2', __('Send Email', 'subscribe2'), __('Send Email', 'subscribe2'), apply_filters('s2_capability', "publish_posts", 'send'), 's2_posts', array(&$this, 'write_menu'));
26
+ add_action('load-' . $s2mail, array(&$this, 'mail_help'));
27
28
$s2nonce = wp_hash('subscribe2');
29
} // end admin_menu()
30
31
+ /**
32
+ Contextual Help
33
+ */
34
+ function user_help() {
35
+ $screen = get_current_screen();
36
+ if ( $this->subscribe2_options['email_freq'] != 'never' ) {
37
+ $screen->add_help_tab(array(
38
+ 'id' => 's2-user-help1',
39
+ 'title' => __('Overview', 'subscribe2'),
40
+ 'content' => '<p>' . __('From this page you can opt in or out of receiving a periodical digest style email of blog posts.', 'subscribe2') . '</p>'
41
+ ));
42
+ } else {
43
+ $screen->add_help_tab(array(
44
+ 'id' => 's2-user-help1',
45
+ 'title' => __('Overview', 'subscribe2'),
46
+ 'content' => '<p>' . __('From this page you can control your subscription preferences. Choose the email format you wish to receive, which categories you would like to receive notification for and depending on the site settings which authors you would like to read.', 'subscribe2') . '</p>'
47
+ ));
48
+ }
49
+ } // end user_help()
50
+
51
+ function subscribers_help() {
52
+ $screen = get_current_screen();
53
+ $screen->add_help_tab(array(
54
+ 'id' => 's2-subscribers-help1',
55
+ 'title' => __('Overview', 'subscribe2'),
56
+ 'content' => '<p>' . __('From this page you can manage your subscribers.', 'subscribe2') . '</p>'
57
+ ));
58
+ $screen->add_help_tab(array(
59
+ 'id' => 's2-subscribers-help2',
60
+ 'title' => __('Public Subscribers', 'subscribe2'),
61
+ 'content' => '<p>' . __('Public Subscribers are subscribers who have used the plugin form and only provided their email address.', 'subscribe2') . '</p><p>'. __('On this page public subscribers can be viewed, searched, deleted and also toggled between Confirmed and Unconfirmed status.', 'subscribe2') . '</p>'
62
+ ));
63
+ $screen->add_help_tab(array(
64
+ 'id' => 's2-subscribers-help3',
65
+ 'title' => __('Registered Subscribers', 'subscribe2'),
66
+ 'content' => '<p>' . __('Registered Subscribers are subscribers who have registered in WordPress and have a username and password.', 'subscribe2') .
67
+ '</p><p>'. __('Registered Subscribers have greater personal control over their subscription. They can change the format of the email and also select which categories and authors they want to receive notifications about.', 'subscribe2') .
68
+ '</p><p>'. __('On this page registered subscribers can be viewed and searched. User accounts can be deleted from here with any posts created by those users being assigned to the currently logged in user. Bulk changes can be applied to all user settings changing their subscription email format and categories.', 'subscribe2') . '</p>'
69
+ ));
70
+ } // end subscribers_help()
71
+
72
+ function settings_help() {
73
+ $screen = get_current_screen();
74
+ $screen->add_help_tab(array(
75
+ 'id' => 's2-settings-help1',
76
+ 'title' => __('Overview', 'subscribe2'),
77
+ 'content' => '<p>' . __('From this page you can adjust the Settings for Subscribe2.', 'subscribe2') . '</p>'
78
+ ));
79
+ $screen->add_help_tab(array(
80
+ 'id' => 's2-settings-help2',
81
+ 'title' => __('Email Settings', 'subscribe2'),
82
+ 'content' => '<p>' . __('This section allows you to specify settings that apply to the emails generated by the site.', 'subscribe2') .
83
+ '</p><p>'. __('Emails can be sent to individual subscribers by setting the number of recipients per email to 1. A setting greater than one will group recipients together and make use of the BCC emails header. A setting of 0 sends a single email with all subscribers in one large BCC group. A setting of 1 looks less like spam email to filters but takes longer to process.', 'subscribe2').
84
+ '</p><p>'. __('This section is also where the sender of the email on this page is chosen. You can choose Post Author or your Blogname but it is recommended to create a user account with an email address that really exists and shares the same domain name as your site (the bit after the @ should be the same as your sites web address) and then use this account.', 'subscribe2') .
85
+ '</p><p>'. __('This page also configures the frequency of emails. This can be at the time new posts are made (per post) or periodically with an excerpt of each post made (digest). Additionally the post types (pages, private, password protected) can also be configured here.', 'subscribe2') . '</p>'
86
+ ));
87
+ $screen->add_help_tab(array(
88
+ 'id' => 's2-settings-help3',
89
+ 'title' => __('Templates', 'subscribe2'),
90
+ 'content' => '<p>' . __('This section allows you to customise the content of your notification emails.', 'subscribe2') .
91
+ '</p><p>'. __('There are special {KEYWORDS} that are used by Subscribe2 to place content into the final email. The template also accept regular text and HTML as desired in the final emaisl.', 'subscribe2') .
92
+ '</p><p>'. __('The {KEYWORDS} are listed on the right of the templates, note that some are for per post emails only and some are for digest emails only. Make sure the correct keywords are used based upon the Email Settings.', 'subscribe2') . '</p>'
93
+ ));
94
+ $screen->add_help_tab(array(
95
+ 'id' => 's2-settings-help4',
96
+ 'title' => __('Registered Users', 'subscribe2'),
97
+ 'content' => '<p>' . __('This section allows settings that apply to Registered Subscribers to be configured.', 'subscribe2') .
98
+ '</p><p>'. __('Categories can be made compulsory so emails are always sent for posts in these categories. They can also be excludes so that emails are not generated. Excluded categories take precedence over Compulsory categories.', 'subscribe2') .
99
+ '</p><p>'. __('A set of default settings for new users can also be specified using the Auto Subscribe section. Settings specified here will be applied to any newly created user accounts while Subscribe2 is activated.', 'subscribe2') . '</p>'
100
+ ));
101
+ $screen->add_help_tab(array(
102
+ 'id' => 's2-settings-help5',
103
+ 'title' => __('Appearance', 'subscribe2'),
104
+ 'content' => '<p>' . __('This section allows you to enable several aspect of the plugin such as Widgets and editor buttons.', 'subscribe2') .
105
+ '</p><p>'. __('AJAX mode can be enabled that is intended to work with the shortcode link parameter so that a dialog opens in the centre of the browser rather then using the regular form.', 'subscribe2') .
106
+ '</p><p>'. __('The email over ride check box can be set to be automatically checked for every new post and page from here to, this may be useful if you will only want to send very occasional notifications for specific posts. You can then uncheck this box just before you publish your content.', 'subscribe2') . '</p>'
107
+ ));
108
+ $screen->add_help_tab(array(
109
+ 'id' => 's2-settings-help6',
110
+ 'title' => __('Miscellaneous', 'subscribe2'),
111
+ 'content' => '<p>' . __('This section contains a place to bar specified domains from becoming Public Subscribers and links to help and support pages.', 'subscribe2') .
112
+ '</p><p>'. __('In the paid Subscribe2 HTML version there is also a place here to enter a license code so that updates can be accessed automatically.', 'subscribe2') .
113
+ '</p>'
114
+ ));
115
+ } // end settings_help()
116
+
117
+ function mail_help() {
118
+ $screen = get_current_screen();
119
+ $screen->add_help_tab(array(
120
+ 'id' => 's2-send-mail-help1',
121
+ 'title' => __('Overview', 'subscribe2'),
122
+ 'content' => '<p>' . __('From this page you can send emails to the recipients in the group selected in the drop down.', 'subscribe2') .
123
+ '</p><p>' . __('<strong>Preview</strong> will send a preview of the email to the currently logged in user. <strong>Send</strong> will send the email to the recipient list.', 'subscribe2') . '</p>'
124
+ ));
125
+ } // end send_email_help()
126
+
127
/**
128
Hook for Admin Drop Down Icons
129
*/
135
Insert Javascript and CSS into admin_header
136
*/
137
function checkbox_form_js() {
138
+ wp_register_script('s2_checkbox', S2URL . 'include/s2_checkbox' . $this->script_debug . '.js', array('jquery'), '1.3');
139
wp_enqueue_script('s2_checkbox');
140
} //end checkbox_form_js()
141
147
function option_form_js() {
148
wp_register_script('s2_edit', S2URL . 'include/s2_edit' . $this->script_debug . '.js', array('jquery'), '1.1');
149
wp_enqueue_script('s2_edit');
150
+ wp_enqueue_script('jquery-ui-datepicker');
151
+ wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.css');
152
+ wp_register_script('s2_date_time', S2URL . 'include/s2_date_time' . $this->script_debug . '.js', array('jquery-ui-datepicker'), '1.0');
153
+ wp_enqueue_script('s2_date_time');
154
} // end option_form_js()
155
156
/**
159
function plugin_links($links, $file) {
160
if ( $file == S2DIR.'subscribe2.php' ) {
161
$links[] = "<a href='admin.php?page=s2_settings'>" . __('Settings', 'subscribe2') . "</a>";
162
+ $links[] = "<a href='http://plugins.trac.wordpress.org/browser/subscribe2/i18n/'>" . __('Translation Files', 'subscribe2') . "</a>";
163
$links[] = "<a href='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2387904'><b>" . __('Donate', 'subscribe2') . "</b></a>";
164
}
165
return $links;
207
add_filter('mce_external_plugins', array(&$this, 'mce3_plugin'));
208
add_filter('mce_buttons', array(&$this, 'mce3_button'));
209
} else {
210
+ wp_enqueue_script('subscribe2_button', S2URL . 'include/s2_button' . $this->script_debug . '.js', array('quicktags'), '2.0' );
211
}
212
} // end button_init()
213
234
if ( stripos($_SERVER['REQUEST_URI'], 'widgets.php' ) !== false ) {
235
wp_enqueue_style('farbtastic');
236
wp_enqueue_script('farbtastic');
237
+ wp_register_script('s2_colorpicker', S2URL . 'include/s2_colorpicker' . $this->script_debug . '.js', array('farbtastic'), '1.1'); //my js
238
wp_enqueue_script('s2_colorpicker');
239
}
240
} // end widget_s2_counter_css_and_js()
283
} // end s2_meta_box_handler()
284
285
/* ===== WordPress menu helper functions ===== */
286
+ /**
287
+ Collects the signup date for all public subscribers
288
+ */
289
+ function signup_date($email = '') {
290
+ if ( '' == $email ) { return false; }
291
+
292
+ global $wpdb;
293
+ if ( !empty($this->signup_dates) ) {
294
+ return $this->signup_dates[$email];
295
+ } else {
296
+ $results = $wpdb->get_results("SELECT email, date FROM $this->public", ARRAY_N);
297
+ foreach ( $results as $result ) {
298
+ $this->signup_dates[$result[0]] = $result[1];
299
+ }
300
+ return $this->signup_dates[$email];
301
+ }
302
+ } // end signup_date()
303
+
304
+ /**
305
+ Collects the ip address for all public subscribers
306
+ */
307
+ function signup_ip($email = '') {
308
+ if ( '' == $email ) {return false; }
309
+
310
+ global $wpdb;
311
+ if ( !empty($this->signup_ips) ) {
312
+ return $this->signup_ips[$email];
313
+ } else {
314
+ $results = $wpdb->get_results("SELECT email, ip FROM $this->public", ARRAY_N);
315
+ foreach ( $results as $result ) {
316
+ $this->signup_ips[$result[0]] = $result[1];
317
+ }
318
+ return $this->signup_ips[$email];
319
+ }
320
+ } // end signup_ip()
321
+
322
/**
323
Display a table of categories with checkboxes
324
Optionally pre-select those categories specified
511
$count['all_users'] = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");
512
}
513
if ( $this->s2_mu ) {
514
+ $count['registered'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(b.meta_key) FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id WHERE a.meta_key='" . $wpdb->prefix . "capabilities' AND b.meta_key=%s AND b.meta_value <> ''", $this->get_usermeta_keyname('s2_subscribed')));
515
} else {
516
+ $count['registered'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(meta_key) FROM $wpdb->usermeta WHERE meta_key=%s AND meta_value <> ''", $this->get_usermeta_keyname('s2_subscribed')));
517
}
518
$count['all'] = ($count['confirmed'] + $count['unconfirmed'] + $count['all_users']);
519
// get subscribers to individual categories but only if we are using per-post notifications
520
if ( $this->subscribe2_options['email_freq'] == 'never' ) {
521
+ $compulsory = explode(',', $this->subscribe2_options['compulsory']);
522
if ( $this->s2_mu ) {
523
foreach ( $all_cats as $cat ) {
524
+ if ( in_array($cat->term_id, $compulsory) ) {
525
+ $count[$cat->name] = $count['all_users'];
526
+ } else {
527
+ $count[$cat->name] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(a.meta_key) FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id WHERE a.meta_key='" . $wpdb->prefix . "capabilities' AND b.meta_key=%s", $this->get_usermeta_keyname('s2_cat') . $cat->term_id));
528
+ }
529
}
530
} else {
531
foreach ( $all_cats as $cat ) {
532
+ if ( in_array($cat->term_id, $compulsory) ) {
533
+ $count[$cat->name] = $count['all_users'];
534
+ } else {
535
+ $count[$cat->name] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key=%s", $this->get_usermeta_keyname('s2_cat') . $cat->term_id));
536
+ }
537
}
538
}
539
}
629
echo "<label><input type=\"radio\" name=\"email_freq\" value=\"" . $key . "\"" . checked($this->subscribe2_options['email_freq'], $key, false) . " />";
630
echo " " . $value['display'] . "</label><br />\r\n";
631
}
632
if ( $scheduled_time ) {
633
+ $date_format = get_option('date_format');
634
+ $time_format = get_option('time_format');
635
echo "<p>" . __('Current UTC time is', 'subscribe2') . ": \r\n";
636
+ echo "<strong>" . date_i18n($date_format . " @ " . $time_format, false, 'gmt') . "</strong></p>\r\n";
637
echo "<p>" . __('Current blog time is', 'subscribe2') . ": \r\n";
638
+ echo "<strong>" . date_i18n($date_format . " @ " . $time_format) . "</strong></p>\r\n";
639
echo "<p>" . __('Next email notification will be sent when your blog time is after', 'subscribe2') . ": \r\n";
640
+ echo "<input type=\"hidden\" id=\"jscrondate\" value=\"" . date_i18n($date_format, $scheduled_time + $offset) . "\" />";
641
+ echo "<input type=\"hidden\" id=\"jscrontime\" value=\"" . date_i18n($time_format, $scheduled_time + $offset) . "\" />";
642
+ echo "<span id=\"s2cron_1\"><span id=\"s2crondate\" style=\"background-color: #FFFBCC\">" . date_i18n($date_format, $scheduled_time + $offset) . "</span>";
643
+ echo " @ <span id=\"s2crontime\" style=\"background-color: #FFFBCC\">" . date_i18n($time_format, $scheduled_time + $offset) . "</span> ";
644
+ echo "<a href=\"#\" onclick=\"s2_show('cron'); return false;\">" . __('Edit', 'subscribe2') . "</a></span>\n";
645
+ echo "<span id=\"s2cron_2\">\r\n";
646
+ echo "<input id=\"s2datepicker\" name=\"crondate\" value=\"" . date_i18n($date_format, $scheduled_time + $offset) . "\">\r\n";
647
+ $hours = array('12:00 am', '1:00 am', '2:00 am', '3:00 am', '4:00 am', '5:00 am', '6:00 am', '7:00 am', '8:00 am', '9:00 am', '10:00 am', '11:00 am', '12:00 pm', '1:00 pm', '2:00 pm', '3:00 pm', '4:00 pm', '5:00 pm', '6:00 pm', '7:00 pm', '8:00 pm', '9:00 pm', '10:00 pm', '11:00 pm');
648
+ $current_hour = intval(date_i18n('G', $scheduled_time + $offset));
649
+ echo "<select name=\"crontime\">\r\n";
650
+ foreach ( $hours as $key => $value ) {
651
+ echo "<option value=\"" . $key . "\"";
652
+ if ( !empty($scheduled_time) && $key === $current_hour ) {
653
+ echo " selected=\"selected\"";
654
+ }
655
+ echo ">" . $value . "</option>\r\n";
656
+ }
657
+ echo "</select>\r\n";
658
+ echo "<a href=\"#\" onclick=\"s2_cron_update('cron'); return false;\">". __('Update', 'subscribe2') . "</a>\n";
659
+ echo "<a href=\"#\" onclick=\"s2_cron_revert('cron'); return false;\">". __('Revert', 'subscribe2') . "</a></span>\n";
660
if ( !empty($this->subscribe2_options['previous_s2cron']) ) {
661
echo "<p>" . __('Attempt to resend the last Digest Notification email', 'subscribe2') . ": ";
662
echo "<input type=\"submit\" class=\"button-secondary\" name=\"resend\" value=\"" . __('Resend Digest', 'subscribe2') . "\" /></p>\r\n";
670
Create and display a dropdown list of pages
671
*/
672
function pages_dropdown($s2page) {
673
+ $pages = get_pages();
674
if ( empty($pages) ) { return; }
675
676
+ $option = "<option value=\"0\">" . __('Select a page', 'subscribe2') . "</option>\r\n";
677
foreach ( $pages as $page ) {
678
$option .= "<option value=\"" . $page->ID . "\"";
679
if ( $page->ID == $s2page ) {
680
$option .= " selected=\"selected\"";
681
}
682
+ $option .= ">";
683
+ $parents = array_reverse( get_ancestors($page->ID, 'page') );
684
+ if ( $parents ) {
685
+ foreach ( $parents as $parent ) {
686
+ $option .= get_the_title($parent) . ' &raquo; ';
687
+ }
688
+ }
689
+ $option .= $page->post_title . "</option>\r\n";
690
}
691
692
echo $option;
822
*/
823
function new_category($new_category='') {
824
if ( 'no' == $this->subscribe2_options['show_autosub'] ) { return; }
825
+
826
global $wpdb;
827
+ if ( $this->subscribe2_options['email_freq'] != 'never' ) {
828
+ // if we are doing digests add new categories to users who are currently opted in
829
+ $sql = $wpdb->prepare("SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE meta_key=%s AND meta_value<>''", $this->get_usermeta_keyname('s2_subscribed'));
830
+ $user_IDs = $wpdb->get_col($sql);
831
+ foreach ( $user_IDs as $user_ID ) {
832
+ $old_cats = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true);
833
+ $old_cats = explode(',', $old_cats);
834
+ $newcats = array_merge($old_cats, (array)$new_category);
835
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $new_category, $new_category);
836
+ update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $newcats));
837
+ }
838
+ return;
839
+ }
840
841
if ( 'yes' == $this->subscribe2_options['show_autosub'] ) {
842
if ( $this->s2_mu ) {
classes/class-s2-core.php CHANGED
@@ -7,7 +7,8 @@ class s2class {
7
function load_translations() {
8
load_plugin_textdomain('subscribe2', false, S2DIR);
9
load_plugin_textdomain('subscribe2', false, S2DIR . "languages/");
10
- load_plugin_textdomain('subscribe2', false, WP_LANG_DIR . "/");
11
} // end load_translations()
12
13
/**
@@ -16,15 +17,15 @@ class s2class {
16
function load_strings() {
17
// adjust the output of Subscribe2 here
18
19
- $this->please_log_in = "<p class=\"s2_message\">" . __('To manage your subscription options please', 'subscribe2') . " <a href=\"" . get_option('siteurl') . "/wp-login.php\">" . __('login', 'subscribe2') . "</a>.</p>";
20
21
- $this->profile = "<p class=\"s2_message\">" . __('You may manage your subscription options from your', 'subscribe2') . " <a href=\"" . get_option('siteurl') . "/wp-admin/admin.php?page=s2\">" . __('profile', 'subscribe2') . "</a>.</p>";
22
if ( $this->s2_mu === true ) {
23
global $blog_id;
24
$user_ID = get_current_user_id();
25
if ( !is_user_member_of_blog($user_ID, $blog_id) ) {
26
// if we are on multisite and the user is not a member of this blog change the link
27
- $this->profile = "<p class=\"s2_message\"><a href=\"" . get_option('siteurl') . "/wp-admin/?s2mu_subscribe=" . $blog_id . "\">" . __('Subscribe', 'subscribe2') . "</a> " . __('to email notifications when this blog posts new content', 'subscribe2') . ".</p>";
28
}
29
}
30
@@ -42,9 +43,11 @@ class s2class {
42
43
$this->no_page = __('You must to create a WordPress page for this plugin to work correctly.', 'subscribe2');
44
45
$this->mail_sent = "<p class=\"s2_message\">" . __('Message sent!', 'subscribe2') . "</p>";
46
47
- $this->mail_failed = "<p class=\"s2_error\">" . __('Message failed! Check your settings and check with your hosting provider', 'subscribe2') . "</p>";
48
49
// confirmation messages
50
$this->no_such_email = "<p class=\"s2_error\">" . __('No such email address is registered.', 'subscribe2') . "</p>";
@@ -232,7 +235,7 @@ class s2class {
232
/**
233
Delivers email to recipients in HTML or plaintext
234
*/
235
- function mail($recipients = array(), $subject = '', $message = '', $type = 'text') {
236
if ( empty($recipients) || '' == $message ) { return; }
237
238
// Replace any escaped html symbols in subject then apply filter
@@ -240,14 +243,14 @@ class s2class {
240
$subject = apply_filters('s2_email_subject', $subject);
241
242
if ( 'html' == $type ) {
243
- $headers = $this->headers('html');
244
if ( 'yes' == $this->subscribe2_options['stylesheet'] ) {
245
$mailtext = apply_filters('s2_html_email', "<html><head><title>" . $subject . "</title><link rel=\"stylesheet\" href=\"" . get_stylesheet_uri() . "\" type=\"text/css\" media=\"screen\" /></head><body>" . $message . "</body></html>", $subject, $message);
246
} else {
247
$mailtext = apply_filters('s2_html_email', "<html><head><title>" . $subject . "</title></head><body>" . $message . "</body></html>", $subject, $message);
248
}
249
} else {
250
- $headers = $this->headers();
251
$message = preg_replace('|&[^a][^m][^p].{0,3};|', '', $message);
252
$message = preg_replace('|&amp;|', '&', $message);
253
$message = wordwrap(strip_tags($message), $this->word_wrap, "\n");
@@ -265,9 +268,9 @@ class s2class {
265
if ( !is_email($recipient) || empty($recipient) ) { continue; }
266
// Use the mail queue provided we are not sending a preview
267
if ( function_exists('wpmq_mail') && !$this->preview_email ) {
268
- @wp_mail($recipient, $subject, $mailtext, $headers, '', 0);
269
} else {
270
- @wp_mail($recipient, $subject, $mailtext, $headers);
271
}
272
}
273
return true;
@@ -316,10 +319,10 @@ class s2class {
316
if ( isset($batch) && !empty($batch) ) {
317
foreach ( $batch as $bcc ) {
318
$newheaders = $headers . "$bcc\n";
319
- $status = @wp_mail($this->myemail, $subject, $mailtext, $newheaders);
320
}
321
} else {
322
- $status = @wp_mail($this->myemail, $subject, $mailtext, $headers);
323
}
324
return $status;
325
} // end mail()
@@ -327,7 +330,7 @@ class s2class {
327
/**
328
Construct standard set of email headers
329
*/
330
- function headers($type = 'text') {
331
if ( empty($this->myname) || empty($this->myemail) ) {
332
if ( $this->subscribe2_options['sender'] == 'blogname' ) {
333
$this->myname = html_entity_decode(get_option('blogname'), ENT_QUOTES);
@@ -360,10 +363,10 @@ class s2class {
360
}
361
$header['Return-path'] = "<" . $this->myemail . ">";
362
$header['Precedence'] = "list\nList-Id: " . html_entity_decode(get_option('blogname'), ENT_QUOTES) . "";
363
- if ( $type == 'html' ) {
364
// To send HTML mail, the Content-Type header must be set
365
$header['Content-Type'] = get_option('html_type') . "; charset=\"". get_option('blog_charset') . "\"";
366
- } else {
367
$header['Content-Type'] = "text/plain; charset=\"". get_option('blog_charset') . "\"";
368
}
369
@@ -539,6 +542,7 @@ class s2class {
539
$plaintext = preg_replace('|<s[^>]*>(.*)<\/s>|Ui','', $plaintext);
540
$plaintext = preg_replace('|<strike[^>]*>(.*)<\/strike>|Ui','', $plaintext);
541
$plaintext = preg_replace('|<del[^>]*>(.*)<\/del>|Ui','', $plaintext);
542
543
$gallid = '[gallery id="' . $post->ID . '"';
544
$content = str_replace('[gallery', $gallid, $post->post_content);
@@ -601,8 +605,8 @@ class s2class {
601
$plaintext = preg_replace('|[ ]+|', ' ', $plaintext);
602
603
// prepare mail body texts
604
- $excerpt_body = str_replace("{POST}", $excerpt, $mailtext);
605
- $full_body = str_replace("{POST}", strip_tags($plaintext), $mailtext);
606
$html_body = str_replace("\r\n", "<br />\r\n", $mailtext);
607
$html_body = str_replace("{POST}", $content, $html_body);
608
$html_excerpt_body = str_replace("\r\n", "<br />\r\n", $mailtext);
@@ -611,40 +615,38 @@ class s2class {
611
if ( $preview != '' ) {
612
$this->myemail = $preview;
613
$this->myname = __('Plain Text Excerpt Preview', 'subscribe2');
614
- $this->mail(array($preview), $subject, $excerpt_body);
615
$this->myname = __('Plain Text Full Preview', 'subscribe2');
616
- $this->mail(array($preview), $subject, $full_body);
617
$this->myname = __('HTML Excerpt Preview', 'subscribe2');
618
$this->mail(array($preview), $subject, $html_excerpt_body, 'html');
619
$this->myname = __('HTML Full Preview', 'subscribe2');
620
$this->mail(array($preview), $subject, $html_body, 'html');
621
} else {
622
// first we send plaintext summary emails
623
- $registered = $this->get_registered("cats=$post_cats_string&format=excerpt&author=$post->post_author");
624
- if ( empty($registered) ) {
625
- $recipients = (array)$public;
626
- } elseif ( empty($public) ) {
627
- $recipients = (array)$registered;
628
- } else {
629
- $recipients = array_merge((array)$public, (array)$registered);
630
- }
631
$recipients = apply_filters('s2_send_plain_excerpt_suscribers', $recipients, $post->ID);
632
- $this->mail($recipients, $subject, $excerpt_body);
633
634
// next we send plaintext full content emails
635
$recipients = $this->get_registered("cats=$post_cats_string&format=post&author=$post->post_author");
636
$recipients = apply_filters('s2_send_plain_fullcontent_suscribers', $recipients, $post->ID);
637
- $this->mail($recipients, $subject, $full_body);
638
639
// next we send html excerpt content emails
640
$recipients = $this->get_registered("cats=$post_cats_string&format=html_excerpt&author=$post->post_author");
641
$recipients = apply_filters('s2_send_html_excerpt_suscribers', $recipients, $post->ID);
642
$this->mail($recipients, $subject, $html_excerpt_body, 'html');
643
644
- // finally we send html full content emails
645
$recipients = $this->get_registered("cats=$post_cats_string&format=html&author=$post->post_author");
646
$recipients = apply_filters('s2_send_html_fullcontent_suscribers', $recipients, $post->ID);
647
$this->mail($recipients, $subject, $html_body, 'html');
648
}
649
} // end publish()
650
@@ -817,21 +819,6 @@ class s2class {
817
}
818
} //end remind()
819
820
- /**
821
- Check email is not from a barred domain
822
- */
823
- function is_barred($email = '') {
824
- $barred_option = $this->subscribe2_options['barred'];
825
- list($user, $domain) = explode('@', $email, 2);
826
- $bar_check = stristr($barred_option, $domain);
827
-
828
- if ( !empty($bar_check) ) {
829
- return true;
830
- } else {
831
- return false;
832
- }
833
- } // end is_barred()
834
-
835
/**
836
Is the supplied email address a public subscriber?
837
*/
@@ -849,42 +836,6 @@ class s2class {
849
}
850
} // end is_public()
851
852
- /**
853
- Collects the signup date for all public subscribers
854
- */
855
- function signup_date($email = '') {
856
- if ( '' == $email ) { return false; }
857
-
858
- global $wpdb;
859
- if ( !empty($this->signup_dates) ) {
860
- return $this->signup_dates[$email];
861
- } else {
862
- $results = $wpdb->get_results("SELECT email, date FROM $this->public", ARRAY_N);
863
- foreach ( $results as $result ) {
864
- $this->signup_dates[$result[0]] = $result[1];
865
- }
866
- return $this->signup_dates[$email];
867
- }
868
- } // end signup_date()
869
-
870
- /**
871
- Collects the ip address for all public subscribers
872
- */
873
- function signup_ip($email = '') {
874
- if ( '' == $email ) {return false; }
875
-
876
- global $wpdb;
877
- if ( !empty($this->signup_ips) ) {
878
- return $this->signup_ips[$email];
879
- } else {
880
- $results = $wpdb->get_results("SELECT email, ip FROM $this->public", ARRAY_N);
881
- foreach ( $results as $result ) {
882
- $this->signup_ips[$result[0]] = $result[1];
883
- }
884
- return $this->signup_ips[$email];
885
- }
886
- } // end signup_ip()
887
-
888
/* ===== Registered User and Subscriber functions ===== */
889
/**
890
Is the supplied email address a registered user of the blog?
@@ -1004,9 +955,9 @@ class s2class {
1004
}
1005
1006
if ( $this->s2_mu ) {
1007
- $sql = "SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . "WHERE a.meta_key='" . $wpdb->prefix . "capabilities'" . $AND;
1008
} else {
1009
- $sql = $wpdb->prepare("SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . "WHERE a.meta_key=%s" . $AND, $this->get_usermeta_keyname('s2_subscribed'));
1010
}
1011
$result = $wpdb->get_col($sql);
1012
if ( $result ) {
@@ -1389,7 +1340,7 @@ class s2class {
1389
} // end add_weekly_sched()
1390
1391
/**
1392
- Send a daily digest of today's new posts
1393
*/
1394
function subscribe2_cron($preview = '', $resend = '') {
1395
if ( defined('DOING_S2_CRON') && DOING_S2_CRON ) { return; }
@@ -1637,6 +1588,22 @@ class s2class {
1637
}
1638
} // end subscribe2_cron()
1639
1640
/* ===== Our constructor ===== */
1641
/**
1642
Subscribe2 constructor
@@ -1670,9 +1637,8 @@ class s2class {
1670
}
1671
}
1672
1673
- // load our translations and strings
1674
- add_action('init', array(&$this, 'load_translations'), 5);
1675
- add_action('init', array(&$this, 'load_strings'));
1676
1677
// do we need to install anything?
1678
$this->public = $wpdb->prefix . "subscribe2";
@@ -1727,8 +1693,16 @@ class s2class {
1727
add_action('widgets_init', array(&$this, 'counter_widget'));
1728
}
1729
1730
// Add actions specific to admin or frontend
1731
if ( is_admin() ) {
1732
//add menu, authoring and category admin actions
1733
add_action('admin_menu', array(&$this, 'admin_menu'));
1734
add_action('admin_menu', array(&$this, 's2_meta_init'));
@@ -1774,11 +1748,14 @@ class s2class {
1774
exit(0);
1775
}
1776
} else {
1777
if ( isset($_GET['s2']) ) {
1778
// someone is confirming a request
1779
if ( defined('DOING_S2_CONFIRM') && DOING_S2_CONFIRM ) { return; }
1780
define( 'DOING_S2_CONFIRM', true );
1781
- add_filter('query_string', array(&$this, 'query_filter'));
1782
add_filter('the_title', array(&$this, 'title_filter'));
1783
add_filter('the_content', array(&$this, 'confirm'));
1784
}
@@ -1800,14 +1777,6 @@ class s2class {
1800
}
1801
} // end s2init()
1802
1803
- /**
1804
- PHP4 Constructor
1805
- Can be erased when support for WordPress 3.1 is dropped
1806
- */
1807
- function s2class() {
1808
- $this->__construct();
1809
- } // end s2class()
1810
-
1811
/**
1812
PHP5 Constructor
1813
Allows dynamic variable setting
@@ -1816,6 +1785,7 @@ class s2class {
1816
$this->word_wrap = apply_filters('s2_word_wrap', 80);
1817
$this->excerpt_length = apply_filters('s2_excerpt_length', 55);
1818
$this->site_switching = apply_filters('s2_allow_site_switching', false);
1819
} // end __construct()
1820
1821
/* ===== our variables ===== */
@@ -1849,6 +1819,7 @@ class s2class {
1849
var $word_wrap;
1850
var $excerpt_length;
1851
var $site_switching;
1852
1853
// some messages
1854
var $please_log_in = '';
7
function load_translations() {
8
load_plugin_textdomain('subscribe2', false, S2DIR);
9
load_plugin_textdomain('subscribe2', false, S2DIR . "languages/");
10
+ $mofile = WP_LANG_DIR . '/subscribe2-' . apply_filters('plugin_locale', get_locale(), 'subscribe2') . '.mo';
11
+ load_textdomain('subscribe2', $mofile);
12
} // end load_translations()
13
14
/**
17
function load_strings() {
18
// adjust the output of Subscribe2 here
19
20
+ $this->please_log_in = "<p class=\"s2_message\">" . sprintf(__('To manage your subscription options please <a href="%1$s">login.</a>', 'subscribe2'), get_option('siteurl') . '/wp-login.php') . "</p>";
21
22
+ $this->profile = "<p class=\"s2_message\">" . sprintf(__('You may manage your subscription options from your <a href="%1$s">profile</a>', 'subscribe2'), get_option('siteurl') . "/wp-admin/admin.php?page=s2") . "</p>";
23
if ( $this->s2_mu === true ) {
24
global $blog_id;
25
$user_ID = get_current_user_id();
26
if ( !is_user_member_of_blog($user_ID, $blog_id) ) {
27
// if we are on multisite and the user is not a member of this blog change the link
28
+ $this->profile = "<p class=\"s2_message\">" . sprintf(__('<a href="%1$s">Subscribe</a> to email notifications when this blog posts new content.', 'subscribe2'), get_option('siteurl') . "/wp-admin/?s2mu_subscribe=" . $blog_id) . "</p>";
29
}
30
}
31
43
44
$this->no_page = __('You must to create a WordPress page for this plugin to work correctly.', 'subscribe2');
45
46
+ $this->disallowed_keywords = __('Your chosen email type (per-post or digest) does not support the following keywords:', 'subscribe2');
47
+
48
$this->mail_sent = "<p class=\"s2_message\">" . __('Message sent!', 'subscribe2') . "</p>";
49
50
+ $this->mail_failed = "<p class=\"s2_error\">" . __('Message failed!', 'subscribe2') . "</p>";
51
52
// confirmation messages
53
$this->no_such_email = "<p class=\"s2_error\">" . __('No such email address is registered.', 'subscribe2') . "</p>";
235
/**
236
Delivers email to recipients in HTML or plaintext
237
*/
238
+ function mail($recipients = array(), $subject = '', $message = '', $type = 'text', $attachments = array()) {
239
if ( empty($recipients) || '' == $message ) { return; }
240
241
// Replace any escaped html symbols in subject then apply filter
243
$subject = apply_filters('s2_email_subject', $subject);
244
245
if ( 'html' == $type ) {
246
+ $headers = $this->headers('html', $attachments);
247
if ( 'yes' == $this->subscribe2_options['stylesheet'] ) {
248
$mailtext = apply_filters('s2_html_email', "<html><head><title>" . $subject . "</title><link rel=\"stylesheet\" href=\"" . get_stylesheet_uri() . "\" type=\"text/css\" media=\"screen\" /></head><body>" . $message . "</body></html>", $subject, $message);
249
} else {
250
$mailtext = apply_filters('s2_html_email', "<html><head><title>" . $subject . "</title></head><body>" . $message . "</body></html>", $subject, $message);
251
}
252
} else {
253
+ $headers = $this->headers('text', $attachments);
254
$message = preg_replace('|&[^a][^m][^p].{0,3};|', '', $message);
255
$message = preg_replace('|&amp;|', '&', $message);
256
$message = wordwrap(strip_tags($message), $this->word_wrap, "\n");
268
if ( !is_email($recipient) || empty($recipient) ) { continue; }
269
// Use the mail queue provided we are not sending a preview
270
if ( function_exists('wpmq_mail') && !$this->preview_email ) {
271
+ @wp_mail($recipient, $subject, $mailtext, $headers, $attachments, 0);
272
} else {
273
+ @wp_mail($recipient, $subject, $mailtext, $headers, $attachments);
274
}
275
}
276
return true;
319
if ( isset($batch) && !empty($batch) ) {
320
foreach ( $batch as $bcc ) {
321
$newheaders = $headers . "$bcc\n";
322
+ $status = @wp_mail($this->myemail, $subject, $mailtext, $newheaders, $attachments);
323
}
324
} else {
325
+ $status = @wp_mail($this->myemail, $subject, $mailtext, $headers, $attachments);
326
}
327
return $status;
328
} // end mail()
330
/**
331
Construct standard set of email headers
332
*/
333
+ function headers($type = 'text', $attachments = array()) {
334
if ( empty($this->myname) || empty($this->myemail) ) {
335
if ( $this->subscribe2_options['sender'] == 'blogname' ) {
336
$this->myname = html_entity_decode(get_option('blogname'), ENT_QUOTES);
363
}
364
$header['Return-path'] = "<" . $this->myemail . ">";
365
$header['Precedence'] = "list\nList-Id: " . html_entity_decode(get_option('blogname'), ENT_QUOTES) . "";
366
+ if ( empty($attachments) && $type == 'html' ) {
367
// To send HTML mail, the Content-Type header must be set
368
$header['Content-Type'] = get_option('html_type') . "; charset=\"". get_option('blog_charset') . "\"";
369
+ } elseif ( empty($attachments) && $type == 'text' ) {
370
$header['Content-Type'] = "text/plain; charset=\"". get_option('blog_charset') . "\"";
371
}
372
542
$plaintext = preg_replace('|<s[^>]*>(.*)<\/s>|Ui','', $plaintext);
543
$plaintext = preg_replace('|<strike[^>]*>(.*)<\/strike>|Ui','', $plaintext);
544
$plaintext = preg_replace('|<del[^>]*>(.*)<\/del>|Ui','', $plaintext);
545
+ $plaintext = trim(strip_tags($plaintext));
546
547
$gallid = '[gallery id="' . $post->ID . '"';
548
$content = str_replace('[gallery', $gallid, $post->post_content);
605
$plaintext = preg_replace('|[ ]+|', ' ', $plaintext);
606
607
// prepare mail body texts
608
+ $plain_excerpt_body = str_replace("{POST}", $excerpt, $mailtext);
609
+ $plain_body = str_replace("{POST}", $plaintext, $mailtext);
610
$html_body = str_replace("\r\n", "<br />\r\n", $mailtext);
611
$html_body = str_replace("{POST}", $content, $html_body);
612
$html_excerpt_body = str_replace("\r\n", "<br />\r\n", $mailtext);
615
if ( $preview != '' ) {
616
$this->myemail = $preview;
617
$this->myname = __('Plain Text Excerpt Preview', 'subscribe2');
618
+ $this->mail(array($preview), $subject, $plain_excerpt_body);
619
$this->myname = __('Plain Text Full Preview', 'subscribe2');
620
+ $this->mail(array($preview), $subject, $plain_body);
621
$this->myname = __('HTML Excerpt Preview', 'subscribe2');
622
$this->mail(array($preview), $subject, $html_excerpt_body, 'html');
623
$this->myname = __('HTML Full Preview', 'subscribe2');
624
$this->mail(array($preview), $subject, $html_body, 'html');
625
} else {
626
+ // Registered Subscribers first
627
// first we send plaintext summary emails
628
+ $recipients = $this->get_registered("cats=$post_cats_string&format=excerpt&author=$post->post_author");
629
$recipients = apply_filters('s2_send_plain_excerpt_suscribers', $recipients, $post->ID);
630
+ $this->mail($recipients, $subject, $plain_excerpt_body);
631
632
// next we send plaintext full content emails
633
$recipients = $this->get_registered("cats=$post_cats_string&format=post&author=$post->post_author");
634
$recipients = apply_filters('s2_send_plain_fullcontent_suscribers', $recipients, $post->ID);
635
+ $this->mail($recipients, $subject, $plain_body);
636
637
// next we send html excerpt content emails
638
$recipients = $this->get_registered("cats=$post_cats_string&format=html_excerpt&author=$post->post_author");
639
$recipients = apply_filters('s2_send_html_excerpt_suscribers', $recipients, $post->ID);
640
$this->mail($recipients, $subject, $html_excerpt_body, 'html');
641
642
+ // next we send html full content emails
643
$recipients = $this->get_registered("cats=$post_cats_string&format=html&author=$post->post_author");
644
$recipients = apply_filters('s2_send_html_fullcontent_suscribers', $recipients, $post->ID);
645
$this->mail($recipients, $subject, $html_body, 'html');
646
+
647
+ // and finally we send to Public Subscribers
648
+ $recipients = apply_filters('s2_send_public_suscribers', $public, $post->ID);
649
+ $this->mail($recipients, $subject, $plain_excerpt_body, 'text');
650
}
651
} // end publish()
652
819
}
820
} //end remind()
821
822
/**
823
Is the supplied email address a public subscriber?
824
*/
836
}
837
} // end is_public()
838
839
/* ===== Registered User and Subscriber functions ===== */
840
/**
841
Is the supplied email address a registered user of the blog?
955
}
956
957
if ( $this->s2_mu ) {
958
+ $sql = $wpdb->prepare("SELECT a.user_id FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS e ON a.user_id = e.user_id " . $JOIN . "WHERE a.meta_key='" . $wpdb->prefix . "capabilities' AND e.meta_key=%s AND e.meta_value <> ''" . $AND, $this->get_usermeta_keyname('s2_subscribed'));
959
} else {
960
+ $sql = $wpdb->prepare("SELECT a.user_id FROM $wpdb->usermeta AS a " . $JOIN . "WHERE a.meta_key=%s AND a.meta_value <> ''" . $AND, $this->get_usermeta_keyname('s2_subscribed'));
961
}
962
$result = $wpdb->get_col($sql);
963
if ( $result ) {
1340
} // end add_weekly_sched()
1341
1342
/**
1343
+ Send a digest of recent new posts
1344
*/
1345
function subscribe2_cron($preview = '', $resend = '') {
1346
if ( defined('DOING_S2_CRON') && DOING_S2_CRON ) { return; }
1588
}
1589
} // end subscribe2_cron()
1590
1591
+ function s2cleaner_task() {
1592
+ $unconfirmed = $this->get_public('0');
1593
+ if ( empty($unconfirmed) ) { return; }
1594
+ global $wpdb;
1595
+ $sql = "SELECT email FROM $this->public WHERE active='0' AND date < DATE_SUB(CURDATE(), INTERVAL " . $this->clean_interval . " DAY)";
1596
+ $old_unconfirmed = $wpdb->get_col( $sql );
1597
+ if ( empty($old_unconfirmed) ) {
1598
+ return;
1599
+ } else {
1600
+ foreach ($old_unconfirmed as $email) {
1601
+ $this->delete($email);
1602
+ }
1603
+ }
1604
+ return;
1605
+ } // end s2cleaner_task()
1606
+
1607
/* ===== Our constructor ===== */
1608
/**
1609
Subscribe2 constructor
1637
}
1638
}
1639
1640
+ // load our translations
1641
+ add_action('plugins_loaded', array(&$this, 'load_translations'));
1642
1643
// do we need to install anything?
1644
$this->public = $wpdb->prefix . "subscribe2";
1693
add_action('widgets_init', array(&$this, 'counter_widget'));
1694
}
1695
1696
+ // add action to 'clean' unconfirmed Public Subscribers
1697
+ if ( $this->clean_interval > 0 ) {
1698
+ add_action('wp_scheduled_delete', array(&$this, 's2cleaner_task'));
1699
+ }
1700
+
1701
// Add actions specific to admin or frontend
1702
if ( is_admin() ) {
1703
+ // load strings
1704
+ add_action('init', array(&$this, 'load_strings'));
1705
+
1706
//add menu, authoring and category admin actions
1707
add_action('admin_menu', array(&$this, 'admin_menu'));
1708
add_action('admin_menu', array(&$this, 's2_meta_init'));
1748
exit(0);
1749
}
1750
} else {
1751
+ // load strings later on frontend for polylang plugin compatibility
1752
+ add_action('wp', array(&$this, 'load_strings'));
1753
+
1754
if ( isset($_GET['s2']) ) {
1755
// someone is confirming a request
1756
if ( defined('DOING_S2_CONFIRM') && DOING_S2_CONFIRM ) { return; }
1757
define( 'DOING_S2_CONFIRM', true );
1758
+ add_filter('request', array(&$this, 'query_filter'));
1759
add_filter('the_title', array(&$this, 'title_filter'));
1760
add_filter('the_content', array(&$this, 'confirm'));
1761
}
1777
}
1778
} // end s2init()
1779
1780
/**
1781
PHP5 Constructor
1782
Allows dynamic variable setting
1785
$this->word_wrap = apply_filters('s2_word_wrap', 80);
1786
$this->excerpt_length = apply_filters('s2_excerpt_length', 55);
1787
$this->site_switching = apply_filters('s2_allow_site_switching', false);
1788
+ $this->clean_interval = apply_filters('s2_clean_interval', 28);
1789
} // end __construct()
1790
1791
/* ===== our variables ===== */
1819
var $word_wrap;
1820
var $excerpt_length;
1821
var $site_switching;
1822
+ var $clean_interval;
1823
1824
// some messages
1825
var $please_log_in = '';
classes/class-s2-frontend.php CHANGED
@@ -10,8 +10,10 @@ class s2_frontend extends s2class {
10
'id' => '',
11
'url' => '',
12
'nojs' => 'false',
13
'link' => '',
14
- 'size' => 20
15
), $atts));
16
17
// if link is true return a link to the page with the ajax class
@@ -56,11 +58,26 @@ class s2_frontend extends s2class {
56
$value = __('Enter email address...', 'subscribe2');
57
}
58
59
// build default form
60
if ( $nojs == 'true' ) {
61
- $this->form = "<form method=\"post\"" . $action . "><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" /><p><label for=\"s2email\">" . __('Your email:', 'subscribe2') . "</label><br /><input type=\"text\" name=\"email\" id=\"s2email\" value=\"" . $value . "\" size=\"" . $size . "\" /></p><p>" . $this->input_form_action . "</p></form>";
62
} else {
63
- $this->form = "<form method=\"post\"" . $action . "><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" /><p><label for=\"s2email\">" . __('Your email:', 'subscribe2') . "</label><br /><input type=\"text\" name=\"email\" id=\"s2email\" value=\"" . $value . "\" size=\"" . $size . "\" onfocus=\"if (this.value == '" . $value . "') {this.value = '';}\" onblur=\"if (this.value == '') {this.value = '" . $value . "';}\" /></p><p>" . $this->input_form_action . "</p></form>\r\n";
64
}
65
$this->s2form = $this->form;
66
@@ -70,6 +87,11 @@ class s2_frontend extends s2class {
70
$this->s2form = $this->profile;
71
}
72
if ( isset($_POST['subscribe']) || isset($_POST['unsubscribe']) ) {
73
global $wpdb, $user_email;
74
$this->email = $this->sanitize_email($_POST['email']);
75
if ( !is_email($this->email) ) {
@@ -147,14 +169,20 @@ class s2_frontend extends s2class {
147
148
global $wpdb;
149
150
if ( 0 != $this->subscribe2_options['s2page'] ) {
151
- return "page_id=" . $this->subscribe2_options['s2page'];
152
} else {
153
$id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1");
154
if ( $id ) {
155
- return "page_id=$id";
156
} else {
157
- return "showposts=1";
158
}
159
}
160
} // end query_filter()
@@ -203,7 +231,7 @@ class s2_frontend extends s2class {
203
204
if ( '1' == $action ) {
205
// make this subscription active
206
- $this->message = $this->added;
207
if ( '1' != $current ) {
208
$this->ip = $_SERVER['REMOTE_ADDR'];
209
$this->toggle($this->email);
@@ -217,6 +245,7 @@ class s2_frontend extends s2class {
217
foreach ($wp_user_query as $user) {
218
$recipients[] = $user->user_email;
219
}
220
$headers = $this->headers();
221
// send individual emails so we don't reveal admin emails to each other
222
foreach ( $recipients as $recipient ) {
@@ -227,7 +256,7 @@ class s2_frontend extends s2class {
227
$this->filtered = 1;
228
} elseif ( '0' == $action ) {
229
// remove this subscriber
230
- $this->message = $this->deleted;
231
if ( '0' != $current ) {
232
$this->delete($this->email);
233
if ( $this->subscribe2_options['admin_email'] == 'unsubs' || $this->subscribe2_options['admin_email'] == 'both' ) {
@@ -240,6 +269,7 @@ class s2_frontend extends s2class {
240
foreach ($wp_user_query as $user) {
241
$recipients[] = $user->user_email;
242
}
243
$headers = $this->headers();
244
// send individual emails so we don't reveal admin emails to each other
245
foreach ( $recipients as $recipient ) {
@@ -270,7 +300,7 @@ class s2_frontend extends s2class {
270
function add_ajax() {
271
// enqueue the jQuery script we need and let WordPress handle the dependencies
272
wp_enqueue_script('jquery-ui-dialog');
273
- wp_register_style('jquery-ui-style', apply_filters('s2_jqueryui_css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/themes/ui-darkness/jquery-ui.css'));
274
wp_enqueue_style('jquery-ui-style');
275
} // end add_ajax()
276
@@ -280,11 +310,12 @@ class s2_frontend extends s2class {
280
function add_s2_ajax() {
281
echo "<script type=\"text/javascript\">\r\n";
282
echo "//<![CDATA[\r\n";
283
- echo "jQuery(document).ready(function() {\r\n";
284
- echo " var dialog = jQuery('<div></div>');\r\n";
285
- echo " if (jQuery('a.s2popup').attr('id') === 'unsubscribe') {\r\n";
286
echo " dialog.html('" . do_shortcode('[subscribe2 nojs="true" hide="unsubscribe"]') . "');\r\n";
287
- echo " } else if (jQuery('a.s2popup').attr('id') === 'subscribe') {\r\n";
288
echo " dialog.html('" . do_shortcode('[subscribe2 nojs="true" hide="subscribe"]') . "');\r\n";
289
echo " } else {\r\n";
290
echo " dialog.html('" . do_shortcode('[subscribe2 nojs="true"]') . "');\r\n";
@@ -294,7 +325,7 @@ class s2_frontend extends s2class {
294
} else {
295
echo " dialog.dialog({autoOpen: false, modal: true, zIndex: 10000, title: '" . __('Subscribe to this blog', 'subscribe2') . "'});\r\n";
296
}
297
- echo " jQuery('a.s2popup').click(function(){\r\n";
298
echo " dialog.dialog('open');\r\n";
299
echo " return false;\r\n";
300
echo " });\r\n";
@@ -302,5 +333,21 @@ class s2_frontend extends s2class {
302
echo "//]]>\r\n";
303
echo "</script>\r\n";
304
} // end add_s2_ajax()
305
}
306
?>
10
'id' => '',
11
'url' => '',
12
'nojs' => 'false',
13
+ 'noantispam' => 'false',
14
'link' => '',
15
+ 'size' => 20,
16
+ 'wrap' => 'true'
17
), $atts));
18
19
// if link is true return a link to the page with the ajax class
58
$value = __('Enter email address...', 'subscribe2');
59
}
60
61
+ // if wrap is true add paragraph html tags
62
+ $wrap_text = '';
63
+ if ( $wrap == 'true' ) {
64
+ $wrap_text = '</p><p>';
65
+ }
66
+
67
+ // deploy some anti-spam measures
68
+ $antispam_text = '';
69
+ if ( $noantispam != 'true' ) {
70
+ $antispam_text = "<span style=\"display:none !important\">";
71
+ $antispam_text .= "<label for=\"name\">Leave Blank:</label><input type=\"text\" id=\"name\" name=\"name\" />";
72
+ $antispam_text .= "<label for=\"uri\">Don't Change:</label><input type=\"text\" id=\"uri\" name=\"uri\" value=\"http://\" />";
73
+ $antispam_text .= "</span>";
74
+ }
75
+
76
// build default form
77
if ( $nojs == 'true' ) {
78
+ $this->form = "<form method=\"post\"" . $action . "><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" />" . $antispam_text . "<p><label for=\"s2email\">" . __('Your email:', 'subscribe2') . "</label><br /><input type=\"text\" name=\"email\" id=\"s2email\" value=\"" . $value . "\" size=\"" . $size . "\" />" . $wrap_text . $this->input_form_action . "</p></form>";
79
} else {
80
+ $this->form = "<form method=\"post\"" . $action . "><input type=\"hidden\" name=\"ip\" value=\"" . $_SERVER['REMOTE_ADDR'] . "\" />" . $antispam_text . "<p><label for=\"s2email\">" . __('Your email:', 'subscribe2') . "</label><br /><input type=\"text\" name=\"email\" id=\"s2email\" value=\"" . $value . "\" size=\"" . $size . "\" onfocus=\"if (this.value == '" . $value . "') {this.value = '';}\" onblur=\"if (this.value == '') {this.value = '" . $value . "';}\" />" . $wrap_text . $this->input_form_action . "</p></form>\r\n";
81
}
82
$this->s2form = $this->form;
83
87
$this->s2form = $this->profile;
88
}
89
if ( isset($_POST['subscribe']) || isset($_POST['unsubscribe']) ) {
90
+ // anti spam sign up measure
91
+ if ( $_POST['name'] != '' || $_POST['uri'] != 'http://' ) {
92
+ // looks like some invisible-to-user fields were changed; falsely report success
93
+ return $this->confirmation_sent;
94
+ }
95
global $wpdb, $user_email;
96
$this->email = $this->sanitize_email($_POST['email']);
97
if ( !is_email($this->email) ) {
169
170
global $wpdb;
171
172
+ // brute force Simple Facebook Connect to bypass compatiblity issues
173
+ $priority = has_filter('wp_head', 'sfc_base_meta');
174
+ if ( $priority !== false ) {
175
+ remove_action('wp_head', 'sfc_base_meta', $priority);
176
+ }
177
+
178
if ( 0 != $this->subscribe2_options['s2page'] ) {
179
+ return array('page_id' => $this->subscribe2_options['s2page']);
180
} else {
181
$id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1");
182
if ( $id ) {
183
+ return array('page_id' => $id);
184
} else {
185
+ return array('showposts' => 1);
186
}
187
}
188
} // end query_filter()
231
232
if ( '1' == $action ) {
233
// make this subscription active
234
+ $this->message = apply_filters('s2_subscribe_confirmed', $this->added);
235
if ( '1' != $current ) {
236
$this->ip = $_SERVER['REMOTE_ADDR'];
237
$this->toggle($this->email);
245
foreach ($wp_user_query as $user) {
246
$recipients[] = $user->user_email;
247
}
248
+ $recipients = apply_filters('s2_admin_email', $recipients, 'subscribe');
249
$headers = $this->headers();
250
// send individual emails so we don't reveal admin emails to each other
251
foreach ( $recipients as $recipient ) {
256
$this->filtered = 1;
257
} elseif ( '0' == $action ) {
258
// remove this subscriber
259
+ $this->message = apply_filters('s2_unsubscribe_confirmed', $this->deleted);
260
if ( '0' != $current ) {
261
$this->delete($this->email);
262
if ( $this->subscribe2_options['admin_email'] == 'unsubs' || $this->subscribe2_options['admin_email'] == 'both' ) {
269
foreach ($wp_user_query as $user) {
270
$recipients[] = $user->user_email;
271
}
272
+ $recipients = apply_filters('s2_admin_email', $recipients, 'unsubscribe');
273
$headers = $this->headers();
274
// send individual emails so we don't reveal admin emails to each other
275
foreach ( $recipients as $recipient ) {
300
function add_ajax() {
301
// enqueue the jQuery script we need and let WordPress handle the dependencies
302
wp_enqueue_script('jquery-ui-dialog');
303
+ wp_register_style('jquery-ui-style', apply_filters('s2_jqueryui_css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/ui-darkness/jquery-ui.css'));
304
wp_enqueue_style('jquery-ui-style');
305
} // end add_ajax()
306
310
function add_s2_ajax() {
311
echo "<script type=\"text/javascript\">\r\n";
312
echo "//<![CDATA[\r\n";
313
+ echo "var s2jQuery = jQuery.noConflict();\r\n";
314
+ echo "s2jQuery(document).ready(function() {\r\n";
315
+ echo " var dialog = s2jQuery('<div></div>');\r\n";
316
+ echo " if (s2jQuery('a.s2popup').attr('id') === 'unsubscribe') {\r\n";
317
echo " dialog.html('" . do_shortcode('[subscribe2 nojs="true" hide="unsubscribe"]') . "');\r\n";
318
+ echo " } else if (s2jQuery('a.s2popup').attr('id') === 'subscribe') {\r\n";
319
echo " dialog.html('" . do_shortcode('[subscribe2 nojs="true" hide="subscribe"]') . "');\r\n";
320
echo " } else {\r\n";
321
echo " dialog.html('" . do_shortcode('[subscribe2 nojs="true"]') . "');\r\n";
325
} else {
326
echo " dialog.dialog({autoOpen: false, modal: true, zIndex: 10000, title: '" . __('Subscribe to this blog', 'subscribe2') . "'});\r\n";
327
}
328
+ echo " s2jQuery('a.s2popup').click(function(){\r\n";
329
echo " dialog.dialog('open');\r\n";
330
echo " return false;\r\n";
331
echo " });\r\n";
333
echo "//]]>\r\n";
334
echo "</script>\r\n";
335
} // end add_s2_ajax()
336
+
337
+ /**
338
+ Check email is not from a barred domain
339
+ */
340
+ function is_barred($email = '') {
341
+ if ( '' == $email ) { return false; }
342
+
343
+ $bar_check = false;
344
+ list($user, $domain) = explode('@', $email, 2);
345
+ foreach ( preg_split("|[\s,]+|", $this->subscribe2_options['barred']) as $barred_domain ) {
346
+ if ( strtolower($domain) === strtolower(trim($barred_domain)) ) {
347
+ $bar_check = true;
348
+ }
349
+ }
350
+ return $bar_check;
351
+ } // end is_barred()
352
}
353
?>
classes/class-s2-list-table.php CHANGED
@@ -1,231 +1,250 @@
1
- <?php
2
- class Subscribe2_List_Table extends WP_List_Table {
3
- function __construct() {
4
- global $status, $page;
5
-
6
- parent::__construct( array(
7
- 'singular' => 'subscriber',
8
- 'plural' => 'subscribers',
9
- 'ajax' => false
10
- ) );
11
- }
12
-
13
- function column_default($item, $column_name) {
14
- global $current_tab;
15
- if ( $current_tab == 'registered' ) {
16
- switch($column_name) {
17
- case 'email':
18
- return $item[$column_name];
19
- default:
20
- return print_r($item,true);
21
- }
22
- } else {
23
- switch($column_name) {
24
- case 'email':
25
- case 'date':
26
- return $item[$column_name];
27
- default:
28
- return print_r($item,true);
29
- }
30
- }
31
- }
32
-
33
- function column_email($item) {
34
- global $current_tab;
35
- if ( $current_tab == 'registered' ) {
36
- $actions = array('edit' => sprintf('<a href="?page=%s&amp;email=%s">%s</a>', 's2', $item['email'], __('Edit', 'subscribe2')));
37
- return sprintf('%1$s %2$s', $item['email'], $this->row_actions($actions));
38
- } else {
39
- global $mysubscribe2;
40
- if ( '0' === $mysubscribe2->is_public($item['email']) ) {
41
- return sprintf('<span style="color:#FF0000">%1$s</span>', $item['email']);
42
- } else {
43
- return sprintf('%1$s', $item['email']);
44
- }
45
- }
46
- }
47
-
48
- function column_cb($item) {
49
- return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_args['singular'], $item['email']);
50
- }
51
-
52
- function get_columns() {
53
- global $current_tab;
54
- if ( $current_tab == 'registered' ) {
55
- $columns = array('email' => _x('Email', 'column name', 'subscribe2'));
56
- } else {
57
- $columns = array(
58
- 'cb' => '<input type="checkbox" />',
59
- 'email' => _x('Email', 'column name', 'subscribe2'),
60
- 'date' => _x('Date', 'column name', 'subscribe2')
61
- );
62
- }
63
- return $columns;
64
- }
65
-
66
- function get_sortable_columns() {
67
- global $current_tab;
68
- if ( $current_tab == 'registered' ) {
69
- $sortable_columns = array('email' => array('email', true));
70
- } else {
71
- $sortable_columns = array(
72
- 'email' => array('email', true),
73
- 'date' => array('date', false)
74
- );
75
- }
76
- return $sortable_columns;
77
- }
78
-
79
- function get_bulk_actions() {
80
- global $current_tab;
81
- if ( $current_tab == 'registered' ) {
82
- return array();
83
- } else {
84
- $actions = array(
85
- 'delete' => __('Delete', 'subscribe2'),
86
- 'toggle' => __('Toggle', 'subscribe2')
87
- );
88
- return $actions;
89
- }
90
- }
91
-
92
- function pagination( $which ) {
93
- if ( empty( $this->_pagination_args ) )
94
- return;
95
-
96
- extract( $this->_pagination_args, EXTR_SKIP );
97
-
98
- $output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items, 'subscribe2' ), number_format_i18n( $total_items ) ) . '</span>';
99
-
100
- if ( isset($_POST['what']) ) {
101
- $current = 1;
102
- } else {
103
- $current = $this->get_pagenum();
104
- }
105
-
106
- if ( version_compare($GLOBALS['wp_version'], '3.5', '<') ) {
107
- $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
108
- } else {
109
- $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
110
- }
111
-
112
- $current_url = remove_query_arg( array('hotkeys_highlight_last', 'hotkeys_highlight_first'), $current_url );
113
-
114
- if ( isset($what) ) {
115
- $current_url = add_query_arg( array('what' => $what), $current_url );
116
- } elseif ( isset($_REQUEST['what']) ) {
117
- $current_url = add_query_arg( array('what' => $_REQUEST['what']), $current_url );
118
- }
119
-
120
- $page_links = array();
121
-
122
- $disable_first = $disable_last = '';
123
- if ( $current == 1 )
124
- $disable_first = ' disabled';
125
- if ( $current == $total_pages )
126
- $disable_last = ' disabled';
127
-
128
- $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
129
- 'first-page' . $disable_first,
130
- esc_attr__('Go to the first page', 'subscribe2'),
131
- esc_url( remove_query_arg( 'paged', $current_url ) ),
132
- '&laquo;'
133
- );
134
-
135
- $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
136
- 'prev-page' . $disable_first,
137
- esc_attr__('Go to the previous page', 'subscribe2'),
138
- esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
139
- '&lsaquo;'
140
- );
141
-
142
- if ( 'bottom' == $which )
143
- $html_current_page = $current;
144
- else
145
- $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='paged' value='%s' size='%d' />",
146
- esc_attr__('Current page', 'subscribe2'),
147
- $current,
148
- strlen( $total_pages )
149
- );
150
-
151
- $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
152
- $page_links[] = '<span class="paging-input">' . sprintf( _x('%1$s of %2$s', 'paging', 'subscribe2'), $html_current_page, $html_total_pages ) . '</span>';
153
-
154
- $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
155
- 'next-page' . $disable_last,
156
- esc_attr__('Go to the next page', 'subscribe2'),
157
- esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
158
- '&rsaquo;'
159
- );
160
-
161
- $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
162
- 'last-page' . $disable_last,
163
- esc_attr__('Go to the last page', 'subscribe2'),
164
- esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
165
- '&raquo;'
166
- );
167
-
168
- $pagination_links_class = 'pagination-links';
169
- if ( ! empty( $infinite_scroll ) )
170
- $pagination_links_class = ' hide-if-js';
171
- $output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
172
-
173
- if ( $total_pages )
174
- $page_class = $total_pages < 2 ? ' one-page' : '';
175
- else
176
- $page_class = ' no-pages';
177
-
178
- $this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
179
-
180
- echo $this->_pagination;
181
- }
182
-
183
- function prepare_items() {
184
- global $mysubscribe2, $subscribers, $current_tab;
185
- if ( is_int($mysubscribe2->subscribe2_options['entries']) ) {
186
- $per_page = $mysubscribe2->subscribe2_options['entries'];
187
- } else {
188
- $per_page = 25;
189
- }
190
-
191
- $columns = $this->get_columns();
192
- $hidden = array();
193
- $sortable = $this->get_sortable_columns();
194
- $this->_column_headers = array($columns, $hidden, $sortable);
195
-
196
- $data = array();
197
- if ( $current_tab == 'public' ) {
198
- foreach((array)$subscribers as $email) {
199
- $data[] = array('email' => $email, 'date' => $mysubscribe2->signup_date($email));
200
- }
201
- } else {
202
- foreach((array)$subscribers as $email) {
203
- $data[] = array('email' => $email);
204
- }
205
- }
206
-
207
- function usort_reorder($a,$b) {
208
- $orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'email';
209
- $order = (!empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'asc';
210
- $result = strcasecmp($a[$orderby], $b[$orderby]);
211
- return ($order==='asc') ? $result : -$result;
212
- }
213
- usort($data, 'usort_reorder');
214
-
215
- if ( isset($_POST['what']) ) {
216
- $current_page = 1;
217
- } else {
218
- $current_page = $this->get_pagenum();
219
- }
220
- $total_items = count($data);
221
- $data = array_slice($data,(($current_page-1)*$per_page),$per_page);
222
- $this->items = $data;
223
-
224
- $this->set_pagination_args( array(
225
- 'total_items' => $total_items,
226
- 'per_page' => $per_page,
227
- 'total_pages' => ceil($total_items/$per_page)
228
- ) );
229
- }
230
- }
231
?>
1
+ <?php
2
+ class Subscribe2_List_Table extends WP_List_Table {
3
+ function __construct() {
4
+ global $status, $page;
5
+
6
+ parent::__construct( array(
7
+ 'singular' => 'subscriber',
8
+ 'plural' => 'subscribers',
9
+ 'ajax' => false
10
+ ) );
11
+ }
12
+
13
+ function column_default($item, $column_name) {
14
+ global $current_tab;
15
+ if ( $current_tab == 'registered' ) {
16
+ switch($column_name) {
17
+ case 'email':
18
+ return $item[$column_name];
19
+ default:
20
+ return print_r($item,true);
21
+ }
22
+ } else {
23
+ switch($column_name) {
24
+ case 'email':
25
+ case 'date':
26
+ return $item[$column_name];
27
+ default:
28
+ return print_r($item,true);
29
+ }
30
+ }
31
+ }
32
+
33
+ function column_email($item) {
34
+ global $current_tab;
35
+ if ( $current_tab == 'registered' ) {
36
+ $actions = array('edit' => sprintf('<a href="?page=%s&amp;email=%s">%s</a>', 's2', $item['email'], __('Edit', 'subscribe2')));
37
+ return sprintf('%1$s %2$s', $item['email'], $this->row_actions($actions));
38
+ } else {
39
+ global $mysubscribe2;
40
+ if ( '0' === $mysubscribe2->is_public($item['email']) ) {
41
+ return sprintf('<span style="color:#FF0000"><abbr title="' . $mysubscribe2->signup_ip($item['email']) . '">%1$s</abbr></span>', $item['email']);
42
+ } else {
43
+ return sprintf('<abbr title="' . $mysubscribe2->signup_ip($item['email']) . '">%1$s</abbr>', $item['email']);
44
+ }
45
+ }
46
+ }
47
+
48
+ function column_cb($item) {
49
+ return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_args['singular'], $item['email']);
50
+ }
51
+
52
+ function get_columns() {
53
+ global $current_tab;
54
+ if ( $current_tab == 'registered' ) {
55
+ if (is_multisite()) {
56
+ $columns = array(
57
+ 'email' => _x('Email', 'column name', 'subscribe2')
58
+ );
59
+ } else {
60
+ $columns = array(
61
+ 'cb' => '<input type="checkbox" />',
62
+ 'email' => _x('Email', 'column name', 'subscribe2')
63
+ );
64
+ }
65
+ } else {
66
+ $columns = array(
67
+ 'cb' => '<input type="checkbox" />',
68
+ 'email' => _x('Email', 'column name', 'subscribe2'),
69
+ 'date' => _x('Date', 'column name', 'subscribe2')
70
+ );
71
+ }
72
+ return $columns;
73
+ }
74
+
75
+ function get_sortable_columns() {
76
+ global $current_tab;
77
+ if ( $current_tab == 'registered' ) {
78
+ $sortable_columns = array('email' => array('email', true));
79
+ } else {
80
+ $sortable_columns = array(
81
+ 'email' => array('email', true),
82
+ 'date' => array('date', false)
83
+ );
84
+ }
85
+ return $sortable_columns;
86
+ }
87
+
88
+ function get_bulk_actions() {
89
+ global $current_tab;
90
+ if ( $current_tab == 'registered' ) {
91
+ if (is_multisite()) {
92
+ return array();
93
+ } else {
94
+ return array(
95
+ 'delete' => __('Delete', 'subscribe2')
96
+ );
97
+ }
98
+ } else {
99
+ $actions = array(
100
+ 'delete' => __('Delete', 'subscribe2'),
101
+ 'toggle' => __('Toggle', 'subscribe2')
102
+ );
103
+ return $actions;
104
+ }
105
+ }
106
+
107
+ function pagination( $which ) {
108
+ if ( empty( $this->_pagination_args ) )
109
+ return;
110
+
111
+ extract( $this->_pagination_args, EXTR_SKIP );
112
+
113
+ $output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items, 'subscribe2' ), number_format_i18n( $total_items ) ) . '</span>';
114
+
115
+ if ( isset($_POST['what']) ) {
116
+ $current = 1;
117
+ } else {
118
+ $current = $this->get_pagenum();
119
+ }
120
+
121
+ if ( version_compare($GLOBALS['wp_version'], '3.5', '<') ) {
122
+ $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
123
+ } else {
124
+ $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
125
+ }
126
+
127
+ $current_url = remove_query_arg( array('hotkeys_highlight_last', 'hotkeys_highlight_first'), $current_url );