Version Description
- Fixed the referrer attribute on shortcodes
Download this release
Release Info
Developer | satollo |
Plugin | Newsletter |
Version | 3.7.5 |
Comparing to | |
See all releases |
Code changes from version 3.7.3 to 3.7.5
- admin.css +2 -2
- api/add.php +5 -2
- do/subscribe.php +5 -3
- emails/create.php +4 -1
- emails/edit.php +28 -22
- emails/emails.php +16 -5
- emails/themes/blank/theme-options.php +6 -1
- emails/themes/blank/theme.php +35 -5
- includes/controls.php +5 -3
- plugin.php +56 -26
- readme.txt +18 -0
- statistics/statistics.php +5 -0
- subscription/options.php +12 -0
- subscription/profile.php +12 -17
- subscription/styles/shortcode/default.css +63 -0
- subscription/subscription.php +119 -25
- todo.txt +0 -12
- widget.php +2 -0
admin.css
CHANGED
@@ -699,8 +699,8 @@
|
|
699 |
vertical-align: initial;
|
700 |
}
|
701 |
.wrap {
|
702 |
-
background-color: white
|
703 |
-
padding: 10px
|
704 |
}
|
705 |
|
706 |
.wrap td a {
|
699 |
vertical-align: initial;
|
700 |
}
|
701 |
.wrap {
|
702 |
+
/*background-color: white;*/
|
703 |
+
/*padding: 10px;*/
|
704 |
}
|
705 |
|
706 |
.wrap td a {
|
api/add.php
CHANGED
@@ -5,10 +5,13 @@ include '../../../../wp-load.php';
|
|
5 |
if (!isset($newsletter)) $newsletter = new Newsletter();
|
6 |
|
7 |
$key = stripslashes($_REQUEST['nk']);
|
8 |
-
if (empty(
|
9 |
die('Wrong API key');
|
|
|
10 |
|
11 |
-
if (!is_email($_REQUEST['ne']))
|
|
|
|
|
12 |
|
13 |
$subscriber = array();
|
14 |
$subscriber['name'] = stripslashes($_REQUEST['nn']);
|
5 |
if (!isset($newsletter)) $newsletter = new Newsletter();
|
6 |
|
7 |
$key = stripslashes($_REQUEST['nk']);
|
8 |
+
if (empty($newsletter->options['api_key']) || $key != $newsletter->options['api_key']) {
|
9 |
die('Wrong API key');
|
10 |
+
}
|
11 |
|
12 |
+
if (!is_email($_REQUEST['ne'])) {
|
13 |
+
die('Wrong email');
|
14 |
+
}
|
15 |
|
16 |
$subscriber = array();
|
17 |
$subscriber['name'] = stripslashes($_REQUEST['nn']);
|
do/subscribe.php
CHANGED
@@ -12,7 +12,9 @@ unset($_REQUEST['na']);
|
|
12 |
unset($_POST['na']);
|
13 |
unset($_GET['na']);
|
14 |
|
15 |
-
|
|
|
|
|
16 |
|
17 |
$module = NewsletterSubscription::instance();
|
18 |
if (!isset($module->options['antibot'])) $module->options['antibot'] = 0;
|
@@ -42,12 +44,12 @@ else {
|
|
42 |
if (is_array($value)) {
|
43 |
foreach ($value as $element) {
|
44 |
?>
|
45 |
-
|
46 |
<?php
|
47 |
}
|
48 |
} else {
|
49 |
?>
|
50 |
-
<input type="hidden" name="<?php echo esc_attr($name); ?>" value="<?php echo esc_attr($value); ?>">
|
51 |
<?php
|
52 |
}
|
53 |
?>
|
12 |
unset($_POST['na']);
|
13 |
unset($_GET['na']);
|
14 |
|
15 |
+
if (!defined('ABSPATH')) {
|
16 |
+
require_once '../../../../wp-load.php';
|
17 |
+
}
|
18 |
|
19 |
$module = NewsletterSubscription::instance();
|
20 |
if (!isset($module->options['antibot'])) $module->options['antibot'] = 0;
|
44 |
if (is_array($value)) {
|
45 |
foreach ($value as $element) {
|
46 |
?>
|
47 |
+
<input type="hidden" name="<?php echo esc_attr($name); ?>[]" value="<?php echo esc_attr(stripslashes($element)); ?>">
|
48 |
<?php
|
49 |
}
|
50 |
} else {
|
51 |
?>
|
52 |
+
<input type="hidden" name="<?php echo esc_attr($name); ?>" value="<?php echo esc_attr(stripslashes($value)); ?>">
|
53 |
<?php
|
54 |
}
|
55 |
?>
|
emails/create.php
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
3 |
require_once '../../../../wp-load.php';
|
4 |
|
5 |
if (!is_user_logged_in()) die();
|
@@ -15,7 +18,7 @@ if ($controls->is_action('create')) {
|
|
15 |
|
16 |
$email = array();
|
17 |
$email['status'] = 'new';
|
18 |
-
$email['subject'] = __('Here the email subject', 'newsletter-emails');
|
19 |
$email['track'] = 1;
|
20 |
|
21 |
$theme_options = $module->get_current_theme_options();
|
1 |
<?php
|
2 |
|
3 |
+
// Stops WP Super Cache which removes the logged_in cookie
|
4 |
+
$_GET['preview'] = 'true';
|
5 |
+
|
6 |
require_once '../../../../wp-load.php';
|
7 |
|
8 |
if (!is_user_logged_in()) die();
|
18 |
|
19 |
$email = array();
|
20 |
$email['status'] = 'new';
|
21 |
+
$email['subject'] = ''; //__('Here the email subject', 'newsletter-emails');
|
22 |
$email['track'] = 1;
|
23 |
|
24 |
$theme_options = $module->get_current_theme_options();
|
emails/edit.php
CHANGED
@@ -56,15 +56,17 @@ if ($controls->is_action('test') || $controls->is_action('save') || $controls->i
|
|
56 |
|
57 |
$email['options'] = serialize($email['options']);
|
58 |
|
59 |
-
if (is_array($controls->data['preferences']))
|
60 |
$email['preferences'] = implode(',', $controls->data['preferences']);
|
61 |
-
else
|
62 |
$email['preferences'] = '';
|
|
|
63 |
|
64 |
-
if (is_array($controls->data['sex']))
|
65 |
$email['sex'] = implode(',', $controls->data['sex']);
|
66 |
-
else
|
67 |
$email['sex'] = '';
|
|
|
68 |
|
69 |
// Before send, we build the query to extract subscriber, so the delivery engine does not
|
70 |
// have to worry about the email parameters
|
@@ -111,13 +113,11 @@ if ($controls->is_action('test') || $controls->is_action('save') || $controls->i
|
|
111 |
}
|
112 |
|
113 |
$email['query'] = $query;
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
$
|
118 |
}
|
119 |
-
$email['sent'] = 0;
|
120 |
-
$email['last_id'] = 0;
|
121 |
$email['send_on'] = $controls->data['send_on'];
|
122 |
|
123 |
if ($controls->is_action('editor')) {
|
@@ -138,10 +138,14 @@ if ($controls->is_action('test') || $controls->is_action('save') || $controls->i
|
|
138 |
}
|
139 |
|
140 |
if ($controls->is_action('send')) {
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
|
|
145 |
}
|
146 |
|
147 |
if ($controls->is_action('pause')) {
|
@@ -155,9 +159,8 @@ if ($controls->is_action('continue')) {
|
|
155 |
}
|
156 |
|
157 |
if ($controls->is_action('abort')) {
|
158 |
-
$wpdb->query("update " . NEWSLETTER_EMAILS_TABLE . " set last_id=0,
|
159 |
$email['status'] = 'new';
|
160 |
-
$email['total'] = 0;
|
161 |
$email['sent'] = 0;
|
162 |
$email['last_id'] = 0;
|
163 |
$controls->messages = "Sending aborted.";
|
@@ -249,7 +252,7 @@ if ($email['editor'] == 0) {
|
|
249 |
<?php $controls->show(); ?>
|
250 |
|
251 |
<form method="post" action="" id="newsletter-form">
|
252 |
-
<?php $controls->init(); ?>
|
253 |
|
254 |
<p class="submit">
|
255 |
<?php if ($email['status'] != 'sending' && $email['status'] != 'sent') $controls->button('save', 'Save'); ?>
|
@@ -258,8 +261,8 @@ if ($email['editor'] == 0) {
|
|
258 |
<?php if ($email['status'] == 'new') $controls->button_confirm('send', 'Send', 'Start a real delivery?'); ?>
|
259 |
<?php if ($email['status'] == 'sending') $controls->button_confirm('pause', 'Pause', 'Pause the delivery?'); ?>
|
260 |
<?php if ($email['status'] == 'paused') $controls->button_confirm('continue', 'Continue', 'Continue the delivery?'); ?>
|
261 |
-
<?php if ($email['status']
|
262 |
-
<?php $controls->button_confirm('editor', 'Save and switch to ' . ($email['editor'] == 0 ? 'HTML source' : 'visual') . ' editor', 'Sure?'); ?>
|
263 |
</p>
|
264 |
|
265 |
<div id="tabs">
|
@@ -314,9 +317,9 @@ if ($email['editor'] == 0) {
|
|
314 |
<th><?php _e('Gender', 'newsletter-emails'); ?></th>
|
315 |
<td>
|
316 |
<?php $controls->checkboxes_group('sex', array('f' => 'Women', 'm' => 'Men', 'n' => 'Not specified')); ?>
|
317 |
-
<
|
318 |
Leaving all gender options unselected disable this filter.
|
319 |
-
</
|
320 |
</td>
|
321 |
</tr>
|
322 |
<tr valign="top">
|
@@ -395,7 +398,10 @@ if ($email['editor'] == 0) {
|
|
395 |
<tr valign="top">
|
396 |
<th><?php _e('Send on', 'newsletter-emails') ?></th>
|
397 |
<td>
|
398 |
-
<?php $controls->datetime('send_on'); ?> (<?php echo date_i18n(get_option('date_format') . ' ' . get_option('time_format')); ?>
|
|
|
|
|
|
|
399 |
</td>
|
400 |
</tr>
|
401 |
</table>
|
56 |
|
57 |
$email['options'] = serialize($email['options']);
|
58 |
|
59 |
+
if (is_array($controls->data['preferences'])) {
|
60 |
$email['preferences'] = implode(',', $controls->data['preferences']);
|
61 |
+
} else {
|
62 |
$email['preferences'] = '';
|
63 |
+
}
|
64 |
|
65 |
+
if (is_array($controls->data['sex'])) {
|
66 |
$email['sex'] = implode(',', $controls->data['sex']);
|
67 |
+
} else {
|
68 |
$email['sex'] = '';
|
69 |
+
}
|
70 |
|
71 |
// Before send, we build the query to extract subscriber, so the delivery engine does not
|
72 |
// have to worry about the email parameters
|
113 |
}
|
114 |
|
115 |
$email['query'] = $query;
|
116 |
+
$email['total'] = $wpdb->get_var(str_replace('*', 'count(*)', $query));
|
117 |
+
|
118 |
+
if ($controls->is_action('send') && $controls->data['send_on'] < time()) {
|
119 |
+
$controls->data['send_on'] = time();
|
120 |
}
|
|
|
|
|
121 |
$email['send_on'] = $controls->data['send_on'];
|
122 |
|
123 |
if ($controls->is_action('editor')) {
|
138 |
}
|
139 |
|
140 |
if ($controls->is_action('send')) {
|
141 |
+
// Todo subject check
|
142 |
+
if ($email['subject'] == '') {
|
143 |
+
$controls->errors = 'Ops, you missed to write the subject!';
|
144 |
+
} else {
|
145 |
+
$wpdb->update(NEWSLETTER_EMAILS_TABLE, array('status' => 'sending'), array('id' => $email_id));
|
146 |
+
$email['status'] = 'sending';
|
147 |
+
$controls->messages .= "Email added to the queue.";
|
148 |
+
}
|
149 |
}
|
150 |
|
151 |
if ($controls->is_action('pause')) {
|
159 |
}
|
160 |
|
161 |
if ($controls->is_action('abort')) {
|
162 |
+
$wpdb->query("update " . NEWSLETTER_EMAILS_TABLE . " set last_id=0, sent=0, status='new' where id=" . $email_id);
|
163 |
$email['status'] = 'new';
|
|
|
164 |
$email['sent'] = 0;
|
165 |
$email['last_id'] = 0;
|
166 |
$controls->messages = "Sending aborted.";
|
252 |
<?php $controls->show(); ?>
|
253 |
|
254 |
<form method="post" action="" id="newsletter-form">
|
255 |
+
<?php $controls->init(array('cookie_name'=>'newsletter_emails_edit_tab')); ?>
|
256 |
|
257 |
<p class="submit">
|
258 |
<?php if ($email['status'] != 'sending' && $email['status'] != 'sent') $controls->button('save', 'Save'); ?>
|
261 |
<?php if ($email['status'] == 'new') $controls->button_confirm('send', 'Send', 'Start a real delivery?'); ?>
|
262 |
<?php if ($email['status'] == 'sending') $controls->button_confirm('pause', 'Pause', 'Pause the delivery?'); ?>
|
263 |
<?php if ($email['status'] == 'paused') $controls->button_confirm('continue', 'Continue', 'Continue the delivery?'); ?>
|
264 |
+
<?php if ($email['status'] == 'paused') $controls->button_confirm('abort', 'Abort', 'Abort the delivery?'); ?>
|
265 |
+
<?php if ($email['status'] != 'sending' && $email['status'] != 'sent') $controls->button_confirm('editor', 'Save and switch to ' . ($email['editor'] == 0 ? 'HTML source' : 'visual') . ' editor', 'Sure?'); ?>
|
266 |
</p>
|
267 |
|
268 |
<div id="tabs">
|
317 |
<th><?php _e('Gender', 'newsletter-emails'); ?></th>
|
318 |
<td>
|
319 |
<?php $controls->checkboxes_group('sex', array('f' => 'Women', 'm' => 'Men', 'n' => 'Not specified')); ?>
|
320 |
+
<p class="description">
|
321 |
Leaving all gender options unselected disable this filter.
|
322 |
+
</p>
|
323 |
</td>
|
324 |
</tr>
|
325 |
<tr valign="top">
|
398 |
<tr valign="top">
|
399 |
<th><?php _e('Send on', 'newsletter-emails') ?></th>
|
400 |
<td>
|
401 |
+
<?php $controls->datetime('send_on'); ?> (now: <?php echo date_i18n(get_option('date_format') . ' ' . get_option('time_format')); ?>)
|
402 |
+
<p class="description">
|
403 |
+
If the current date and time are wrong, check your timezone on the General WordPress settings.
|
404 |
+
</p>
|
405 |
</td>
|
406 |
</tr>
|
407 |
</table>
|
emails/emails.php
CHANGED
@@ -20,6 +20,14 @@ class NewsletterEmails extends NewsletterModule {
|
|
20 |
function __construct() {
|
21 |
$this->themes = new NewsletterThemes('emails');
|
22 |
parent::__construct('emails', '1.1.1');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
|
25 |
function upgrade() {
|
@@ -52,9 +60,11 @@ class NewsletterEmails extends NewsletterModule {
|
|
52 |
* Returns the current selected theme.
|
53 |
*/
|
54 |
function get_current_theme() {
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
58 |
}
|
59 |
|
60 |
function get_current_theme_options() {
|
@@ -62,7 +72,7 @@ class NewsletterEmails extends NewsletterModule {
|
|
62 |
// main options merge
|
63 |
$main_options = Newsletter::instance()->options;
|
64 |
foreach ($main_options as $key => $value) {
|
65 |
-
$theme_options['main_'
|
66 |
}
|
67 |
return $theme_options;
|
68 |
}
|
@@ -100,7 +110,8 @@ class NewsletterEmails extends NewsletterModule {
|
|
100 |
$email['type'] = 'message';
|
101 |
$query = "select * from " . NEWSLETTER_USERS_TABLE . " where status='C'";
|
102 |
|
103 |
-
if ($email['list'] != 0)
|
|
|
104 |
$email['preferences'] = $email['list'];
|
105 |
|
106 |
if (!empty($email['sex'])) {
|
20 |
function __construct() {
|
21 |
$this->themes = new NewsletterThemes('emails');
|
22 |
parent::__construct('emails', '1.1.1');
|
23 |
+
|
24 |
+
$action = isset($_REQUEST['na']) ? $_REQUEST['na'] : '';
|
25 |
+
if (!empty($action)) {
|
26 |
+
if ($action == 'v') {
|
27 |
+
include dirname(__FILE__ . '/../do/view.php');
|
28 |
+
}
|
29 |
+
return;
|
30 |
+
}
|
31 |
}
|
32 |
|
33 |
function upgrade() {
|
60 |
* Returns the current selected theme.
|
61 |
*/
|
62 |
function get_current_theme() {
|
63 |
+
$theme = $this->options['theme'];
|
64 |
+
if (empty($theme))
|
65 |
+
return 'blank';
|
66 |
+
else
|
67 |
+
return $theme;
|
68 |
}
|
69 |
|
70 |
function get_current_theme_options() {
|
72 |
// main options merge
|
73 |
$main_options = Newsletter::instance()->options;
|
74 |
foreach ($main_options as $key => $value) {
|
75 |
+
$theme_options['main_' . $key] = $value;
|
76 |
}
|
77 |
return $theme_options;
|
78 |
}
|
110 |
$email['type'] = 'message';
|
111 |
$query = "select * from " . NEWSLETTER_USERS_TABLE . " where status='C'";
|
112 |
|
113 |
+
if ($email['list'] != 0)
|
114 |
+
$query .= " and list_" . $email['list'] . "=1";
|
115 |
$email['preferences'] = $email['list'];
|
116 |
|
117 |
if (!empty($email['sex'])) {
|
emails/themes/blank/theme-options.php
CHANGED
@@ -1 +1,6 @@
|
|
1 |
-
<
|
|
|
|
|
|
|
|
|
|
1 |
+
<table class="form-table">
|
2 |
+
<tr>
|
3 |
+
<th>Disable social links</th>
|
4 |
+
<td><?php $controls->checkbox('theme_social_disable', ''); ?></td>
|
5 |
+
</tr>
|
6 |
+
</table>
|
emails/themes/blank/theme.php
CHANGED
@@ -1,6 +1,36 @@
|
|
1 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
<p>
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<html>
|
2 |
+
<head>
|
3 |
+
<style>
|
4 |
+
body {
|
5 |
+
font-family: sans-serif;
|
6 |
+
font-size: 12px;
|
7 |
+
}
|
8 |
+
</style>
|
9 |
+
</head>
|
10 |
+
<body>
|
11 |
+
<h1>Your awesome title</h1>
|
12 |
|
13 |
+
<p>
|
14 |
+
Hi {name} (but you should remove that if you're not collecting subscriber names),
|
15 |
+
</p>
|
16 |
+
|
17 |
+
<p>
|
18 |
+
here the forewords of your shiny new newsletter. Most of the times a simple layout is the best.
|
19 |
+
</p>
|
20 |
+
<h2>There is more for you!</h2>
|
21 |
+
|
22 |
+
<p>Still not secure to sign up for our premium service? Even with a standard service plan you'll receive our t-shirt!</p>
|
23 |
+
|
24 |
+
<p>
|
25 |
+
Goodbye!
|
26 |
+
</p>
|
27 |
+
|
28 |
+
<?php include WP_PLUGIN_DIR . '/newsletter/emails/themes/default/social_main.php'; ?>
|
29 |
+
|
30 |
+
<hr>
|
31 |
+
<p>
|
32 |
+
To unsubscribe <a href="{unsubscription_url}">click here</a>, to edit your subscription
|
33 |
+
<a href="{profile_url}">click here</a>.
|
34 |
+
</p>
|
35 |
+
</body>
|
36 |
+
</html>
|
includes/controls.php
CHANGED
@@ -612,7 +612,9 @@ class NewsletterControls {
|
|
612 |
$this->select($name, $days);
|
613 |
}
|
614 |
|
615 |
-
function init() {
|
|
|
|
|
616 |
echo '<script type="text/javascript">
|
617 |
jQuery(document).ready(function(){
|
618 |
jQuery("textarea.dynamic").focus(function() {
|
@@ -620,9 +622,9 @@ class NewsletterControls {
|
|
620 |
jQuery(this).css("height", "400px");
|
621 |
});
|
622 |
tabs = jQuery("#tabs").tabs({
|
623 |
-
active : jQuery.cookie("
|
624 |
activate : function( event, ui ){
|
625 |
-
jQuery.cookie("
|
626 |
}
|
627 |
});
|
628 |
});
|
612 |
$this->select($name, $days);
|
613 |
}
|
614 |
|
615 |
+
function init($options = array()) {
|
616 |
+
$cookie_name = 'newsletter_tab';
|
617 |
+
if (isset($options['cookie_name'])) $cookie_name = $options['cookie_name'];
|
618 |
echo '<script type="text/javascript">
|
619 |
jQuery(document).ready(function(){
|
620 |
jQuery("textarea.dynamic").focus(function() {
|
622 |
jQuery(this).css("height", "400px");
|
623 |
});
|
624 |
tabs = jQuery("#tabs").tabs({
|
625 |
+
active : jQuery.cookie("' . $cookie_name . '"),
|
626 |
activate : function( event, ui ){
|
627 |
+
jQuery.cookie("' . $cookie_name . '", ui.newTab.index(),{expires: 1});
|
628 |
}
|
629 |
});
|
630 |
});
|
plugin.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Newsletter
|
5 |
Plugin URI: http://www.thenewsletterplugin.com/plugins/newsletter
|
6 |
Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="http://www.thenewsletterplugin.com/plugins/newsletter#update">this page</a> to know what's changed.</strong>
|
7 |
-
Version: 3.7.
|
8 |
Author: Stefano Lissa
|
9 |
Author URI: http://www.thenewsletterplugin.com
|
10 |
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
|
@@ -13,7 +13,7 @@
|
|
13 |
*/
|
14 |
|
15 |
// Used as dummy parameter on css and js links
|
16 |
-
define('NEWSLETTER_VERSION', '3.7.
|
17 |
|
18 |
global $wpdb, $newsletter;
|
19 |
|
@@ -442,7 +442,7 @@ class Newsletter extends NewsletterModule {
|
|
442 |
if (!$test && $this->limits_exceeded())
|
443 |
return false;
|
444 |
|
445 |
-
$headers = array('List-Unsubscribe' => '<' .
|
446 |
$headers['Precedence'] = 'bulk';
|
447 |
$headers['X-Newsletter-Email-Id'] = $email->id;
|
448 |
|
@@ -905,29 +905,59 @@ class Newsletter extends NewsletterModule {
|
|
905 |
$id_token = '&ni=' . $user->id . '&nt=' . $user->token;
|
906 |
$nk = $user->id . '-' . $user->token;
|
907 |
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
$text = $this->replace_url($text, '
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
931 |
}
|
932 |
|
933 |
for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
|
4 |
Plugin Name: Newsletter
|
5 |
Plugin URI: http://www.thenewsletterplugin.com/plugins/newsletter
|
6 |
Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="http://www.thenewsletterplugin.com/plugins/newsletter#update">this page</a> to know what's changed.</strong>
|
7 |
+
Version: 3.7.5
|
8 |
Author: Stefano Lissa
|
9 |
Author URI: http://www.thenewsletterplugin.com
|
10 |
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
|
13 |
*/
|
14 |
|
15 |
// Used as dummy parameter on css and js links
|
16 |
+
define('NEWSLETTER_VERSION', '3.7.5');
|
17 |
|
18 |
global $wpdb, $newsletter;
|
19 |
|
442 |
if (!$test && $this->limits_exceeded())
|
443 |
return false;
|
444 |
|
445 |
+
$headers = array('List-Unsubscribe' => '<' . home_url() . 'na=u&nk=' . $user->id . '-' . $user->token . '>');
|
446 |
$headers['Precedence'] = 'bulk';
|
447 |
$headers['X-Newsletter-Email-Id'] = $email->id;
|
448 |
|
905 |
$id_token = '&ni=' . $user->id . '&nt=' . $user->token;
|
906 |
$nk = $user->id . '-' . $user->token;
|
907 |
|
908 |
+
$options_subscription = NewsletterSubscription::instance()->options;
|
909 |
+
|
910 |
+
if (!empty($options_subscription['action_url'])) {
|
911 |
+
$home_url = home_url();
|
912 |
+
//$text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', self::add_qs(plugins_url('do.php', __FILE__), 'a=c' . $id_token));
|
913 |
+
$text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', $home_url . '?na=c&nk=' . $nk);
|
914 |
+
$text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', $home_url . '?na=u&nk=' . $nk);
|
915 |
+
//$text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', NEWSLETTER_URL . '/do/unsubscribe.php?nk=' . $nk);
|
916 |
+
$text = $this->replace_url($text, 'UNSUBSCRIPTION_URL', $home_url . '?na=uc&nk=' . $nk);
|
917 |
+
$text = $this->replace_url($text, 'CHANGE_URL', plugins_url('newsletter/do/change.php'));
|
918 |
+
|
919 |
+
// Obsolete.
|
920 |
+
$text = $this->replace_url($text, 'FOLLOWUP_SUBSCRIPTION_URL', self::add_qs($base, 'nm=fs' . $id_token));
|
921 |
+
$text = $this->replace_url($text, 'FOLLOWUP_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=fu' . $id_token));
|
922 |
+
$text = $this->replace_url($text, 'FEED_SUBSCRIPTION_URL', self::add_qs($base, 'nm=es' . $id_token));
|
923 |
+
$text = $this->replace_url($text, 'FEED_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=eu' . $id_token));
|
924 |
+
|
925 |
+
|
926 |
+
if (empty($options_profile['profile_url']))
|
927 |
+
$text = $this->replace_url($text, 'PROFILE_URL', $home_url . '?na=p&nk=' . $nk);
|
928 |
+
else
|
929 |
+
$text = $this->replace_url($text, 'PROFILE_URL', self::add_qs($options_profile['profile_url'], 'ni=' . $user->id . '&nt=' . $user->token));
|
930 |
+
|
931 |
+
//$text = $this->replace_url($text, 'UNLOCK_URL', self::add_qs($this->options_main['lock_url'], 'nm=m' . $id_token));
|
932 |
+
$text = $this->replace_url($text, 'UNLOCK_URL', $home_url . '?na=ul&nk=' . $nk);
|
933 |
+
if (!empty($email_id)) {
|
934 |
+
$text = $this->replace_url($text, 'EMAIL_URL', $home_url . '?na=v&id=' . $email_id . '&nk=' . $nk);
|
935 |
+
}
|
936 |
+
} else {
|
937 |
+
//$text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', self::add_qs(plugins_url('do.php', __FILE__), 'a=c' . $id_token));
|
938 |
+
$text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', plugins_url('newsletter/do/confirm.php') . '?nk=' . $nk);
|
939 |
+
$text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', plugins_url('newsletter/do/unsubscribe.php') . '?nk=' . $nk);
|
940 |
+
//$text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', NEWSLETTER_URL . '/do/unsubscribe.php?nk=' . $nk);
|
941 |
+
$text = $this->replace_url($text, 'UNSUBSCRIPTION_URL', plugins_url('newsletter/do/unsubscription.php') . '?nk=' . $nk);
|
942 |
+
$text = $this->replace_url($text, 'CHANGE_URL', plugins_url('newsletter/do/change.php'));
|
943 |
+
|
944 |
+
// Obsolete.
|
945 |
+
$text = $this->replace_url($text, 'FOLLOWUP_SUBSCRIPTION_URL', self::add_qs($base, 'nm=fs' . $id_token));
|
946 |
+
$text = $this->replace_url($text, 'FOLLOWUP_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=fu' . $id_token));
|
947 |
+
$text = $this->replace_url($text, 'FEED_SUBSCRIPTION_URL', self::add_qs($base, 'nm=es' . $id_token));
|
948 |
+
$text = $this->replace_url($text, 'FEED_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=eu' . $id_token));
|
949 |
+
|
950 |
+
|
951 |
+
if (empty($options_profile['profile_url']))
|
952 |
+
$text = $this->replace_url($text, 'PROFILE_URL', plugins_url('newsletter/do/profile.php') . '?nk=' . $nk);
|
953 |
+
else
|
954 |
+
$text = $this->replace_url($text, 'PROFILE_URL', self::add_qs($options_profile['profile_url'], 'ni=' . $user->id . '&nt=' . $user->token));
|
955 |
+
|
956 |
+
//$text = $this->replace_url($text, 'UNLOCK_URL', self::add_qs($this->options_main['lock_url'], 'nm=m' . $id_token));
|
957 |
+
$text = $this->replace_url($text, 'UNLOCK_URL', plugins_url('newsletter/do/unlock.php') . '?nk=' . $nk);
|
958 |
+
if (!empty($email_id)) {
|
959 |
+
$text = $this->replace_url($text, 'EMAIL_URL', plugins_url('newsletter/do/view.php') . '?id=' . $email_id . '&nk=' . $nk);
|
960 |
+
}
|
961 |
}
|
962 |
|
963 |
for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
|
readme.txt
CHANGED
@@ -61,6 +61,24 @@ No screen shots are available at this time.
|
|
61 |
|
62 |
* Added shortcodes for in page form building (beta): see the [plugin documentation](http://www.thenewsletterplugin.com/plugins/newsletter/newsletter-documentation).
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
= 3.7.2 =
|
65 |
|
66 |
* Fixed the editor issue on subscription steps panel
|
61 |
|
62 |
* Added shortcodes for in page form building (beta): see the [plugin documentation](http://www.thenewsletterplugin.com/plugins/newsletter/newsletter-documentation).
|
63 |
|
64 |
+
= 3.7.5 =
|
65 |
+
|
66 |
+
* Fixed the referrer attribute on shortcodes
|
67 |
+
|
68 |
+
= 3.7.4 =
|
69 |
+
|
70 |
+
* Added control to avoid the wp super cache caching on newsletter services
|
71 |
+
* Added the new action URL schema (see the subscription steps panel)
|
72 |
+
* Added confirmation_url attribute to the form short code
|
73 |
+
* Added referrer attribute to the form short code
|
74 |
+
* Newsletters now start with empty subject and it's require to write it
|
75 |
+
* Fixed the API add service key check
|
76 |
+
* Fixed a couple of PHP noticies on widget (when not configured)
|
77 |
+
|
78 |
+
= 3.7.3 =
|
79 |
+
|
80 |
+
* Fixed extra profile field rules and placeholder
|
81 |
+
|
82 |
= 3.7.2 =
|
83 |
|
84 |
* Fixed the editor issue on subscription steps panel
|
statistics/statistics.php
CHANGED
@@ -116,6 +116,11 @@ class NewsletterStatistics extends NewsletterModule {
|
|
116 |
if (strpos($href, '/newsletter/') !== false) {
|
117 |
return $matches[0];
|
118 |
}
|
|
|
|
|
|
|
|
|
|
|
119 |
// Do not relink anchors
|
120 |
if (substr($href, 0, 1) == '#') {
|
121 |
return $matches[0];
|
116 |
if (strpos($href, '/newsletter/') !== false) {
|
117 |
return $matches[0];
|
118 |
}
|
119 |
+
|
120 |
+
if (strpos($href, '?na=') !== false) {
|
121 |
+
return $matches[0];
|
122 |
+
}
|
123 |
+
|
124 |
// Do not relink anchors
|
125 |
if (substr($href, 0, 1) == '#') {
|
126 |
return $matches[0];
|
subscription/options.php
CHANGED
@@ -223,6 +223,18 @@ if ($controls->is_action()) {
|
|
223 |
<?php } ?>
|
224 |
</p>
|
225 |
</td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
</tr>
|
227 |
<?php /*
|
228 |
<tr valign="top">
|
223 |
<?php } ?>
|
224 |
</p>
|
225 |
</td>
|
226 |
+
</tr>
|
227 |
+
<tr valign="top">
|
228 |
+
<th>Action URLs</th>
|
229 |
+
<td>
|
230 |
+
<?php $controls->select('action_url', array(0=>__('Standard', 'newsletter-statistics'),
|
231 |
+
1=>__('Blog Home URL with parameters', 'newsletter-statistics'))) ?>
|
232 |
+
<p class="description">
|
233 |
+
How the URLs for unsubscription, profile editing and so on should look. Due to some spam filter
|
234 |
+
rules, the "Blog Home URL" should be safe but can conflict with plugins which removes the query string
|
235 |
+
parameters.
|
236 |
+
</p>
|
237 |
+
</td>
|
238 |
</tr>
|
239 |
<?php /*
|
240 |
<tr valign="top">
|
subscription/profile.php
CHANGED
@@ -22,23 +22,6 @@ if (!$controls->is_action()) {
|
|
22 |
$status = array(0 => 'Disabled/Private use', 1 => 'Only on profile page', 2 => 'Even on subscription forms');
|
23 |
$rules = array(0 => 'Optional', 1 => 'Required');
|
24 |
?>
|
25 |
-
<script type="text/javascript" src="<?php echo get_option('siteurl'); ?>/wp-content/plugins/newsletter/tiny_mce/tiny_mce.js"></script>
|
26 |
-
<script type="text/javascript">
|
27 |
-
tinyMCE.init({
|
28 |
-
mode: "specific_textareas",
|
29 |
-
editor_selector: "visual",
|
30 |
-
theme: "advanced",
|
31 |
-
theme_advanced_disable: "styleselect",
|
32 |
-
relative_urls: false,
|
33 |
-
remove_script_host: false,
|
34 |
-
theme_advanced_buttons3: "",
|
35 |
-
theme_advanced_toolbar_location: "top",
|
36 |
-
theme_advanced_resizing: true,
|
37 |
-
theme_advanced_statusbar_location: "bottom",
|
38 |
-
document_base_url: "<?php echo get_option('home'); ?>/",
|
39 |
-
content_css: "<?php echo get_option('blogurl'); ?>/wp-content/plugins/newsletter/editor.css?" + new Date().getTime()
|
40 |
-
});
|
41 |
-
</script>
|
42 |
|
43 |
<div class="wrap">
|
44 |
<?php $help_url = 'http://www.thenewsletterplugin.com/plugins/newsletter/subscription-module'; ?>
|
@@ -177,6 +160,18 @@ $rules = array(0 => 'Optional', 1 => 'Required');
|
|
177 |
or selection list. Fields of type "list" must be configured with a set of options, comma separated
|
178 |
like: "first option, second option, third option".
|
179 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
|
181 |
<table class="widefat">
|
182 |
<thead>
|
22 |
$status = array(0 => 'Disabled/Private use', 1 => 'Only on profile page', 2 => 'Even on subscription forms');
|
23 |
$rules = array(0 => 'Optional', 1 => 'Required');
|
24 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
<div class="wrap">
|
27 |
<?php $help_url = 'http://www.thenewsletterplugin.com/plugins/newsletter/subscription-module'; ?>
|
160 |
or selection list. Fields of type "list" must be configured with a set of options, comma separated
|
161 |
like: "first option, second option, third option".
|
162 |
</p>
|
163 |
+
<p>
|
164 |
+
The placeholder works only on HTML 5 compliant browsers.
|
165 |
+
</p>
|
166 |
+
|
167 |
+
<table class="form-table">
|
168 |
+
<tr>
|
169 |
+
<th>Error message</th>
|
170 |
+
<td>
|
171 |
+
<?php $controls->text('profile_error', 50); ?>
|
172 |
+
</td>
|
173 |
+
</tr>
|
174 |
+
</table>
|
175 |
|
176 |
<table class="widefat">
|
177 |
<thead>
|
subscription/styles/shortcode/default.css
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.newsletter-form {
|
2 |
+
width: 100%;
|
3 |
+
display: block;
|
4 |
+
margin: 15px 0;
|
5 |
+
border: 0;
|
6 |
+
padding: 0;
|
7 |
+
}
|
8 |
+
|
9 |
+
.newsletter-field {
|
10 |
+
clear: both;
|
11 |
+
text-align: left;
|
12 |
+
}
|
13 |
+
|
14 |
+
.newsletter-field label {
|
15 |
+
//display: inline-block;
|
16 |
+
display: block;
|
17 |
+
width: 135px;
|
18 |
+
font-size: 14px;
|
19 |
+
line-height: normal;
|
20 |
+
text-align: right;
|
21 |
+
margin-right: 15px;
|
22 |
+
}
|
23 |
+
|
24 |
+
.newsletter-field input, .newsletter-field select {
|
25 |
+
padding: 5px;
|
26 |
+
font-size: 14px;
|
27 |
+
margin-right: 0;
|
28 |
+
line-height: normal;
|
29 |
+
border: 1px solid rgba(0,0,0,.1);
|
30 |
+
border-radius: 2px;
|
31 |
+
}
|
32 |
+
|
33 |
+
.newsletter-field-preference label, .newsletter-field-privacy label {
|
34 |
+
text-align: left;
|
35 |
+
}
|
36 |
+
|
37 |
+
.newsletter-field-preference, .newsletter-field-privacy, .newsletter-field-button {
|
38 |
+
margin-left: 150px;
|
39 |
+
}
|
40 |
+
|
41 |
+
.newsletter-field-preference input {
|
42 |
+
margin-right: 10px;
|
43 |
+
}
|
44 |
+
|
45 |
+
.newsletter-privacy {
|
46 |
+
margin-right: 10px;
|
47 |
+
}
|
48 |
+
|
49 |
+
@media all and (max-width: 480px) {
|
50 |
+
.newsletter-field label {
|
51 |
+
display: block;
|
52 |
+
text-align: left;
|
53 |
+
width: 100%;
|
54 |
+
}
|
55 |
+
.newsletter-field-preference label, .newsletter-field-privacy label {
|
56 |
+
display: inline;
|
57 |
+
width: auto;
|
58 |
+
}
|
59 |
+
.newsletter-field-preference, .newsletter-field-privacy, .newsletter-field-button {
|
60 |
+
margin-left: 0px;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
subscription/subscription.php
CHANGED
@@ -20,7 +20,24 @@ class NewsletterSubscription extends NewsletterModule {
|
|
20 |
|
21 |
function __construct() {
|
22 |
parent::__construct('subscription', '1.1.2');
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
add_action('wp_login', array($this, 'hook_wp_login'));
|
25 |
|
26 |
// Must be called after the Newsletter::hook_init, since some constants are defined
|
@@ -32,6 +49,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
32 |
add_shortcode('newsletter_profile', array($this, 'shortcode_profile'));
|
33 |
add_shortcode('newsletter_subscription', array($this, 'shortcode_subscription'));
|
34 |
add_shortcode('newsletter_field', array($this, 'shortcode_field'));
|
|
|
35 |
|
36 |
$action = isset($_REQUEST['na']) ? $_REQUEST['na'] : '';
|
37 |
if (empty($action) || is_admin())
|
@@ -128,6 +146,10 @@ class NewsletterSubscription extends NewsletterModule {
|
|
128 |
$this->add_admin_page('forms', 'Forms');
|
129 |
}
|
130 |
|
|
|
|
|
|
|
|
|
131 |
/**
|
132 |
* This method has been redefined for compatibility with the old options naming. It would
|
133 |
* be better to change them instead. The subscription options should be named
|
@@ -498,12 +520,18 @@ class NewsletterSubscription extends NewsletterModule {
|
|
498 |
if (!is_object($user)) {
|
499 |
if (is_array($user))
|
500 |
$user = (object) $user;
|
501 |
-
else
|
502 |
$user = $newsletter->get_user($user);
|
|
|
503 |
}
|
504 |
|
505 |
-
if (!empty($alert))
|
506 |
$params = '&alert=' . urlencode($alert);
|
|
|
|
|
|
|
|
|
|
|
507 |
|
508 |
// Add exceptions for "profile" key.
|
509 |
// Is there a custom url?
|
@@ -549,8 +577,9 @@ class NewsletterSubscription extends NewsletterModule {
|
|
549 |
}
|
550 |
|
551 |
function get_message_key_from_request() {
|
552 |
-
if (empty($_GET['nm']))
|
553 |
return 'subscription';
|
|
|
554 |
$key = $_GET['nm'];
|
555 |
switch ($key) {
|
556 |
case 's': return 'confirmation';
|
@@ -618,6 +647,13 @@ class NewsletterSubscription extends NewsletterModule {
|
|
618 |
$buffer .= ' return false;' . "\n";
|
619 |
$buffer .= ' }' . "\n";
|
620 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
621 |
$buffer .= ' if (f.elements["ny"] && !f.elements["ny"].checked) {' . "\n";
|
622 |
$buffer .= ' alert("' . addslashes($options_profile['privacy_error']) . '");' . "\n";
|
623 |
$buffer .= ' return false;' . "\n";
|
@@ -631,23 +667,34 @@ class NewsletterSubscription extends NewsletterModule {
|
|
631 |
}
|
632 |
|
633 |
function shortcode_subscription($attrs, $content) {
|
|
|
|
|
|
|
|
|
634 |
if (isset($attrs['css'])) {
|
635 |
if (!empty($attrs['css'])) {
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
}
|
640 |
} else {
|
641 |
echo '<style scoped>';
|
642 |
include dirname(__FILE__) . '/styles/shortcode-default.css';
|
643 |
echo '</style>';
|
644 |
-
|
645 |
}
|
646 |
|
647 |
$options_profile = get_option('newsletter_profile');
|
648 |
|
649 |
-
$buffer = '<form method="post" action="' . plugins_url('newsletter/do/subscribe.php') . '" class="
|
650 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
651 |
//$content = str_replace("\r\n", "", $content);
|
652 |
$buffer .= do_shortcode($content);
|
653 |
|
@@ -657,13 +704,15 @@ class NewsletterSubscription extends NewsletterModule {
|
|
657 |
$label = $options_profile['subscribe'];
|
658 |
}
|
659 |
|
660 |
-
$
|
661 |
-
|
662 |
-
$
|
663 |
-
|
664 |
-
|
|
|
|
|
|
|
665 |
}
|
666 |
-
$buffer .= '</div>';
|
667 |
|
668 |
return $buffer;
|
669 |
}
|
@@ -683,6 +732,14 @@ class NewsletterSubscription extends NewsletterModule {
|
|
683 |
$buffer .= '<label for="">' . $options_profile['email'] . '</label>';
|
684 |
}
|
685 |
$buffer .= '<input class="newsletter-email" type="email" name="ne" required>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
686 |
$buffer .= '</div>';
|
687 |
return $buffer;
|
688 |
}
|
@@ -789,20 +846,22 @@ class NewsletterSubscription extends NewsletterModule {
|
|
789 |
$buffer .= '<label for="">' . $options_profile['profile_' . $number] . '</label>';
|
790 |
}
|
791 |
$placeholder = isset($attrs['placeholder']) ? $attrs['placeholder'] : $options_profile['profile_' . $number . '_placeholder'];
|
792 |
-
|
793 |
$required = $options_profile['profile_' . $number . '_rules'] == 1;
|
794 |
-
|
795 |
// Text field
|
796 |
if ($type == 'text') {
|
797 |
$buffer .= '<input class="newsletter-profile newsletter-profile-' . $number . '" type="text" size="' . $size . '" name="np' . $number . '" placeholder="' . esc_attr($placeholder) . '"';
|
798 |
-
if ($required)
|
|
|
799 |
$buffer .= '>';
|
800 |
}
|
801 |
|
802 |
// Select field
|
803 |
if ($type == 'select') {
|
804 |
$buffer .= '<select class="newsletter-profile newsletter-profile-' . $number . '" name="np' . $number . '"';
|
805 |
-
if ($required)
|
|
|
806 |
$buffer .= '>';
|
807 |
if (!empty($placeholder)) {
|
808 |
$buffer .= '<option value="">' . esc_html($placeholder) . '</option>';
|
@@ -852,19 +911,27 @@ class NewsletterSubscription extends NewsletterModule {
|
|
852 |
*
|
853 |
* @return string The html code of the subscription form
|
854 |
*/
|
855 |
-
function get_subscription_form($referrer = null, $action = null) {
|
|
|
|
|
|
|
|
|
|
|
856 |
$options_profile = get_option('newsletter_profile');
|
857 |
$options = get_option('newsletter');
|
858 |
|
859 |
$buffer = $this->get_form_javascript();
|
860 |
|
861 |
-
|
862 |
$buffer .= '<div class="newsletter newsletter-subscription">' . "\n";
|
863 |
if (empty($action)) {
|
864 |
$buffer .= '<form method="post" action="' . plugins_url('newsletter/do/subscribe.php') . '" onsubmit="return newsletter_check(this)">' . "\n\n";
|
865 |
} else {
|
866 |
$buffer .= '<form method="post" action="' . $action . '" onsubmit="return newsletter_check(this)">' . "\n\n";
|
867 |
}
|
|
|
|
|
|
|
|
|
868 |
if (!empty($referrer)) {
|
869 |
$buffer .= "<input type='hidden' name='nr' value='$referrer'>\n";
|
870 |
}
|
@@ -891,10 +958,24 @@ class NewsletterSubscription extends NewsletterModule {
|
|
891 |
$buffer .= "\t</select>\n\t</td></tr>\n";
|
892 |
}
|
893 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
894 |
$lists = '';
|
895 |
for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
|
896 |
-
if ($options_profile['list_' . $i . '_status'] != 2)
|
|
|
|
|
|
|
|
|
|
|
897 |
continue;
|
|
|
|
|
898 |
$lists .= "\t\t" . '<input type="checkbox" name="nl[]" value="' . $i . '"';
|
899 |
if ($options_profile['list_' . $i . '_checked'] == 1)
|
900 |
$lists .= ' checked';
|
@@ -911,12 +992,22 @@ class NewsletterSubscription extends NewsletterModule {
|
|
911 |
|
912 |
// Text field
|
913 |
if ($options_profile['profile_' . $i . '_type'] == 'text') {
|
914 |
-
$buffer .= "<tr>\n\t<th>" . $options_profile['profile_' . $i] . "</th>\n\t<td>\n\t\t"
|
|
|
|
|
|
|
|
|
|
|
|
|
915 |
}
|
916 |
|
917 |
// Select field
|
918 |
if ($options_profile['profile_' . $i . '_type'] == 'select') {
|
919 |
-
$buffer .= "<tr>\n\t<th>" . $options_profile['profile_' . $i] . "</th>\n\t<td>\n\t\t" . '<select class="newsletter-profile newsletter-profile-' . $i . '" name="np' . $i . '"
|
|
|
|
|
|
|
|
|
920 |
$opts = explode(',', $options_profile['profile_' . $i . '_options']);
|
921 |
for ($j = 0; $j < count($opts); $j++) {
|
922 |
$buffer .= "\t\t\t<option>" . trim($opts[$j]) . "</option>\n";
|
@@ -1257,10 +1348,13 @@ add_shortcode('newsletter_embed', 'newsletter_shortcode_form');
|
|
1257 |
add_shortcode('newsletter_form', 'newsletter_shortcode_form');
|
1258 |
|
1259 |
function newsletter_shortcode_form($attrs, $content) {
|
|
|
|
|
|
|
1260 |
if (isset($attrs['form'])) {
|
1261 |
return NewsletterSubscription::instance()->get_form($attrs['form']);
|
1262 |
} else {
|
1263 |
-
return NewsletterSubscription::instance()->get_subscription_form();
|
1264 |
}
|
1265 |
}
|
1266 |
|
20 |
|
21 |
function __construct() {
|
22 |
parent::__construct('subscription', '1.1.2');
|
23 |
+
|
24 |
+
// Direct action call
|
25 |
+
$action = isset($_REQUEST['na']) ? $_REQUEST['na'] : '';
|
26 |
+
if (!empty($action)) {
|
27 |
+
if ($action == 'u') {
|
28 |
+
include dirname(__FILE__ . '/../do/unsubscription.php');
|
29 |
+
} else if ($action == 'uc') {
|
30 |
+
include dirname(__FILE__ . '/../do/unsubscribe.php');
|
31 |
+
} else if ($action == 'p' || $action == 'pe') {
|
32 |
+
include dirname(__FILE__ . '/../do/profile.php');
|
33 |
+
} else if ($action == 'c') {
|
34 |
+
include dirname(__FILE__ . '/../do/confirm.php');
|
35 |
+
} else if ($action == 'ul') {
|
36 |
+
include dirname(__FILE__ . '/../do/unlock.php');
|
37 |
+
}
|
38 |
+
return;
|
39 |
+
}
|
40 |
+
|
41 |
add_action('wp_login', array($this, 'hook_wp_login'));
|
42 |
|
43 |
// Must be called after the Newsletter::hook_init, since some constants are defined
|
49 |
add_shortcode('newsletter_profile', array($this, 'shortcode_profile'));
|
50 |
add_shortcode('newsletter_subscription', array($this, 'shortcode_subscription'));
|
51 |
add_shortcode('newsletter_field', array($this, 'shortcode_field'));
|
52 |
+
add_action('wp_footer', array($this, 'hook_wp_footer'));
|
53 |
|
54 |
$action = isset($_REQUEST['na']) ? $_REQUEST['na'] : '';
|
55 |
if (empty($action) || is_admin())
|
146 |
$this->add_admin_page('forms', 'Forms');
|
147 |
}
|
148 |
|
149 |
+
function hook_wp_footer() {
|
150 |
+
|
151 |
+
}
|
152 |
+
|
153 |
/**
|
154 |
* This method has been redefined for compatibility with the old options naming. It would
|
155 |
* be better to change them instead. The subscription options should be named
|
520 |
if (!is_object($user)) {
|
521 |
if (is_array($user))
|
522 |
$user = (object) $user;
|
523 |
+
else {
|
524 |
$user = $newsletter->get_user($user);
|
525 |
+
}
|
526 |
}
|
527 |
|
528 |
+
if (!empty($alert)) {
|
529 |
$params = '&alert=' . urlencode($alert);
|
530 |
+
}
|
531 |
+
|
532 |
+
if ($key == 'confirmation') {
|
533 |
+
$this->options['confirmation_url'] = $_REQUEST['ncu'];
|
534 |
+
}
|
535 |
|
536 |
// Add exceptions for "profile" key.
|
537 |
// Is there a custom url?
|
577 |
}
|
578 |
|
579 |
function get_message_key_from_request() {
|
580 |
+
if (empty($_GET['nm'])) {
|
581 |
return 'subscription';
|
582 |
+
}
|
583 |
$key = $_GET['nm'];
|
584 |
switch ($key) {
|
585 |
case 's': return 'confirmation';
|
647 |
$buffer .= ' return false;' . "\n";
|
648 |
$buffer .= ' }' . "\n";
|
649 |
}
|
650 |
+
$buffer .= ' for (var i=1; i<' . NEWSLETTER_PROFILE_MAX . '; i++) {' . "\n";
|
651 |
+
$buffer .= ' if (f.elements["np" + i] && f.elements["np" + i].value == "") {' . "\n";
|
652 |
+
$buffer .= ' alert("' . addslashes($options_profile['profile_error']) . '");' . "\n";
|
653 |
+
$buffer .= ' return false;' . "\n";
|
654 |
+
$buffer .= ' }' . "\n";
|
655 |
+
$buffer .= ' }' . "\n";
|
656 |
+
|
657 |
$buffer .= ' if (f.elements["ny"] && !f.elements["ny"].checked) {' . "\n";
|
658 |
$buffer .= ' alert("' . addslashes($options_profile['privacy_error']) . '");' . "\n";
|
659 |
$buffer .= ' return false;' . "\n";
|
667 |
}
|
668 |
|
669 |
function shortcode_subscription($attrs, $content) {
|
670 |
+
if (!is_array($attrs)) $attrs = array();
|
671 |
+
|
672 |
+
$attrs = array_merge(array('class'=>'newsletter'), $attrs);
|
673 |
+
|
674 |
if (isset($attrs['css'])) {
|
675 |
if (!empty($attrs['css'])) {
|
676 |
+
echo '<style scoped>';
|
677 |
+
//include dirname(__FILE__) . '/styles/shortcode-' . $attrs['css'] . '.css';
|
678 |
+
echo '</style>';
|
679 |
}
|
680 |
} else {
|
681 |
echo '<style scoped>';
|
682 |
include dirname(__FILE__) . '/styles/shortcode-default.css';
|
683 |
echo '</style>';
|
|
|
684 |
}
|
685 |
|
686 |
$options_profile = get_option('newsletter_profile');
|
687 |
|
688 |
+
$buffer = '<form method="post" action="' . plugins_url('newsletter/do/subscribe.php') . '" class="' . $attrs['class'] . '">';
|
689 |
|
690 |
+
if (isset($attrs['referrer'])) {
|
691 |
+
$buffer .= "<input type='hidden' name='nr' value='$referrer'>";
|
692 |
+
}
|
693 |
+
|
694 |
+
if (isset($attrs['confirmation_url'])) {
|
695 |
+
$buffer .= "<input type='hidden' name='ncu' value='" . esc_attr($attrs['confirmation_url']) . "'>\n";
|
696 |
+
}
|
697 |
+
|
698 |
//$content = str_replace("\r\n", "", $content);
|
699 |
$buffer .= do_shortcode($content);
|
700 |
|
704 |
$label = $options_profile['subscribe'];
|
705 |
}
|
706 |
|
707 |
+
if (!empty($label)) {
|
708 |
+
$buffer .= '<div class="newsletter-field newsletter-field-button">';
|
709 |
+
if (strpos($label, 'http') === 0) {
|
710 |
+
$buffer .= '<input class="newsletter-button-image" type="image" src="' . $label . '">';
|
711 |
+
} else {
|
712 |
+
$buffer .= '<input class="newsletter-button" type="submit" value="' . $label . '">';
|
713 |
+
}
|
714 |
+
$buffer .= '</div>';
|
715 |
}
|
|
|
716 |
|
717 |
return $buffer;
|
718 |
}
|
732 |
$buffer .= '<label for="">' . $options_profile['email'] . '</label>';
|
733 |
}
|
734 |
$buffer .= '<input class="newsletter-email" type="email" name="ne" required>';
|
735 |
+
if (isset($attrs['button_label'])) {
|
736 |
+
$label = $attrs['button_label'];
|
737 |
+
if (strpos($label, 'http') === 0) {
|
738 |
+
$buffer .= '<input class="newsletter-button-image" type="image" src="' . $label . '">';
|
739 |
+
} else {
|
740 |
+
$buffer .= '<input class="newsletter-button" type="submit" value="' . $label . '">';
|
741 |
+
}
|
742 |
+
}
|
743 |
$buffer .= '</div>';
|
744 |
return $buffer;
|
745 |
}
|
846 |
$buffer .= '<label for="">' . $options_profile['profile_' . $number] . '</label>';
|
847 |
}
|
848 |
$placeholder = isset($attrs['placeholder']) ? $attrs['placeholder'] : $options_profile['profile_' . $number . '_placeholder'];
|
849 |
+
|
850 |
$required = $options_profile['profile_' . $number . '_rules'] == 1;
|
851 |
+
|
852 |
// Text field
|
853 |
if ($type == 'text') {
|
854 |
$buffer .= '<input class="newsletter-profile newsletter-profile-' . $number . '" type="text" size="' . $size . '" name="np' . $number . '" placeholder="' . esc_attr($placeholder) . '"';
|
855 |
+
if ($required)
|
856 |
+
$buffer .= ' required';
|
857 |
$buffer .= '>';
|
858 |
}
|
859 |
|
860 |
// Select field
|
861 |
if ($type == 'select') {
|
862 |
$buffer .= '<select class="newsletter-profile newsletter-profile-' . $number . '" name="np' . $number . '"';
|
863 |
+
if ($required)
|
864 |
+
$buffer .= ' required';
|
865 |
$buffer .= '>';
|
866 |
if (!empty($placeholder)) {
|
867 |
$buffer .= '<option value="">' . esc_html($placeholder) . '</option>';
|
911 |
*
|
912 |
* @return string The html code of the subscription form
|
913 |
*/
|
914 |
+
function get_subscription_form($referrer = null, $action = null, $attrs = array()) {
|
915 |
+
if (isset($attrs['action']))
|
916 |
+
$action = $attrs['action'];
|
917 |
+
if (isset($attrs['referrer']))
|
918 |
+
$referrer = $attrs['referrer'];
|
919 |
+
|
920 |
$options_profile = get_option('newsletter_profile');
|
921 |
$options = get_option('newsletter');
|
922 |
|
923 |
$buffer = $this->get_form_javascript();
|
924 |
|
|
|
925 |
$buffer .= '<div class="newsletter newsletter-subscription">' . "\n";
|
926 |
if (empty($action)) {
|
927 |
$buffer .= '<form method="post" action="' . plugins_url('newsletter/do/subscribe.php') . '" onsubmit="return newsletter_check(this)">' . "\n\n";
|
928 |
} else {
|
929 |
$buffer .= '<form method="post" action="' . $action . '" onsubmit="return newsletter_check(this)">' . "\n\n";
|
930 |
}
|
931 |
+
|
932 |
+
if (isset($attrs['confirmation_url'])) {
|
933 |
+
$buffer .= "<input type='hidden' name='ncu' value='" . esc_attr($attrs['confirmation_url']) . "'>\n";
|
934 |
+
}
|
935 |
if (!empty($referrer)) {
|
936 |
$buffer .= "<input type='hidden' name='nr' value='$referrer'>\n";
|
937 |
}
|
958 |
$buffer .= "\t</select>\n\t</td></tr>\n";
|
959 |
}
|
960 |
|
961 |
+
if (isset($attrs['preferences'])) {
|
962 |
+
$preferences = explode(',', str_replace(' ', '', $attrs['preferences']));
|
963 |
+
foreach ($preferences as $preference) {
|
964 |
+
$buffer .= '<input type="hidden" name="nl[]" value="' . $preference . '">';
|
965 |
+
}
|
966 |
+
}
|
967 |
+
|
968 |
$lists = '';
|
969 |
for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
|
970 |
+
if ($options_profile['list_' . $i . '_status'] != 2) {
|
971 |
+
continue;
|
972 |
+
}
|
973 |
+
|
974 |
+
// Already added above
|
975 |
+
if (isset($preferences) && array_search($i, $preferences) !== false) {
|
976 |
continue;
|
977 |
+
}
|
978 |
+
|
979 |
$lists .= "\t\t" . '<input type="checkbox" name="nl[]" value="' . $i . '"';
|
980 |
if ($options_profile['list_' . $i . '_checked'] == 1)
|
981 |
$lists .= ' checked';
|
992 |
|
993 |
// Text field
|
994 |
if ($options_profile['profile_' . $i . '_type'] == 'text') {
|
995 |
+
$buffer .= "<tr>\n\t<th>" . $options_profile['profile_' . $i] . "</th>\n\t<td>\n\t\t";
|
996 |
+
$buffer .= '<input class="newsletter-profile newsletter-profile-' . $i . '" type="text" size="30" name="np' . $i . '"';
|
997 |
+
$buffer .= ' placeholder="' . esc_attr($options_profile['profile_' . $i . '_placeholder']) . '"';
|
998 |
+
if (!empty($options_profile['profile_' . $i . '_rules'])) {
|
999 |
+
$buffer .= ' required';
|
1000 |
+
}
|
1001 |
+
$buffer .= '/>' . "\n\t</td>\n</tr>\n\n";
|
1002 |
}
|
1003 |
|
1004 |
// Select field
|
1005 |
if ($options_profile['profile_' . $i . '_type'] == 'select') {
|
1006 |
+
$buffer .= "<tr>\n\t<th>" . $options_profile['profile_' . $i] . "</th>\n\t<td>\n\t\t" . '<select class="newsletter-profile newsletter-profile-' . $i . '" name="np' . $i . '"';
|
1007 |
+
if (!empty($options_profile['profile_' . $i . '_rules'])) {
|
1008 |
+
$buffer .= ' required';
|
1009 |
+
}
|
1010 |
+
$buffer .= '>' . "\n";
|
1011 |
$opts = explode(',', $options_profile['profile_' . $i . '_options']);
|
1012 |
for ($j = 0; $j < count($opts); $j++) {
|
1013 |
$buffer .= "\t\t\t<option>" . trim($opts[$j]) . "</option>\n";
|
1348 |
add_shortcode('newsletter_form', 'newsletter_shortcode_form');
|
1349 |
|
1350 |
function newsletter_shortcode_form($attrs, $content) {
|
1351 |
+
if (!empty($content)) {
|
1352 |
+
return NewsletterSubscription::instance()->shortcode_subscription($attrs, $content);
|
1353 |
+
}
|
1354 |
if (isset($attrs['form'])) {
|
1355 |
return NewsletterSubscription::instance()->get_form($attrs['form']);
|
1356 |
} else {
|
1357 |
+
return NewsletterSubscription::instance()->get_subscription_form(null, null, $attrs);
|
1358 |
}
|
1359 |
}
|
1360 |
|
todo.txt
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
* Consider the custom taxonomies
|
2 |
-
|
3 |
-
function categories_group($name, $show_mode = false, $taxonomy = ‘category’, $top_level = false) {
|
4 |
-
|
5 |
-
$categories = get_categories( array( ‘taxonomy’ => $taxonomy, ‘hide_empty’ => 0 , ‘parent’ => (($top_level) ? 0 : ”) ) );
|
6 |
-
|
7 |
-
I need to filter for custom taxonomy. Mayby passing the args would do best and keep flexibility.
|
8 |
-
|
9 |
-
function categories_group($name, $show_mode = false, $cat_args = ”) {
|
10 |
-
|
11 |
-
$categories = get_categories( $args );
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
widget.php
CHANGED
@@ -144,6 +144,8 @@ class NewsletterWidget extends WP_Widget {
|
|
144 |
}
|
145 |
|
146 |
function form($instance) {
|
|
|
|
|
147 |
?>
|
148 |
<p>
|
149 |
<label for="<?php echo $this->get_field_id('title'); ?>">
|
144 |
}
|
145 |
|
146 |
function form($instance) {
|
147 |
+
if (!is_array($instance)) $instance = array();
|
148 |
+
$instance = array_merge(array('title'=>'', 'text'=>''), $instance);
|
149 |
?>
|
150 |
<p>
|
151 |
<label for="<?php echo $this->get_field_id('title'); ?>">
|