Version Description
- Fixed: not being able to uncheck "Use HTML 5" on form settings page
- Added: compatibility with bbPress, you can now add a sign-up checkbox to the post new topic and post new reply forms.
- Fixed: not being able to uncheck "add to comment form" in checkbox settings
- Fixed: compatibility with other plugins who use a 'functions.php' file (like GDE).
Download this release
Release Info
Developer | DvanKooten |
Plugin | Newsletter Sign-Up |
Version | 2.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.8.1 to 2.0.1
- assets/css/admin.css +13 -0
- {frontend → assets}/css/newsletter-sign-up.php +0 -0
- {backend → assets}/img/close.png +0 -0
- {backend → assets}/img/email-icon.png +0 -0
- {backend → assets}/img/icon.png +0 -0
- assets/img/mailchimp-for-wp-icon.png +0 -0
- {backend → assets}/img/overlay.png +0 -0
- assets/img/recent-facebook-posts-icon.png +0 -0
- {backend → assets}/img/rss-icon.png +0 -0
- {backend → assets}/img/twitter-icon.png +0 -0
- backend/js/backend.js → assets/js/admin.js +0 -0
- backend/css/backend.css +0 -44
- backend/css/newsletter-sign-up-backend.css +0 -0
- backend/views/checkbox_settings.php +0 -99
- backend/views/config_helper.php +0 -76
- backend/views/dashboard.php +0 -108
- backend/views/form_settings.php +0 -89
- frontend/NewsletterSignUp.php +0 -566
- includes/NSU.php +315 -0
- backend/NewsletterSignUpAdmin.php → includes/NSU_Admin.php +55 -110
- includes/NSU_Checkbox.php +212 -0
- includes/NSU_Form.php +174 -0
- {frontend → includes}/NewsletterSignUpWidget.php +4 -2
- includes/functions.php +27 -0
- includes/views/checkbox_settings.php +57 -0
- includes/views/config_helper.php +68 -0
- includes/views/dashboard.php +102 -0
- includes/views/form_settings.php +93 -0
- includes/views/parts/navigation.php +7 -0
- {backend/views → includes/views/parts}/rows-aweber.php +0 -0
- {backend/views → includes/views/parts}/rows-mailchimp.php +5 -12
- {backend/views → includes/views/parts}/rows-phplist.php +0 -0
- {backend/views → includes/views/parts}/rows-ymlp.php +0 -0
- includes/views/parts/sidebar.php +44 -0
- newsletter-sign-up.php +6 -27
- readme.txt +34 -10
- screenshot-1.jpg +0 -0
- screenshot-2.jpg +0 -0
- screenshot-3.jpg +0 -0
assets/css/admin.css
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#nsu-admin { }
|
2 |
+
#nsu-main { width:65%; float:left; }
|
3 |
+
#nsu-sidebar{ width:30%; float:right; }
|
4 |
+
|
5 |
+
#nsu-sidebar > div{ margin-bottom:20px; }
|
6 |
+
|
7 |
+
#nsu-admin li.dvk-email{ padding-left:25px; background:url("../img/email-icon.png") no-repeat left center; }
|
8 |
+
#nsu-admin li.dvk-twitter{ padding-left:25px; background:url("../img/twitter-icon.png") no-repeat left center}
|
9 |
+
#nsu-admin li.mc4wp{ padding-left:25px; background:url("../img/mailchimp-for-wp-icon.png") no-repeat left center; }
|
10 |
+
#nsu-admin li.rfb{ padding-left:25px; background:url("../img/recent-facebook-posts-icon.png") no-repeat left center; }
|
11 |
+
|
12 |
+
#nsu-donate-box{ border:2px solid green; background:#CFC; padding:0 20px; }
|
13 |
+
#nsu-donate-box h3{ color:green; }
|
{frontend → assets}/css/newsletter-sign-up.php
RENAMED
File without changes
|
{backend → assets}/img/close.png
RENAMED
File without changes
|
{backend → assets}/img/email-icon.png
RENAMED
File without changes
|
{backend → assets}/img/icon.png
RENAMED
File without changes
|
assets/img/mailchimp-for-wp-icon.png
ADDED
Binary file
|
{backend → assets}/img/overlay.png
RENAMED
File without changes
|
assets/img/recent-facebook-posts-icon.png
ADDED
Binary file
|
{backend → assets}/img/rss-icon.png
RENAMED
File without changes
|
{backend → assets}/img/twitter-icon.png
RENAMED
File without changes
|
backend/js/backend.js → assets/js/admin.js
RENAMED
File without changes
|
backend/css/backend.css
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
.dvk-box{ margin-bottom:20px; }
|
2 |
-
.dvk-box h3{ font-family:sans-serif; font-weight:bold; }
|
3 |
-
.dvk-box div.inside{ padding:0 10px 10px; font-size:13px; }
|
4 |
-
.dvk-box p,.dvk-box ul, .dvk-box input{ margin:3px 0 7px; }
|
5 |
-
.dvk-box ul{ list-style:square; margin-left:20px; }
|
6 |
-
.dvk-box li{ margin:0; margin-bottom:4px; }
|
7 |
-
|
8 |
-
li.dvk-rss-item{ margin-left:-16px; padding-left:25px;
|
9 |
-
background:url(http://static.dannyvankooten.com/images/dvk-16x16.png) no-repeat left center; list-style:none;
|
10 |
-
}
|
11 |
-
li.dvk-rss{ margin-top:10px; margin-left:-16px;
|
12 |
-
float:left; padding-left:25px; background:url("../img/rss-icon.png") no-repeat left center;
|
13 |
-
list-style:none; }
|
14 |
-
li.dvk-email{ margin:10px 0 0 10px; float:left; padding-left:25px; background:url("../img/email-icon.png") no-repeat left center;
|
15 |
-
list-style:none; }
|
16 |
-
li.dvk-twitter{ clear:both; margin:10px 0 0 -16px; float:left; list-style:none; padding-left:25px; background:url("../img/twitter-icon.png") no-repeat left center}
|
17 |
-
|
18 |
-
.dvk-box b,.dvk-box strong{ font-weight:bold; }
|
19 |
-
|
20 |
-
#ns_settings_page input[type=text]{ width:75%; }
|
21 |
-
|
22 |
-
span.ns_small{
|
23 |
-
font-style:italic;
|
24 |
-
font-size:10px;
|
25 |
-
display:block;
|
26 |
-
margin:2px 0;
|
27 |
-
}
|
28 |
-
|
29 |
-
#dvk-avatar{
|
30 |
-
vertical-align:top;
|
31 |
-
margin-right:10px;
|
32 |
-
display:inline-block;
|
33 |
-
height:32px;
|
34 |
-
width:32px;
|
35 |
-
background:url(http://static.dannyvankooten.com/images/dvk-avatar.png) no-repeat;
|
36 |
-
}
|
37 |
-
|
38 |
-
.nsu-tip{ font-size: 11px; font-style:italic; }
|
39 |
-
html,body{ height:auto !important; position:relative; }
|
40 |
-
.nsu-textarea{ width:100% !important; min-height:150px; }
|
41 |
-
|
42 |
-
#newsletter-sign-up-donatebox{ border:2px solid green; background:#CFC; }
|
43 |
-
#newsletter-sign-up-donatebox h3{ color:green; }
|
44 |
-
#newsletter-sign-up-donatebox li{ line-height:22px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backend/css/newsletter-sign-up-backend.css
DELETED
File without changes
|
backend/views/checkbox_settings.php
DELETED
@@ -1,99 +0,0 @@
|
|
1 |
-
<div class="wrap" id="<?php echo $this->hook; ?>">
|
2 |
-
<h2><a href="http://dannyvankooten.com/" target="_blank"><span id="dvk-avatar"></span></a>Newsletter Sign-Up :: Checkbox Settings</h2>
|
3 |
-
<div class="postbox-container" style="width:65%;">
|
4 |
-
<div class="metabox-holder">
|
5 |
-
<div class="meta-box-sortables">
|
6 |
-
|
7 |
-
<div class="postbox">
|
8 |
-
<div class="handlediv" title="<?php _e('Click to toggle'); ?>"><br></div>
|
9 |
-
<h3 class="hndle"><span>Checkbox Settings</span></h3>
|
10 |
-
<div class="inside">
|
11 |
-
<form method="post" action="options.php" id="ns_settings_page">
|
12 |
-
<?php settings_fields('nsu_checkbox_group'); ?>
|
13 |
-
<table class="form-table">
|
14 |
-
<tr valign="top"><th scope="row">Text to show after the checkbox</th>
|
15 |
-
<td><input size="50%" type="text" name="nsu_checkbox[text]" value="<?php echo $opts['text']; ?>" /></td>
|
16 |
-
</tr>
|
17 |
-
<tr valign="top"><th scope="row">Redirect to this url after signing up <span class="ns_small">(leave empty for no redirect)</span></th>
|
18 |
-
<td><input size="50%" type="text" name="nsu_checkbox[redirect_to]" value="<?php echo $opts['redirect_to']; ?>" />
|
19 |
-
<br />
|
20 |
-
<p class="nsu-tip">In general, I don't recommend setting a redirect url for the sign-up checkbox. This will cause some serious confusion, since
|
21 |
-
users expect to be redirected to the post they commented on.</p>
|
22 |
-
|
23 |
-
</td>
|
24 |
-
</tr>
|
25 |
-
<tr valign="top"><th scope="row"><label for="ns_precheck_checkbox">Pre-check the checkbox?</label></th>
|
26 |
-
<td><input type="checkbox" id="ns_precheck_checkbox" name="nsu_checkbox[precheck]" value="1"<?php
|
27 |
-
if ($opts['precheck'] == '1') {
|
28 |
-
echo ' checked';
|
29 |
-
}
|
30 |
-
?> /></td>
|
31 |
-
</tr>
|
32 |
-
<tr valign="top">
|
33 |
-
<th scope="row"><label for="do_css_reset">Do a CSS 'reset' on the checkbox.</label> <span class="ns_small">(check this if checkbox appears in a weird place)</span></th>
|
34 |
-
<td><input type="checkbox" id="do_css_reset" name="nsu_checkbox[css_reset]" value="1"<?php
|
35 |
-
if ($opts['css_reset'] == '1') {
|
36 |
-
echo ' checked="checked"';
|
37 |
-
}
|
38 |
-
?> /> </td>
|
39 |
-
</tr>
|
40 |
-
<tr valign="top"><th scope="row">Where to show the sign-up checkbox?</th>
|
41 |
-
<td>
|
42 |
-
<input type="checkbox" id="add_to_comment_form" name="nsu_checkbox[add_to_comment_form]" value="1"<?php
|
43 |
-
if ($opts['add_to_comment_form'] == '1') {
|
44 |
-
echo ' checked="checked"';
|
45 |
-
}
|
46 |
-
?> /> <label for="add_to_comment_form">WordPress comment form</label><br />
|
47 |
-
<input type="checkbox" id="add_to_reg_form" name="nsu_checkbox[add_to_registration_form]" value="1"<?php
|
48 |
-
if ($opts['add_to_registration_form'] == '1') {
|
49 |
-
echo ' checked="checked"';
|
50 |
-
}
|
51 |
-
?> /> <label for="add_to_reg_form">WordPress registration form</label><br />
|
52 |
-
<?php if ($this->bp_active == TRUE) { ?>
|
53 |
-
<input type="checkbox" id="add_to_bp_form" name="nsu_checkbox[add_to_buddypress_form]" value="1"<?php
|
54 |
-
if ($opts['add_to_buddypress_form'] == '1') {
|
55 |
-
echo ' checked="checked"';
|
56 |
-
}
|
57 |
-
?> /> <label for="add_to_bp_form">BuddyPress registration form</label><br />
|
58 |
-
<?php
|
59 |
-
}
|
60 |
-
if (defined('MULTISITE') && MULTISITE == TRUE) {
|
61 |
-
?>
|
62 |
-
<input type="checkbox" id="add_to_ms_form" name="nsu_checkbox[add_to_multisite_form]" value="1"<?php
|
63 |
-
if ($opts['add_to_multisite_form'] == '1') {
|
64 |
-
echo ' checked="checked"';
|
65 |
-
}
|
66 |
-
?> /> <label for="add_to_ms_form">MultiSite registration form</label><br />
|
67 |
-
<?php } ?>
|
68 |
-
</td>
|
69 |
-
</tr>
|
70 |
-
<tr valign="top"><th scope="row"><label for="ns_cookie_hide">Hide the checkbox for users who used it to subscribe before?</label><span class="ns_small">(uses a cookie)</span></th>
|
71 |
-
<td><input type="checkbox" id="ns_cookie_hide" name="nsu_checkbox[cookie_hide]" value="1"<?php
|
72 |
-
if ($opts['cookie_hide'] == '1') {
|
73 |
-
echo ' checked="checked"';
|
74 |
-
}
|
75 |
-
?> /></td>
|
76 |
-
</tr>
|
77 |
-
|
78 |
-
</table>
|
79 |
-
|
80 |
-
<p class="submit">
|
81 |
-
<input type="submit" class="button-primary" style="margin:5px;" value="<?php _e('Save Changes') ?>" />
|
82 |
-
</p>
|
83 |
-
|
84 |
-
</form>
|
85 |
-
</div>
|
86 |
-
</div>
|
87 |
-
</div></div></div></div>
|
88 |
-
<div class="postbox-container" style="width:33%; float:right; margin-right:1%;">
|
89 |
-
<div class="metabox-holder">
|
90 |
-
<div class="meta-box-sortables">
|
91 |
-
<?php
|
92 |
-
$this->donate_box();
|
93 |
-
$this->latest_posts();
|
94 |
-
$this->support_box();
|
95 |
-
?>
|
96 |
-
</div>
|
97 |
-
</div>
|
98 |
-
</div>
|
99 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backend/views/config_helper.php
DELETED
@@ -1,76 +0,0 @@
|
|
1 |
-
<div class="wrap" id="<?php echo $this->hook; ?>">
|
2 |
-
|
3 |
-
<?php if(isset($error)) { ?>
|
4 |
-
<div id="message" class="notice error"><p>Oops, I couldn't make any sense of that. Are you sure you submitted a form snippet?</p></div>
|
5 |
-
<?php } ?>
|
6 |
-
|
7 |
-
<h2><a href="http://dannyvankooten.com/" target="_blank"><span id="dvk-avatar"></span></a>Newsletter Sign-Up :: Config Extractor</h2>
|
8 |
-
<div class="postbox-container" style="width:65%;">
|
9 |
-
<div class="metabox-holder">
|
10 |
-
<div class="meta-box-sortables">
|
11 |
-
<div class="postbox">
|
12 |
-
<h3 class="hndle"><span>Newsletter Sign-Up :: Config Extractor</span></h3>
|
13 |
-
<div class="inside">
|
14 |
-
|
15 |
-
|
16 |
-
<?php if(isset($result)) { ?>
|
17 |
-
<table class="form-table">
|
18 |
-
<tr valign="top">
|
19 |
-
<th scope="row" style="font-weight:bold;">Form action:</th>
|
20 |
-
<td><?php echo $form_action; ?></td>
|
21 |
-
</tr>
|
22 |
-
<tr valign="top">
|
23 |
-
<th scope="row" style="font-weight:bold;">Email identifier:</th>
|
24 |
-
<td><?php echo $email_identifier; ?></td>
|
25 |
-
</tr>
|
26 |
-
<tr valign="top">
|
27 |
-
<th scope="row" style="font-weight:bold;">Name identifier:</th>
|
28 |
-
<td><?php echo $name_identifier; ?></td>
|
29 |
-
</tr>
|
30 |
-
<?php if(isset($additional_data) && count($additional_data) > 0) { ?>
|
31 |
-
<tr valign="top">
|
32 |
-
<th scope="row" colspan="2" style="font-weight:bold;">Additional data ( name / value):</th>
|
33 |
-
</tr>
|
34 |
-
<?php foreach($additional_data as $data) { ?>
|
35 |
-
<tr valign="top">
|
36 |
-
<td><?php echo $data[0]; ?></th>
|
37 |
-
<td><?php echo $data[1]; ?></td>
|
38 |
-
</tr>
|
39 |
-
<?php } ?>
|
40 |
-
<?php } ?>
|
41 |
-
</table>
|
42 |
-
|
43 |
-
<p>The above settings are there to help you, though they may not be right. Check out <a href="http://dannyvankooten.com/571/configuring-newsletter-sign-up-the-definitive-guide/">this post on my blog</a> for more information on how to manually
|
44 |
-
configure Newsletter Sign-up.</p>
|
45 |
-
<p>The form code below is a stripped down version of your sign-up form which will make it easier for you to extract the right values. Please also use this form when asking for support.</p>
|
46 |
-
<textarea class="nsu-textarea"><?php echo $clean_form; ?></textarea>
|
47 |
-
|
48 |
-
<?php } else { ?>
|
49 |
-
<p>This tool was designed to help you extract the right configuration settings to make NSU work properly.</p>
|
50 |
-
<p>Please copy and paste a sign-up form you would normally embed on a HTML page in the textarea below and hit the extract button. The NSU Config Tool will then try to extract the right configuration settings for you. </p>
|
51 |
-
<form method="post" action="" id="ns_settings_page">
|
52 |
-
<textarea name="form" class="nsu-textarea"></textarea>
|
53 |
-
|
54 |
-
<p class="submit">
|
55 |
-
<input type="submit" class="button-primary" style="margin:5px;" value="<?php _e('Extract') ?>" />
|
56 |
-
</p>
|
57 |
-
|
58 |
-
|
59 |
-
</form>
|
60 |
-
<?Php } ?>
|
61 |
-
</div>
|
62 |
-
</div>
|
63 |
-
|
64 |
-
</div></div></div></div>
|
65 |
-
<div class="postbox-container" style="width:33%; float:right; margin-right:1%;">
|
66 |
-
<div class="metabox-holder">
|
67 |
-
<div class="meta-box-sortables">
|
68 |
-
<?php
|
69 |
-
$this->donate_box();
|
70 |
-
$this->latest_posts();
|
71 |
-
$this->support_box();
|
72 |
-
?>
|
73 |
-
</div>
|
74 |
-
</div>
|
75 |
-
</div>
|
76 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backend/views/dashboard.php
DELETED
@@ -1,108 +0,0 @@
|
|
1 |
-
<div class="wrap" id="<?php echo $this->hook; ?>">
|
2 |
-
<h2><a href="http://dannyvankooten.com/" target="_blank"><span id="dvk-avatar"></span></a>Newsletter Sign-Up :: Mailinglist Settings</h2>
|
3 |
-
<div class="postbox-container" style="width:65%;">
|
4 |
-
<div class="metabox-holder">
|
5 |
-
<div class="meta-box-sortables">
|
6 |
-
<div class="postbox">
|
7 |
-
<div class="handlediv" title="<?php _e('Click to toggle'); ?>"><br></div>
|
8 |
-
<h3 class="hndle"><span>Mailinglist Settings</span></span></h3>
|
9 |
-
<div class="inside">
|
10 |
-
<form method="post" action="options.php" id="ns_settings_page">
|
11 |
-
<?php settings_fields('nsu_mailinglist_group'); ?>
|
12 |
-
|
13 |
-
<table class="form-table">
|
14 |
-
<tr valign="top">
|
15 |
-
<td colspan="2"><p>These settings are the most important since without these Newsletter Sign-Up can't do it's job. Having trouble finding
|
16 |
-
the right configuration settings? Have a look at <a href="http://dannyvankooten.com/wordpress-plugins/newsletter-sign-up/">this post on my blog</a> or try the <a href="admin.php?page=newsletter-sign-up/config-helper">configuration extractor</a>.</p></td>
|
17 |
-
</tr>
|
18 |
-
<tr valign="top">
|
19 |
-
<th scope="row">Select your mailinglist provider: </th>
|
20 |
-
<td>
|
21 |
-
<select name="nsu_mailinglist[provider]" id="ns_mp_provider" onchange="document.location.href = 'admin.php?page=<?php echo $this->hook; ?>&mp=' + this.value">
|
22 |
-
<option value="other"<?php if ($viewed_mp == NULL || $viewed_mp == 'other')
|
23 |
-
echo ' SELECTED'; ?>>-- other / advanced</option>
|
24 |
-
<option value="mailchimp"<?php if ($viewed_mp == 'mailchimp')
|
25 |
-
echo ' SELECTED'; ?> >MailChimp</option>
|
26 |
-
<option value="ymlp"<?php if ($viewed_mp == 'ymlp')
|
27 |
-
echo ' SELECTED'; ?> >YMLP</option>
|
28 |
-
<option value="icontact"<?php if ($viewed_mp == 'icontact')
|
29 |
-
echo ' SELECTED'; ?> >iContact</option>
|
30 |
-
<option value="aweber"<?php if ($viewed_mp == 'aweber')
|
31 |
-
echo ' SELECTED'; ?> >Aweber</option>
|
32 |
-
<option value="phplist"<?php if ($viewed_mp == 'phplist')
|
33 |
-
echo ' SELECTED'; ?> >PHPList</option>
|
34 |
-
</select>
|
35 |
-
</td>
|
36 |
-
</tr>
|
37 |
-
|
38 |
-
<?php if(isset($viewed_mp) && file_exists(dirname(__FILE__).'/rows-' . $viewed_mp . '.php')) require dirname(__FILE__). '/rows-' . $viewed_mp . '.php'; ?>
|
39 |
-
|
40 |
-
<tbody class="form_rows"<?php if (isset($viewed_mp) && in_array($viewed_mp, array('mailchimp', 'ymlp')) && isset($opts['use_api']) && $opts['use_api'] == 1)
|
41 |
-
echo ' style="display:none" '; ?>>
|
42 |
-
<tr valign="top"><th scope="row">Newsletter form action</th>
|
43 |
-
<td><input size="50%" type="text" id="ns_form_action" name="nsu_mailinglist[form_action]" value="<?php echo $opts['form_action']; ?>" /></td>
|
44 |
-
</tr>
|
45 |
-
<tr valign="top"><th scope="row">E-mail identifier <span class="ns_small">name attribute of input field that holds the emailadress</span></th>
|
46 |
-
<td><input size="50%" type="text" name="nsu_mailinglist[email_id]" value="<?php echo $opts['email_id']; ?>"/></td>
|
47 |
-
</tr>
|
48 |
-
</tbody>
|
49 |
-
<tbody>
|
50 |
-
<tr valign="top"><th scope="row"><label for="subscribe_with_name">Subscribe with name?</label></th>
|
51 |
-
<td><input type="checkbox" id="subscribe_with_name" name="nsu_mailinglist[subscribe_with_name]" value="1"<?php if($opts['subscribe_with_name'] == '1') echo ' checked'; ?> /></td>
|
52 |
-
</tr>
|
53 |
-
<tr class="name_dependent" valign="top"<?php if($opts['subscribe_with_name'] != 1) echo 'style="display:none;"'; ?>><th scope="row">Name identifier <span class="ns_small">name attribute of input field that holds the name</span></th>
|
54 |
-
<td><input size="25%" id="ns_name_id" type="text" name="nsu_mailinglist[name_id]" value="<?php echo $opts['name_id']; ?>" /></td>
|
55 |
-
</tr>
|
56 |
-
</tbody>
|
57 |
-
</table>
|
58 |
-
<p style="margin:10px;">
|
59 |
-
For some newsletter services you need to specify some additional static data, like a list ID or your account name. These fields are usually found as hidden fields in your sign-up form's HTML code.
|
60 |
-
You can specify these additional fields here using name / value pairs so they will be sent along with every sign-up request.
|
61 |
-
</p>
|
62 |
-
<p>If you use <em>%%NAME%%</em> or <em>%%IP%%</em> in the value fields it will be replaced by respectively the actual name or IP address of the subscriber.</p>
|
63 |
-
<table class="form-table">
|
64 |
-
<tr valign="top">
|
65 |
-
<th scope="column" style="font-weight:bold;">Name</th>
|
66 |
-
<th scope="column" style="font-weight:bold;">Value</th>
|
67 |
-
</tr>
|
68 |
-
<?php
|
69 |
-
$last_key = 0;
|
70 |
-
|
71 |
-
if (isset($opts['extra_data']) && is_array($opts['extra_data'])) :
|
72 |
-
foreach ($opts['extra_data'] as $key => $value) :
|
73 |
-
?>
|
74 |
-
<tr valign="top">
|
75 |
-
<td><input size="50%" type="text" name="nsu_mailinglist[extra_data][<?php echo $key; ?>][name]" value="<?php echo $value['name']; ?>" /></td>
|
76 |
-
<td><input size="50%" type="text" name="nsu_mailinglist[extra_data][<?php echo $key; ?>][value]" value="<?php echo $value['value']; ?>" /></td>
|
77 |
-
</tr>
|
78 |
-
<?php
|
79 |
-
$last_key = $key + 1;
|
80 |
-
endforeach;
|
81 |
-
endif;
|
82 |
-
?>
|
83 |
-
<tr valign="top">
|
84 |
-
<td><input size="50%" type="text" name="nsu_mailinglist[extra_data][<?php echo $last_key; ?>][name]" value="" /></td>
|
85 |
-
<td><input size="50%" type="text" name="nsu_mailinglist[extra_data][<?php echo $last_key; ?>][value]" value="" /></td>
|
86 |
-
</tr>
|
87 |
-
</table>
|
88 |
-
<p class="submit">
|
89 |
-
<input type="submit" class="button-primary" style="margin:5px;" value="<?php _e('Save Changes') ?>" />
|
90 |
-
</p>
|
91 |
-
</form>
|
92 |
-
<p class="nsu-tip">
|
93 |
-
Having trouble finding the right configuration settings? Try the <a href="admin.php?page=newsletter-sign-up/config-helper">configuration extractor</a>, it's there to help you!
|
94 |
-
</p>
|
95 |
-
</div>
|
96 |
-
</div></div></div></div></div>
|
97 |
-
<div class="postbox-container" style="width:33%; float:right; margin-right:1%;">
|
98 |
-
<div class="metabox-holder">
|
99 |
-
<div class="meta-box-sortables">
|
100 |
-
<?php
|
101 |
-
$this->donate_box();
|
102 |
-
$this->latest_posts();
|
103 |
-
$this->support_box();
|
104 |
-
?>
|
105 |
-
</div>
|
106 |
-
</div>
|
107 |
-
</div>
|
108 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backend/views/form_settings.php
DELETED
@@ -1,89 +0,0 @@
|
|
1 |
-
<div class="wrap" id="<?php echo $this->hook; ?>">
|
2 |
-
<h2><a href="http://dannyvankooten.com/" target="_blank"><span id="dvk-avatar"></span></a>Newsletter Sign-Up :: Form Settings</h2>
|
3 |
-
<div class="postbox-container" style="width:65%;">
|
4 |
-
<div class="metabox-holder">
|
5 |
-
<div class="meta-box-sortables">
|
6 |
-
<div class="postbox">
|
7 |
-
<div class="handlediv" title="<?php _e('Click to toggle'); ?>"><br></div>
|
8 |
-
<h3 class="hndle" id="nsu-form-settings"><span>Form Settings</span></h3>
|
9 |
-
<div class="inside">
|
10 |
-
|
11 |
-
<form method="post" action="options.php" id="ns_settings_page">
|
12 |
-
<?php settings_fields('nsu_form_group'); ?>
|
13 |
-
<table class="form-table">
|
14 |
-
<tr valign="top">
|
15 |
-
<td colspan="2"><p>Custome your Sign-up form by providing your own values for the different labels, input fields and buttons of the sign-up form. </p></td>
|
16 |
-
</tr>
|
17 |
-
<tr valign="top">
|
18 |
-
<th scope="row">E-mail label</th>
|
19 |
-
<td><input size="50%" type="text" name="nsu_form[email_label]" value="<?php echo $opts['email_label']; ?>" /></td>
|
20 |
-
</tr>
|
21 |
-
<tr valign="top">
|
22 |
-
<th scope="row">E-mail default value</th>
|
23 |
-
<td><input size="50%" type="text" name="nsu_form[email_default_value]" value="<?php echo $opts['email_default_value']; ?>" /></td>
|
24 |
-
</tr>
|
25 |
-
<tr valign="top" class="name_dependent" <?php if($opts['mailinglist']['subscribe_with_name'] != 1) echo 'style="display:none;"'; ?>><th scope="row">Name label <span class="ns_small">(if using subscribe with name)</span></th>
|
26 |
-
<td>
|
27 |
-
<input size="50%" type="text" name="nsu_form[name_label]" value="<?php echo $opts['name_label']; ?>" /><br />
|
28 |
-
<input type="checkbox" id="name_required" name="nsu_form[name_required]" value="1"<?php if($opts['name_required'] == '1') { echo ' checked'; } ?> />
|
29 |
-
<label for="name_required">Name is a required field?</label>
|
30 |
-
</td>
|
31 |
-
|
32 |
-
</tr>
|
33 |
-
<tr valign="top" class="name_dependent" <?php if($opts['mailinglist']['subscribe_with_name'] != 1) echo 'style="display:none;"'; ?>>
|
34 |
-
<th scope="row">Name default value</th>
|
35 |
-
<td><input size="50%" type="text" name="nsu_form[name_default_value]" value="<?php echo $opts['name_default_value']; ?>" /></td>
|
36 |
-
|
37 |
-
</tr>
|
38 |
-
<tr valign="top"><th scope="row">Submit button value</th>
|
39 |
-
<td><input size="50%" type="text" name="nsu_form[submit_button]" value="<?php echo $opts['submit_button']; ?>" /></td>
|
40 |
-
</tr>
|
41 |
-
<tr valign="top"><th scope="row">Text to replace the form with after a successful sign-up</th>
|
42 |
-
<td>
|
43 |
-
<textarea style="width:100%;" rows="5" cols="50" name="nsu_form[text_after_signup]"><?php echo $opts['text_after_signup']; ?></textarea>
|
44 |
-
<p><input id="nsu_form_wpautop" name="nsu_form[wpautop]" type="checkbox" value="1" <?php if($opts['wpautop'] == 1) echo 'checked'; ?> /> <label for="nsu_form_wpautop"><?php _e('Automatically add paragraphs'); ?></label></p>
|
45 |
-
</td>
|
46 |
-
</tr>
|
47 |
-
|
48 |
-
<?php if($opts['mailinglist']['use_api'] == 1) { ?>
|
49 |
-
<tr valign="top"><th scope="row">Redirect to this url after signing up <span class="ns_small">(leave empty for no redirect)</span></th>
|
50 |
-
<td><input size="50%" type="text" name="nsu_form[redirect_to]" value="<?php echo $opts['redirect_to']; ?>" /></td>
|
51 |
-
</tr>
|
52 |
-
<?php } ?>
|
53 |
-
|
54 |
-
<tr valign="top"><th scope="row"><label for="ns_load_form_styles">Load some default CSS</label><span class="ns_small">(check this for some default styling of the labels and input fields)</span></th>
|
55 |
-
<td><input type="checkbox" id="ns_load_form_styles" name="nsu_form[load_form_css]" value="1" <?php if($opts['load_form_css'] == 1) echo 'checked'; ?> /></td>
|
56 |
-
</tr>
|
57 |
-
</table>
|
58 |
-
<p class="submit">
|
59 |
-
<input type="submit" class="button-primary" style="margin:5px;" value="<?php _e('Save Changes') ?>" />
|
60 |
-
</p>
|
61 |
-
|
62 |
-
<?php
|
63 |
-
$tips = array(
|
64 |
-
'You can embed a sign-up form in your posts and pages by
|
65 |
-
using the shortcode <b><em>[newsletter-sign-up-form]</em></b> or by calling <b><em><?php if(function_exists(\'nsu_signup_form\')) nsu_signup_form(); ?></em></b> from your template files.',
|
66 |
-
'Using Newsletter Sign-Up Widget? You can alternatively install <a target="_blank" href="http://wordpress.org/extend/plugins/wysiwyg-widgets/">WYSIWYG Widgets</a> and use the NSU form shortcode <strong>[nsu-form]</strong> to render a sign-up form in your widget area\'s. This allows
|
67 |
-
easier customizing',
|
68 |
-
'When testing, make sure to test with an email address that is not already on your e-mail list.',
|
69 |
-
'Using Newsletter Sign-Up with MailChimp? Consider switching to <a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">MailChimp for WordPress</a>'
|
70 |
-
);
|
71 |
-
$random_key = array_rand($tips);
|
72 |
-
?>
|
73 |
-
<p class="nsu-tip">Tip: <?php echo $tips[$random_key]; ?></p>
|
74 |
-
|
75 |
-
</form>
|
76 |
-
<br style="clear:both;" />
|
77 |
-
</div></div></div></div></div></div>
|
78 |
-
<div class="postbox-container" style="width:33%; float:right; margin-right:1%;">
|
79 |
-
<div class="metabox-holder">
|
80 |
-
<div class="meta-box-sortables">
|
81 |
-
<?php
|
82 |
-
$this->donate_box();
|
83 |
-
$this->latest_posts();
|
84 |
-
$this->support_box();
|
85 |
-
?>
|
86 |
-
</div>
|
87 |
-
</div>
|
88 |
-
</div>
|
89 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
frontend/NewsletterSignUp.php
DELETED
@@ -1,566 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if(!class_exists('NewsletterSignUp')) {
|
3 |
-
class NewsletterSignUp {
|
4 |
-
|
5 |
-
private $options = array();
|
6 |
-
private $no_of_forms = 0;
|
7 |
-
private $showed_checkbox = FALSE;
|
8 |
-
private static $instance;
|
9 |
-
private $validation_errors = array();
|
10 |
-
|
11 |
-
public function __construct()
|
12 |
-
{
|
13 |
-
$defaults = array(
|
14 |
-
'form' => array('load_form_css' => 0, 'submit_button' => 'Sign up', 'name_label' => 'Name:', 'email_label' => "Email:", 'email_default_value' => 'Your emailaddress..', 'name_required' => 0, 'name_default_value' => 'Your name..', 'wpautop' => 0, 'text_after_signup' => 'Thanks for signing up to our newsletter. Please check your inbox to confirm your email address.', 'redirect_to' => ''),
|
15 |
-
'mailinglist' => array('provider' => '', 'use_api' => 0, 'subscribe_with_name' => 0, 'email_id' => '', 'name_id' => '', 'form_action' => ''),
|
16 |
-
'checkbox' => array('text' => 'Sign me up for the newsletter', 'redirect_to' => '', 'precheck' => 0, 'cookie_hide' => 0, 'css_reset' => 0, 'add_to_registration_form' => 0, 'add_to_comment_form' => 1, 'add_to_buddypress_form' => 0, 'add_to_multisite_form' => 0)
|
17 |
-
);
|
18 |
-
|
19 |
-
$this->options['form'] = array_merge($defaults['form'], (array) get_option('nsu_form'));
|
20 |
-
$this->options['mailinglist'] = array_merge($defaults['mailinglist'], (array) get_option('nsu_mailinglist'));
|
21 |
-
$this->options['checkbox'] = array_merge($defaults['checkbox'], (array) get_option('nsu_checkbox'));
|
22 |
-
$opts = $this->options;
|
23 |
-
|
24 |
-
// widget hooks
|
25 |
-
add_action('widgets_init', array($this, 'register_widget'));
|
26 |
-
add_action('init', array($this, 'check_for_form_submit'));
|
27 |
-
|
28 |
-
// register the shortcode which can be used to output sign-up form
|
29 |
-
add_shortcode('newsletter-sign-up-form', array($this,'form_shortcode'));
|
30 |
-
add_shortcode('nsu-form', array($this,'form_shortcode'));
|
31 |
-
|
32 |
-
// Should we load the stylesheet?
|
33 |
-
if($opts['checkbox']['css_reset'] == 1 || $opts['form']['load_form_css'] == 1) {
|
34 |
-
add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
|
35 |
-
}
|
36 |
-
|
37 |
-
// Add to comment form? If so, add necessary actions. Try to add automatically.
|
38 |
-
if($opts['checkbox']['add_to_comment_form'] == 1) {
|
39 |
-
add_action('thesis_hook_after_comment_box', array($this, 'output_checkbox'), 20);
|
40 |
-
add_action('comment_form', array($this, 'output_checkbox'), 20);
|
41 |
-
add_action('comment_approved_', array($this, 'grab_email_from_comment'), 10, 1);
|
42 |
-
add_action('comment_post', array($this, 'grab_email_from_comment'), 50, 2);
|
43 |
-
}
|
44 |
-
|
45 |
-
// If add_to_reg_form is ticked, add corresponding actions
|
46 |
-
if($opts['checkbox']['add_to_registration_form'] == 1) {
|
47 |
-
add_action('register_form',array($this, 'output_checkbox'), 20);
|
48 |
-
add_action('register_post',array($this, 'grab_email_from_wp_signup'), 50);
|
49 |
-
}
|
50 |
-
|
51 |
-
// If add_to_bp_form is ticked, add BuddyPress actions
|
52 |
-
if($opts['checkbox']['add_to_buddypress_form'] == 1) {
|
53 |
-
add_action('bp_before_registration_submit_buttons', array($this, 'output_checkbox'), 20);
|
54 |
-
add_action('bp_complete_signup', array($this, 'grab_email_from_wp_signup'), 20);
|
55 |
-
}
|
56 |
-
|
57 |
-
// If running a MultiSite, add to registration form and add actions.
|
58 |
-
if($opts['checkbox']['add_to_multisite_form'] == 1) {
|
59 |
-
add_action('signup_extra_fields', array($this, 'output_checkbox'), 20);
|
60 |
-
add_action('signup_blogform', array($this, 'add_hidden_checkbox'), 20);
|
61 |
-
add_filter('add_signup_meta', array($this, 'add_checkbox_to_usermeta'));
|
62 |
-
add_action('wpmu_activate_blog', array($this, 'grab_email_from_ms_blog_signup'), 20, 5);
|
63 |
-
add_action('wpmu_activate_user', array($this, 'grab_email_from_ms_user_signup'), 20, 3);
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
public function getOptions()
|
68 |
-
{
|
69 |
-
return $this->options;
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Registers the Newsletter Sign-Up Widget
|
74 |
-
* @return type
|
75 |
-
*/
|
76 |
-
public function register_widget()
|
77 |
-
{
|
78 |
-
return register_widget('NewsletterSignUpWidget');
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Factory method for NewsletterSignUp class. Only instantiate once.
|
83 |
-
* @return NewsletterSignUp Instance of Newsletter Sign-Up class
|
84 |
-
*/
|
85 |
-
public static function getInstance() {
|
86 |
-
if(!isset(self::$instance)) self::$instance = new NewsletterSignUp();
|
87 |
-
|
88 |
-
return self::$instance;
|
89 |
-
}
|
90 |
-
|
91 |
-
public function enqueue_styles()
|
92 |
-
{
|
93 |
-
$opts = $this->getOptions();
|
94 |
-
|
95 |
-
// Build stylesheet url --------------
|
96 |
-
$stylesheet_opts = '?';
|
97 |
-
|
98 |
-
// Load CSS to reset the checkbox' position?
|
99 |
-
if($opts['checkbox']['css_reset'] == 1) {
|
100 |
-
$stylesheet_opts .= 'checkbox_reset=1&';
|
101 |
-
}
|
102 |
-
|
103 |
-
// Load CSS to reset label and input fields for the sign-up form?
|
104 |
-
if($opts['form']['load_form_css'] == 1) {
|
105 |
-
$stylesheet_opts .= 'form_css=1&';
|
106 |
-
}
|
107 |
-
|
108 |
-
wp_enqueue_style('ns_checkbox_style', plugins_url("/frontend/css/newsletter-sign-up.php{$stylesheet_opts}", dirname(__FILE__)));
|
109 |
-
}
|
110 |
-
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Check if ANY Newsletter Sign-Up form has been submitted.
|
114 |
-
*/
|
115 |
-
public function check_for_form_submit()
|
116 |
-
{
|
117 |
-
$opts = $this->options['form'];
|
118 |
-
$errors = array();
|
119 |
-
|
120 |
-
if(isset($_POST['nsu_submit']))
|
121 |
-
{
|
122 |
-
$email = (isset($_POST['nsu_email'])) ? $_POST['nsu_email'] : '';
|
123 |
-
$name = (isset($_POST['nsu_name'])) ? $_POST['nsu_name'] : '';
|
124 |
-
|
125 |
-
if($this->options['mailinglist']['subscribe_with_name'] == 1 && $opts['name_required'] == 1 && empty($name)) {
|
126 |
-
$errors['name-field'] = 'Please fill in the name field.';
|
127 |
-
}
|
128 |
-
|
129 |
-
if(empty($email)) {
|
130 |
-
$errors['email-field'] = 'Please fill in the email address field.';
|
131 |
-
} elseif(!is_email($email)) {
|
132 |
-
$errors['email-field'] = 'Please enter a valid email address.';
|
133 |
-
}
|
134 |
-
|
135 |
-
$this->validation_errors = $errors;
|
136 |
-
|
137 |
-
if(count($this->validation_errors) == 0) {
|
138 |
-
$this->send_post_data($email, $name, 'form');
|
139 |
-
}
|
140 |
-
|
141 |
-
}
|
142 |
-
return;
|
143 |
-
}
|
144 |
-
|
145 |
-
|
146 |
-
/**
|
147 |
-
* Output the checkbox
|
148 |
-
* Function can only run once.
|
149 |
-
*/
|
150 |
-
public function output_checkbox()
|
151 |
-
{
|
152 |
-
$opts = $this->options['checkbox'];
|
153 |
-
|
154 |
-
// If using option to hide checkbox for subscribers and cookie is set, set instance variable showed_checkbox to true so checkbox won't show.
|
155 |
-
if($opts['cookie_hide'] == 1 && isset($_COOKIE['ns_subscriber'])) $this->showed_checkbox = TRUE;
|
156 |
-
|
157 |
-
// User could have rendered the checkbox by manually adding 'the hook 'ns_comment_checkbox()' to their comment form
|
158 |
-
// If so, abandon function.
|
159 |
-
if($this->showed_checkbox) return false;
|
160 |
-
|
161 |
-
?>
|
162 |
-
<p id="ns-checkbox">
|
163 |
-
<input value="1" id="nsu_checkbox" type="checkbox" name="newsletter-signup-do" <?php if($opts['precheck'] == 1) echo 'checked="checked" '; ?>/>
|
164 |
-
<label for="nsu_checkbox">
|
165 |
-
<?php echo $opts['text']; ?>
|
166 |
-
</label>
|
167 |
-
</p>
|
168 |
-
<?php
|
169 |
-
|
170 |
-
$this->showed_checkbox = true;
|
171 |
-
return true;
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Adds a hidden checkbox to the second page of the MultiSite sign-up form (the blog sign-up form) containing the checkbox value of the previous screen
|
176 |
-
*/
|
177 |
-
function add_hidden_checkbox()
|
178 |
-
{
|
179 |
-
?>
|
180 |
-
<input type="hidden" name="newsletter-signup-do" value="<?php echo (isset($_POST['newsletter-signup-do'])) ? 1 : 0; ?>" />
|
181 |
-
<?php
|
182 |
-
}
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Save the value of the checkbox to MultiSite sign-ups table
|
186 |
-
*/
|
187 |
-
function add_checkbox_to_usermeta($meta)
|
188 |
-
{
|
189 |
-
$meta['newsletter-signup-do'] = (isset($_POST['newsletter-signup-do'])) ? 1 : 0;
|
190 |
-
return $meta;
|
191 |
-
}
|
192 |
-
|
193 |
-
/**
|
194 |
-
* Send the post data to the newsletter service, mimic form request
|
195 |
-
*/
|
196 |
-
function send_post_data($email, $name = '', $type = 'checkbox')
|
197 |
-
{
|
198 |
-
$opts = $this->options['mailinglist'];
|
199 |
-
|
200 |
-
// when not using api and no form action has been given, abandon.
|
201 |
-
if(empty($opts['use_api']) && empty($opts['form_action'])) return;
|
202 |
-
|
203 |
-
$post_data = array();
|
204 |
-
|
205 |
-
/* Are we using API? */
|
206 |
-
if($opts['use_api'] == 1) {
|
207 |
-
|
208 |
-
switch($opts['provider']) {
|
209 |
-
|
210 |
-
/* Send data using the YMLP API */
|
211 |
-
case 'ymlp':
|
212 |
-
$request_uri = "http://www.ymlp.com/api/Contacts.Add?";
|
213 |
-
$request_uri .= "Key=" . $opts['ymlp_api_key'];
|
214 |
-
$request_uri .= "&Username=" . $opts['ymlp_username'];
|
215 |
-
$request_uri .= "&Email=" . $email;
|
216 |
-
$request_uri .= "&GroupID=" . $opts['ymlp_groupid'];
|
217 |
-
$request_uri .= $this->add_additional_data(array('format' => 'query_string', 'api' => 'ymlp', 'email' => $email, 'name' => $name));
|
218 |
-
$result = wp_remote_get($request_uri);
|
219 |
-
|
220 |
-
if(isset($_POST['_nsu_debug']) || isset($_GET['_nsu_debug'])) {
|
221 |
-
var_dump($result); die();
|
222 |
-
}
|
223 |
-
|
224 |
-
break;
|
225 |
-
|
226 |
-
/* Send data using the MailChimp API */
|
227 |
-
case 'mailchimp':
|
228 |
-
$request = array(
|
229 |
-
'apikey' => $opts['mc_api_key'],
|
230 |
-
'id' => $opts['mc_list_id'],
|
231 |
-
'email_address' => $email,
|
232 |
-
'double_optin' => (isset($opts['mc_no_double_optin']) && $opts['mc_no_double_optin'] == 1) ? FALSE : TRUE,
|
233 |
-
'merge_vars' => array(
|
234 |
-
'OPTIN_TIME' => date('Y-M-D H:i:s')
|
235 |
-
)
|
236 |
-
);
|
237 |
-
|
238 |
-
if(isset($opts['mc_use_groupings']) && $opts['mc_use_groupings'] == 1 && !empty($opts['mc_groupings_name'])) {
|
239 |
-
$request['merge_vars']['GROUPINGS'] = array(
|
240 |
-
array( 'name' => $opts['mc_groupings_name'], 'groups' => $opts['mc_groupings_groups'] )
|
241 |
-
);
|
242 |
-
}
|
243 |
-
|
244 |
-
/* Subscribe with name? If so, add name to merge_vars array */
|
245 |
-
if(isset($opts['subscribe_with_name']) && $opts['subscribe_with_name'] == 1) {
|
246 |
-
// Try to provide values for First and Lastname fields
|
247 |
-
// These can be overridden, of just ignored by mailchimp.
|
248 |
-
$strpos = strpos($name, ' ');
|
249 |
-
|
250 |
-
$request['merge_vars']['FNAME'] = $name;
|
251 |
-
|
252 |
-
if($strpos) {
|
253 |
-
$request['merge_vars']['FNAME'] = substr($name, 0, $strpos);
|
254 |
-
$request['merge_vars']['LNAME'] = substr($name, $strpos);
|
255 |
-
} else {
|
256 |
-
$request['merge_vars']['FNAME'] = $name;
|
257 |
-
$request['merge_vars']['LNAME'] = '...';
|
258 |
-
}
|
259 |
-
|
260 |
-
$request['merge_vars'][$opts['name_id']] = $name;
|
261 |
-
}
|
262 |
-
// Add any set additional data to merge_vars array
|
263 |
-
$request['merge_vars'] = array_merge($request['merge_vars'], $this->add_additional_data(array('email' => $email, 'name' => $name)));
|
264 |
-
|
265 |
-
$result = wp_remote_post(
|
266 |
-
'http://'.substr($opts['mc_api_key'],-3).'.api.mailchimp.com/1.3/?output=php&method=listSubscribe',
|
267 |
-
array( 'body' => json_encode($request))
|
268 |
-
);
|
269 |
-
|
270 |
-
if(isset($_POST['_nsu_debug']) || isset($_GET['_nsu_debug'])) {
|
271 |
-
var_dump($result); die();
|
272 |
-
}
|
273 |
-
|
274 |
-
break;
|
275 |
-
|
276 |
-
}
|
277 |
-
|
278 |
-
} else {
|
279 |
-
/* We are not using API, mimic a normal form request */
|
280 |
-
|
281 |
-
$post_data = array(
|
282 |
-
$opts['email_id'] => $email,
|
283 |
-
);
|
284 |
-
|
285 |
-
// Subscribe with name? Add to $post_data array.
|
286 |
-
if($opts['subscribe_with_name'] == 1) $post_data[$opts['name_id']] = $name;
|
287 |
-
|
288 |
-
// Add list specific data
|
289 |
-
switch($opts['provider']) {
|
290 |
-
|
291 |
-
case 'aweber':
|
292 |
-
$post_data['listname'] = $opts['aweber_list_name'];
|
293 |
-
$post_data['redirect'] = get_bloginfo('wpurl');
|
294 |
-
$post_data['meta_message'] = '1';
|
295 |
-
$post_data['meta_required'] = 'email';
|
296 |
-
break;
|
297 |
-
|
298 |
-
case 'phplist':
|
299 |
-
$post_data['list['.$opts['phplist_list_id'].']'] = 'signup';
|
300 |
-
$post_data['subscribe'] = "Subscribe";
|
301 |
-
$post_data["htmlemail"] = "1";
|
302 |
-
$post_data['emailconfirm'] = $email;
|
303 |
-
$post_data['makeconfirmed']='0';
|
304 |
-
break;
|
305 |
-
|
306 |
-
}
|
307 |
-
|
308 |
-
$post_data = array_merge($post_data, $this->add_additional_data(array_merge(array('email' => $email, 'name' => $name), $post_data)));
|
309 |
-
|
310 |
-
$result = wp_remote_post($opts['form_action'],
|
311 |
-
array( 'body' => $post_data )
|
312 |
-
);
|
313 |
-
|
314 |
-
if(isset($_POST['_nsu_debug']) || isset($_GET['_nsu_debug'])) {
|
315 |
-
var_dump($result); die();
|
316 |
-
}
|
317 |
-
|
318 |
-
}
|
319 |
-
|
320 |
-
// store a cookie, if preferred by site owner
|
321 |
-
if($opts['cookie_hide'] == 1) @setcookie('ns_subscriber',TRUE,time() + 9999999);
|
322 |
-
|
323 |
-
// Check if we should redirect to a given page
|
324 |
-
if($type == 'form' && strlen($this->options['form']['redirect_to']) > 6) {
|
325 |
-
wp_redirect( $this->options['form']['redirect_to']);
|
326 |
-
exit;
|
327 |
-
} elseif($type == 'checkbox' && strlen($this->options['checkbox']['redirect_to']) > 6) {
|
328 |
-
wp_redirect( $this->options['checkbox']['redirect_to']);
|
329 |
-
exit;
|
330 |
-
}
|
331 |
-
|
332 |
-
return true;
|
333 |
-
}
|
334 |
-
|
335 |
-
|
336 |
-
/**
|
337 |
-
* Returns array with additional data names as key, values as value.
|
338 |
-
* @param array $args, the normal form data (name, email, list variables)
|
339 |
-
*/
|
340 |
-
function add_additional_data($args = array())
|
341 |
-
{
|
342 |
-
$opts = $this->options['mailinglist'];
|
343 |
-
$defaults = array(
|
344 |
-
'format' => 'array',
|
345 |
-
'api' => NULL
|
346 |
-
);
|
347 |
-
|
348 |
-
$args = wp_parse_args( $args, $defaults );
|
349 |
-
|
350 |
-
if($args['format'] == 'query_string') {
|
351 |
-
|
352 |
-
$add_data = "";
|
353 |
-
if(isset($opts['extra_data']) && is_array($opts['extra_data'])) {
|
354 |
-
foreach($opts['extra_data'] as $key => $value) {
|
355 |
-
if($args['api'] == 'ymlp') $value['name'] = str_replace('YMP','Field', $value['name']);
|
356 |
-
|
357 |
-
$value['value'] = str_replace("%%NAME%%", $args['name'], $value['value']);
|
358 |
-
$value['value'] = str_replace("%%IP%%", $_SERVER['REMOTE_ADDR'], $value['value']);
|
359 |
-
$add_data .= "&".$value['name']."=".$value['value'];
|
360 |
-
}
|
361 |
-
}
|
362 |
-
return $add_data;
|
363 |
-
}
|
364 |
-
|
365 |
-
$add_data = array();
|
366 |
-
if(isset($opts['extra_data']) && is_array($opts['extra_data'])) {
|
367 |
-
foreach($opts['extra_data'] as $key => $value) {
|
368 |
-
$value['value'] = str_replace("%%NAME%%", $args['name'], $value['value']);
|
369 |
-
$value['value'] = str_replace("%%IP%%", $_SERVER['REMOTE_ADDR'], $value['value']);
|
370 |
-
$add_data[$value['name']] = $value['value'];
|
371 |
-
}
|
372 |
-
}
|
373 |
-
|
374 |
-
return $add_data;
|
375 |
-
}
|
376 |
-
|
377 |
-
/**
|
378 |
-
* Perform the sign-up for users that registered trough a MultiSite register form
|
379 |
-
* This function differs because of the need to grab the emailadress from the user using get_userdata
|
380 |
-
* @param int $user_id : the ID of the new user
|
381 |
-
* @param string $password : the password, we don't actually use this
|
382 |
-
* @param array $meta : the meta values that belong to this user, holds the value of our 'newsletter-sign-up' checkbox.
|
383 |
-
*/
|
384 |
-
public function grab_email_from_ms_user_signup($user_id, $password = NULL,$meta = NULL){
|
385 |
-
if(!isset($meta['newsletter-signup-do']) || $meta['newsletter-signup-do'] != 1) return;
|
386 |
-
$user_info = get_userdata($user_id);
|
387 |
-
|
388 |
-
$email = $user_info->user_email;
|
389 |
-
$naam = $user_info->first_name;
|
390 |
-
|
391 |
-
$this->send_post_data($email,$naam);
|
392 |
-
}
|
393 |
-
|
394 |
-
/**
|
395 |
-
* Perform the sign-up for users that registered trough a MultiSite register form
|
396 |
-
* This function differs because of the need to grab the emailadress from the user using get_userdata
|
397 |
-
* @param int $blog_id The id of the new blow
|
398 |
-
* @param int $user_id The ID of the new user
|
399 |
-
* @param $a No idea, seriously.
|
400 |
-
* @param $b No idea, seriously.
|
401 |
-
* @param array $meta The meta values that belong to this user, holds the value of our 'newsletter-sign-up' checkbox.
|
402 |
-
*/
|
403 |
-
public function grab_email_from_ms_blog_signup($blog_id, $user_id, $a, $b ,$meta){
|
404 |
-
|
405 |
-
if(!isset($meta['newsletter-signup-do']) || $meta['newsletter-signup-do'] != 1) return;
|
406 |
-
$user_info = get_userdata($user_id);
|
407 |
-
|
408 |
-
$email = $user_info->user_email;
|
409 |
-
$name = $user_info->first_name;
|
410 |
-
|
411 |
-
$this->send_post_data($email, $name);
|
412 |
-
}
|
413 |
-
|
414 |
-
/**
|
415 |
-
* Grab the emailadress (and name) from a regular WP or BuddyPress sign-up and then send this to mailinglist.
|
416 |
-
*/
|
417 |
-
function grab_email_from_wp_signup()
|
418 |
-
{
|
419 |
-
if($_POST['newsletter-signup-do'] != 1) return;
|
420 |
-
|
421 |
-
if(isset($_POST['user_email'])) {
|
422 |
-
|
423 |
-
// gather emailadress from user who WordPress registered
|
424 |
-
$email = $_POST['user_email'];
|
425 |
-
$name = $_POST['user_login'];
|
426 |
-
|
427 |
-
} elseif(isset($_POST['signup_email'])) {
|
428 |
-
|
429 |
-
// gather emailadress from user who BuddyPress registered
|
430 |
-
$email = $_POST['signup_email'];
|
431 |
-
$name = $_POST['signup_username'];
|
432 |
-
|
433 |
-
} else { return; }
|
434 |
-
|
435 |
-
$this->send_post_data($email,$name);
|
436 |
-
}
|
437 |
-
|
438 |
-
/**
|
439 |
-
* Grab the emailadress and name from comment and then send it to mailinglist.
|
440 |
-
* @param int $cid : the ID of the comment
|
441 |
-
* @param object $comment : the comment object, optionally
|
442 |
-
*/
|
443 |
-
public function grab_email_from_comment($cid,$comment = NULL)
|
444 |
-
{
|
445 |
-
if($_POST['newsletter-signup-do'] != 1) return;
|
446 |
-
|
447 |
-
$cid = (int) $cid;
|
448 |
-
|
449 |
-
// get comment data
|
450 |
-
if(!is_object($comment)) $comment = get_comment($cid);
|
451 |
-
|
452 |
-
// if spam, abandon function
|
453 |
-
if($comment->comment_karma != 0) return;
|
454 |
-
|
455 |
-
$email = $comment->comment_author_email;
|
456 |
-
$name = $comment->comment_author;
|
457 |
-
|
458 |
-
$this->send_post_data($email, $name);
|
459 |
-
}
|
460 |
-
|
461 |
-
/**
|
462 |
-
* The NSU form shortcode function. Calls the output_form method
|
463 |
-
*
|
464 |
-
* @param array $atts Not used
|
465 |
-
* @param string $content Not used
|
466 |
-
* @return string Form HTML-code
|
467 |
-
*/
|
468 |
-
public function form_shortcode($atts = null,$content = null)
|
469 |
-
{
|
470 |
-
return $this->output_form(false);
|
471 |
-
}
|
472 |
-
|
473 |
-
/**
|
474 |
-
* Generate the HTML for a form
|
475 |
-
* @param boolean $echo Should HTML be echo'ed?
|
476 |
-
* @return string The generated HTML
|
477 |
-
*/
|
478 |
-
public function output_form($echo = true)
|
479 |
-
{
|
480 |
-
$errors = $this->validation_errors;
|
481 |
-
$opts = $this->getOptions();
|
482 |
-
$additional_fields = '';
|
483 |
-
$output = '';
|
484 |
-
|
485 |
-
$this->no_of_forms++;
|
486 |
-
$formno = $this->no_of_forms;
|
487 |
-
|
488 |
-
/* Set up form variables for API usage or normal form */
|
489 |
-
if($opts['mailinglist']['use_api'] == 1) {
|
490 |
-
|
491 |
-
/* Using API, send form request to ANY page */
|
492 |
-
$form_action = get_site_url();
|
493 |
-
$email_id = 'nsu_email';
|
494 |
-
$name_id = 'nsu_name';
|
495 |
-
|
496 |
-
} else {
|
497 |
-
|
498 |
-
/* Using normal form request, set-up using configuration settings */
|
499 |
-
$form_action = $opts['mailinglist']['form_action'];
|
500 |
-
$email_id = $opts['mailinglist']['email_id'];
|
501 |
-
|
502 |
-
if(!empty($opts['mailinglist']['name_id'])) {
|
503 |
-
$name_id = $opts['mailinglist']['name_id'];
|
504 |
-
}
|
505 |
-
|
506 |
-
}
|
507 |
-
|
508 |
-
/* Set up additional fields */
|
509 |
-
|
510 |
-
if(isset($opts['mailinglist']['extra_data']) && is_array($opts['mailinglist']['extra_data'])) :
|
511 |
-
$additional_fields = '<div class="hidden">';
|
512 |
-
foreach($opts['mailinglist']['extra_data'] as $ed) :
|
513 |
-
if($ed['value'] == '%%NAME%%') continue;
|
514 |
-
$ed['value'] = str_replace("%%IP%%", $_SERVER['REMOTE_ADDR'], $ed['value']);
|
515 |
-
$additional_fields .= "<input type=\"hidden\" name=\"{$ed['name']}\" value=\"{$ed['value']}\" />";
|
516 |
-
endforeach;
|
517 |
-
$additional_fields .= "</div>";
|
518 |
-
endif;
|
519 |
-
|
520 |
-
$email_label = $opts['form']['email_label'];
|
521 |
-
$name_label = $opts['form']['name_label'];
|
522 |
-
|
523 |
-
$email_value = $opts['form']['email_default_value'];
|
524 |
-
$name_value = $opts['form']['name_default_value'];
|
525 |
-
$submit_button = $opts['form']['submit_button'];
|
526 |
-
|
527 |
-
$text_after_signup = $opts['form']['text_after_signup'];
|
528 |
-
$text_after_signup = ($opts['form']['wpautop'] == 1) ? wpautop(wptexturize($text_after_signup)) : $text_after_signup;
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
if(!isset($_POST['nsu_submit']) || count($errors) > 0) { //form has not been submitted yet
|
533 |
-
|
534 |
-
$output .= "<form class=\"nsu-form\" id=\"nsu-form-$formno\" action=\"$form_action\" method=\"post\">";
|
535 |
-
if($opts['mailinglist']['subscribe_with_name'] == 1) {
|
536 |
-
$output .= "<p><label for=\"nsu-name-$formno\">$name_label</label><input class=\"nsu-field\" id=\"nsu-name-$formno\" type=\"text\" name=\"$name_id\" value=\"$name_value\" ";
|
537 |
-
if($name_value) $output .= "onblur=\"if(!this.value) this.value = '$name_value';\" onfocus=\"if(this.value == '$name_value') this.value=''\" ";
|
538 |
-
$output .= "/>";
|
539 |
-
if(isset($errors['name-field'])) $output .= '<span class="nsu-error error notice">'.$errors['name-field'].'</span>';
|
540 |
-
$output .= "</p>";
|
541 |
-
}
|
542 |
-
|
543 |
-
$output .= "<p><label for=\"nsu-email-$formno\">$email_label</label><input class=\"nsu-field\" id=\"nsu-email-$formno\" type=\"text\" name=\"$email_id\" value=\"$email_value\" ";
|
544 |
-
if($email_value) $output .= "onblur=\"if(!this.value) this.value = '$email_value';\" onfocus=\"if(this.value == '$email_value') this.value = ''\" ";
|
545 |
-
$output .= "/>";
|
546 |
-
if(isset($errors['email-field'])) $output .= '<span class="nsu-error error notice">'.$errors['email-field'].'</span>';
|
547 |
-
$output .= "</p>";
|
548 |
-
$output .= $additional_fields;
|
549 |
-
$output .= "<p><input type=\"submit\" id=\"nsu-submit-$formno\" class=\"nsu-submit\" name=\"nsu_submit\" value=\"$submit_button\" /></p>";
|
550 |
-
$output .= "</form>";
|
551 |
-
|
552 |
-
} else { // form has been submitted
|
553 |
-
|
554 |
-
$output = "<p id=\"nsu-signed-up-$formno\" class=\"nsu-signed-up\">$text_after_signup</p>";
|
555 |
-
|
556 |
-
}
|
557 |
-
|
558 |
-
if($echo) {
|
559 |
-
echo $output;
|
560 |
-
}
|
561 |
-
|
562 |
-
return $output;
|
563 |
-
|
564 |
-
}
|
565 |
-
}
|
566 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/NSU.php
ADDED
@@ -0,0 +1,315 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class NSU {
|
4 |
+
|
5 |
+
private $options = array();
|
6 |
+
private static $instance = null;
|
7 |
+
private static $checkbox = null;
|
8 |
+
private static $form = null;
|
9 |
+
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
self::$instance = $this;
|
13 |
+
|
14 |
+
$opts = $this->get_options();
|
15 |
+
|
16 |
+
// widget hooks
|
17 |
+
add_action('widgets_init', array($this, 'register_widget'));
|
18 |
+
|
19 |
+
// Should we load the stylesheet?
|
20 |
+
if($opts['checkbox']['css_reset'] == 1 || $opts['form']['load_form_css'] == 1) {
|
21 |
+
add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
|
22 |
+
}
|
23 |
+
|
24 |
+
self::checkbox();
|
25 |
+
self::form();
|
26 |
+
|
27 |
+
if(!defined("DOING_AJAX") || !DOING_AJAX) {
|
28 |
+
// regular request
|
29 |
+
if(is_admin()) {
|
30 |
+
|
31 |
+
// backend only
|
32 |
+
require_once NSU_PLUGIN_DIR . 'includes/NSU_Admin.php';
|
33 |
+
new NSU_Admin();
|
34 |
+
} else {
|
35 |
+
// frontend only
|
36 |
+
require_once NSU_PLUGIN_DIR . 'includes/functions.php';
|
37 |
+
}
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
public static function checkbox()
|
42 |
+
{
|
43 |
+
if(!self::$checkbox) {
|
44 |
+
require_once NSU_PLUGIN_DIR .'includes/NSU_Checkbox.php';
|
45 |
+
self::$checkbox = new NSU_Checkbox;
|
46 |
+
}
|
47 |
+
|
48 |
+
return self::$checkbox;
|
49 |
+
}
|
50 |
+
|
51 |
+
public static function form()
|
52 |
+
{
|
53 |
+
if(!self::$form) {
|
54 |
+
require_once NSU_PLUGIN_DIR . 'includes/NSU_Form.php';
|
55 |
+
self::$form = new NSU_Form;
|
56 |
+
}
|
57 |
+
|
58 |
+
return self::$form;
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Initalize options
|
64 |
+
* @return array $options
|
65 |
+
*/
|
66 |
+
public function get_options()
|
67 |
+
{
|
68 |
+
if(empty($this->options)) {
|
69 |
+
$keys = array('form', 'mailinglist', 'checkbox');
|
70 |
+
|
71 |
+
$defaults = array(
|
72 |
+
'form' => array('load_form_css' => 0, 'use_html5' => 1, 'submit_button' => 'Sign up',
|
73 |
+
'name_label' => 'Name:', 'email_label' => "Email:", 'email_default_value' => 'Your emailaddress..', 'name_required' => 0, 'name_default_value' => 'Your name..', 'wpautop' => 0,
|
74 |
+
'text_after_signup' => 'Thanks for signing up to our newsletter. Please check your inbox to confirm your email address.', 'redirect_to' => '',
|
75 |
+
'text_empty_name' => 'Please fill in the name field.', 'text_empty_email' => 'Please fill in the email field.', 'text_invalid_email' => 'Please enter a valid email address.'
|
76 |
+
),
|
77 |
+
'mailinglist' => array('provider' => '', 'use_api' => 0, 'subscribe_with_name' => 0, 'email_id' => '', 'name_id' => '', 'form_action' => ''),
|
78 |
+
'checkbox' => array('text' => 'Sign me up for the newsletter', 'redirect_to' => '', 'precheck' => 0, 'cookie_hide' => 0, 'css_reset' => 0,
|
79 |
+
'add_to_registration_form' => 0, 'add_to_comment_form' => 1, 'add_to_buddypress_form' => 0,
|
80 |
+
'add_to_multisite_form' => 0, 'add_to_bbpress_forms' => 0
|
81 |
+
)
|
82 |
+
);
|
83 |
+
|
84 |
+
foreach($keys as $key) {
|
85 |
+
if(($option = get_option('nsu_'. $key)) == false) {
|
86 |
+
add_option('nsu_'. $key, $defaults[$key]);
|
87 |
+
}
|
88 |
+
|
89 |
+
$this->options[$key] = array_merge($defaults[$key], (array) $option);
|
90 |
+
}
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
return $this->options;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Registers the Newsletter Sign-Up Widget
|
99 |
+
* @return type
|
100 |
+
*/
|
101 |
+
public function register_widget()
|
102 |
+
{
|
103 |
+
require_once NSU_PLUGIN_DIR . 'includes/NewsletterSignUpWidget.php';
|
104 |
+
return register_widget('NewsletterSignUpWidget');
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Factory method for NewsletterSignUp class. Only instantiate once.
|
109 |
+
* @return NewsletterSignUp Instance of Newsletter Sign-Up class
|
110 |
+
*/
|
111 |
+
public static function instance() {
|
112 |
+
if(!self::$instance) self::$instance = new NSU();
|
113 |
+
|
114 |
+
return self::$instance;
|
115 |
+
}
|
116 |
+
|
117 |
+
public function enqueue_styles()
|
118 |
+
{
|
119 |
+
$opts = $this->get_options();
|
120 |
+
|
121 |
+
// Build stylesheet url --------------
|
122 |
+
$stylesheet_opts = '?';
|
123 |
+
|
124 |
+
// Load CSS to reset the checkbox' position?
|
125 |
+
if($opts['checkbox']['css_reset'] == 1) {
|
126 |
+
$stylesheet_opts .= 'checkbox_reset=1&';
|
127 |
+
}
|
128 |
+
|
129 |
+
// Load CSS to reset label and input fields for the sign-up form?
|
130 |
+
if($opts['form']['load_form_css'] == 1) {
|
131 |
+
$stylesheet_opts .= 'form_css=1&';
|
132 |
+
}
|
133 |
+
|
134 |
+
wp_enqueue_style('ns_checkbox_style', plugins_url("/assets/css/newsletter-sign-up.php{$stylesheet_opts}", dirname(__FILE__)));
|
135 |
+
}
|
136 |
+
|
137 |
+
|
138 |
+
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Send the post data to the newsletter service, mimic form request
|
142 |
+
*/
|
143 |
+
function send_post_data($email, $name = '', $type = 'checkbox')
|
144 |
+
{
|
145 |
+
$opts = $this->options['mailinglist'];
|
146 |
+
|
147 |
+
// when not using api and no form action has been given, abandon.
|
148 |
+
if(empty($opts['use_api']) && empty($opts['form_action'])) return;
|
149 |
+
|
150 |
+
/* Are we using API? */
|
151 |
+
if($opts['use_api'] == 1) {
|
152 |
+
|
153 |
+
switch($opts['provider']) {
|
154 |
+
|
155 |
+
/* Send data using the YMLP API */
|
156 |
+
case 'ymlp':
|
157 |
+
$data = array(
|
158 |
+
'key' => $opts['ymlp_api_key'],
|
159 |
+
'username' => $opts['ymlp_username'],
|
160 |
+
'Email' => $email,
|
161 |
+
'GroupId' => $opts['ymlp_groupid'],
|
162 |
+
'output' => 'JSON'
|
163 |
+
);
|
164 |
+
|
165 |
+
$data = array_merge($data, $this->add_additional_data(array('api' => 'ymlp')));
|
166 |
+
$data = http_build_query($data);
|
167 |
+
$url = 'https://www.ymlp.com/api/Contacts.Add?'.$data;
|
168 |
+
|
169 |
+
$result = wp_remote_post($url);
|
170 |
+
|
171 |
+
if(isset($_POST['_nsu_debug']) || isset($_GET['_nsu_debug'])) {
|
172 |
+
var_dump($result); die();
|
173 |
+
}
|
174 |
+
|
175 |
+
break;
|
176 |
+
|
177 |
+
/* Send data using the MailChimp API */
|
178 |
+
case 'mailchimp':
|
179 |
+
$request = array(
|
180 |
+
'apikey' => $opts['mc_api_key'],
|
181 |
+
'id' => $opts['mc_list_id'],
|
182 |
+
'email_address' => $email,
|
183 |
+
'double_optin' => (isset($opts['mc_no_double_optin']) && $opts['mc_no_double_optin'] == 1) ? FALSE : TRUE,
|
184 |
+
'merge_vars' => array(
|
185 |
+
'OPTIN_TIME' => date('Y-M-D H:i:s')
|
186 |
+
)
|
187 |
+
);
|
188 |
+
|
189 |
+
if(isset($opts['mc_use_groupings']) && $opts['mc_use_groupings'] == 1 && !empty($opts['mc_groupings_name'])) {
|
190 |
+
$request['merge_vars']['GROUPINGS'] = array(
|
191 |
+
array( 'name' => $opts['mc_groupings_name'], 'groups' => $opts['mc_groupings_groups'] )
|
192 |
+
);
|
193 |
+
}
|
194 |
+
|
195 |
+
/* Subscribe with name? If so, add name to merge_vars array */
|
196 |
+
if(isset($opts['subscribe_with_name']) && $opts['subscribe_with_name'] == 1) {
|
197 |
+
// Try to provide values for First and Lastname fields
|
198 |
+
// These can be overridden, of just ignored by mailchimp.
|
199 |
+
$strpos = strpos($name, ' ');
|
200 |
+
|
201 |
+
$request['merge_vars']['FNAME'] = $name;
|
202 |
+
|
203 |
+
if($strpos) {
|
204 |
+
$request['merge_vars']['FNAME'] = substr($name, 0, $strpos);
|
205 |
+
$request['merge_vars']['LNAME'] = substr($name, $strpos);
|
206 |
+
} else {
|
207 |
+
$request['merge_vars']['FNAME'] = $name;
|
208 |
+
$request['merge_vars']['LNAME'] = '...';
|
209 |
+
}
|
210 |
+
|
211 |
+
$request['merge_vars'][$opts['name_id']] = $name;
|
212 |
+
}
|
213 |
+
|
214 |
+
// Add any set additional data to merge_vars array
|
215 |
+
$request['merge_vars'] = array_merge($request['merge_vars'], $this->add_additional_data(array('email' => $email, 'name' => $name)));
|
216 |
+
|
217 |
+
$result = wp_remote_post(
|
218 |
+
'http://'.substr($opts['mc_api_key'],-3).'.api.mailchimp.com/1.3/?output=php&method=listSubscribe',
|
219 |
+
array( 'body' => json_encode($request))
|
220 |
+
);
|
221 |
+
|
222 |
+
if(isset($_POST['_nsu_debug']) || isset($_GET['_nsu_debug'])) {
|
223 |
+
var_dump($result); die();
|
224 |
+
}
|
225 |
+
|
226 |
+
break;
|
227 |
+
|
228 |
+
}
|
229 |
+
|
230 |
+
} else {
|
231 |
+
/* We are not using API, mimic a normal form request */
|
232 |
+
|
233 |
+
$post_data = array(
|
234 |
+
$opts['email_id'] => $email,
|
235 |
+
);
|
236 |
+
|
237 |
+
// Subscribe with name? Add to $post_data array.
|
238 |
+
if($opts['subscribe_with_name'] == 1) $post_data[$opts['name_id']] = $name;
|
239 |
+
|
240 |
+
// Add list specific data
|
241 |
+
switch($opts['provider']) {
|
242 |
+
|
243 |
+
case 'aweber':
|
244 |
+
$post_data['listname'] = $opts['aweber_list_name'];
|
245 |
+
$post_data['redirect'] = get_bloginfo('wpurl');
|
246 |
+
$post_data['meta_message'] = '1';
|
247 |
+
$post_data['meta_required'] = 'email';
|
248 |
+
break;
|
249 |
+
|
250 |
+
case 'phplist':
|
251 |
+
$post_data['list['.$opts['phplist_list_id'].']'] = 'signup';
|
252 |
+
$post_data['subscribe'] = "Subscribe";
|
253 |
+
$post_data["htmlemail"] = "1";
|
254 |
+
$post_data['emailconfirm'] = $email;
|
255 |
+
$post_data['makeconfirmed']='0';
|
256 |
+
break;
|
257 |
+
|
258 |
+
}
|
259 |
+
|
260 |
+
$post_data = array_merge($post_data, $this->add_additional_data(array_merge(array('email' => $email, 'name' => $name), $post_data)));
|
261 |
+
|
262 |
+
$result = wp_remote_post($opts['form_action'],
|
263 |
+
array( 'body' => $post_data )
|
264 |
+
);
|
265 |
+
|
266 |
+
if(isset($_POST['_nsu_debug']) || isset($_GET['_nsu_debug'])) {
|
267 |
+
var_dump($result); die();
|
268 |
+
}
|
269 |
+
|
270 |
+
}
|
271 |
+
|
272 |
+
// store a cookie, if preferred by site owner
|
273 |
+
if($type == 'checkbox' && $this->options['checkbox']['cookie_hide'] == 1) @setcookie('ns_subscriber',TRUE,time() + 9999999);
|
274 |
+
|
275 |
+
// Check if we should redirect to a given page
|
276 |
+
if($type == 'form' && strlen($this->options['form']['redirect_to']) > 6) {
|
277 |
+
wp_redirect( $this->options['form']['redirect_to']);
|
278 |
+
exit;
|
279 |
+
} elseif($type == 'checkbox' && strlen($this->options['checkbox']['redirect_to']) > 6) {
|
280 |
+
wp_redirect( $this->options['checkbox']['redirect_to']);
|
281 |
+
exit;
|
282 |
+
}
|
283 |
+
|
284 |
+
return true;
|
285 |
+
}
|
286 |
+
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Returns array with additional data names as key, values as value.
|
290 |
+
* @param array $args, the normal form data (name, email, list variables)
|
291 |
+
*/
|
292 |
+
function add_additional_data($args = array())
|
293 |
+
{
|
294 |
+
$opts = $this->options['mailinglist'];
|
295 |
+
$defaults = array(
|
296 |
+
'format' => 'array',
|
297 |
+
'api' => NULL
|
298 |
+
);
|
299 |
+
|
300 |
+
$args = wp_parse_args( $args, $defaults );
|
301 |
+
|
302 |
+
$add_data = array();
|
303 |
+
if(isset($opts['extra_data']) && is_array($opts['extra_data'])) {
|
304 |
+
foreach($opts['extra_data'] as $key => $value) {
|
305 |
+
if($args['api'] == 'ymlp') $value['name'] = str_replace('YMP','Field', $value['name']);
|
306 |
+
$value['value'] = str_replace("%%NAME%%", $args['name'], $value['value']);
|
307 |
+
$value['value'] = str_replace("%%IP%%", $_SERVER['REMOTE_ADDR'], $value['value']);
|
308 |
+
$add_data[$value['name']] = $value['value'];
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
+
return $add_data;
|
313 |
+
}
|
314 |
+
|
315 |
+
}
|
backend/NewsletterSignUpAdmin.php → includes/NSU_Admin.php
RENAMED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
-
if (!class_exists('
|
3 |
|
4 |
-
class
|
5 |
|
6 |
private $hook = 'newsletter-sign-up';
|
7 |
private $longname = 'Newsletter Sign-Up';
|
@@ -9,32 +9,57 @@ if (!class_exists('NewsletterSignUpAdmin')) {
|
|
9 |
private $plugin_url = 'http://dannyvankooten.com/wordpress-plugins/newsletter-sign-up/';
|
10 |
private $filename = 'newsletter-sign-up/newsletter-sign-up.php';
|
11 |
private $accesslvl = 'manage_options';
|
12 |
-
private $icon_url = '';
|
13 |
private $bp_active = FALSE;
|
14 |
private $options = array();
|
15 |
|
16 |
-
public function __construct(
|
17 |
-
$this->options =
|
18 |
-
|
19 |
-
|
20 |
add_filter("plugin_action_links_{$this->filename}", array($this, 'add_settings_link'));
|
21 |
add_action('admin_menu', array($this, 'add_option_page'));
|
22 |
add_action('admin_init', array($this, 'settings_init'));
|
23 |
-
|
24 |
-
// register function to remove options upon deactivation
|
25 |
-
register_deactivation_hook($this->filename, array($this, 'remove_options'));
|
26 |
-
|
27 |
add_action( 'admin_enqueue_scripts', array($this, 'load_css_and_js') );
|
28 |
add_action('bp_include', array($this, 'set_bp_active'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
public function load_css_and_js($hook)
|
32 |
{
|
33 |
if(!stripos($hook, $this->hook)) { return false; }
|
34 |
|
35 |
-
wp_enqueue_style($this->hook, plugins_url('/
|
36 |
-
wp_enqueue_script(array('jquery'
|
37 |
-
wp_enqueue_script($this->hook, plugins_url('/
|
38 |
}
|
39 |
|
40 |
/**
|
@@ -48,6 +73,7 @@ if (!class_exists('NewsletterSignUpAdmin')) {
|
|
48 |
* The default settings page
|
49 |
*/
|
50 |
public function options_page_default() {
|
|
|
51 |
$opts = $this->options['mailinglist'];
|
52 |
|
53 |
$viewed_mp = NULL;
|
@@ -97,6 +123,7 @@ if (!class_exists('NewsletterSignUpAdmin')) {
|
|
97 |
* The admin page for managing checkbox settings
|
98 |
*/
|
99 |
public function options_page_checkbox_settings() {
|
|
|
100 |
$opts = $this->options['checkbox'];
|
101 |
require 'views/checkbox_settings.php';
|
102 |
}
|
@@ -105,6 +132,7 @@ if (!class_exists('NewsletterSignUpAdmin')) {
|
|
105 |
* The admin page for managing form settings
|
106 |
*/
|
107 |
public function options_page_form_settings() {
|
|
|
108 |
$opts = $this->options['form'];
|
109 |
$opts['mailinglist'] = $this->options['mailinglist'];
|
110 |
require 'views/form_settings.php';
|
@@ -114,7 +142,7 @@ if (!class_exists('NewsletterSignUpAdmin')) {
|
|
114 |
* The page for the configuration extractor
|
115 |
*/
|
116 |
public function options_page_config_helper() {
|
117 |
-
|
118 |
if (isset($_POST['form'])) {
|
119 |
$error = true;
|
120 |
|
@@ -181,96 +209,15 @@ if (!class_exists('NewsletterSignUpAdmin')) {
|
|
181 |
require 'views/config_helper.php';
|
182 |
}
|
183 |
|
184 |
-
/**
|
185 |
-
* Renders a donate box
|
186 |
-
*/
|
187 |
-
public function donate_box() {
|
188 |
-
$content = '
|
189 |
-
<p>I spent countless hours developing this plugin for <b>FREE</b>. If you like it, consider donating a token of your appreciation.</p>
|
190 |
-
|
191 |
-
<form class="donate" action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
192 |
-
<input type="hidden" name="cmd" value="_donations">
|
193 |
-
<input type="hidden" name="business" value="AP87UHXWPNBBU">
|
194 |
-
<input type="hidden" name="lc" value="US">
|
195 |
-
<input type="hidden" name="item_name" value="Danny van Kooten">
|
196 |
-
<input type="hidden" name="item_number" value="Newsletter Sign-Up">
|
197 |
-
<input type="hidden" name="currency_code" value="USD">
|
198 |
-
<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHosted">
|
199 |
-
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
200 |
-
<img alt="" border="0" src="https://www.paypalobjects.com/nl_NL/i/scr/pixel.gif" width="1" height="1">
|
201 |
-
</form>
|
202 |
-
|
203 |
-
<p>Alternatively, you can: </p>
|
204 |
-
<ul>
|
205 |
-
<li><a href="http://wordpress.org/support/view/plugin-reviews/newsletter-sign-up?rate=5#postform" target="_blank">Give a 5★ rating on WordPress.org</a></li>
|
206 |
-
<li><a href="http://dannyvankooten.com/wordpress-plugins/newsletter-sign-up/" target="_blank">Blog about it and link to the plugin page</a></li>
|
207 |
-
<li><a href="http://twitter.com/?status=I%20manage%20my%20%23WordPress%20sign-up%20forms%20using%20%40DannyvanKooten%20%27s%20Newsletter%20Sign-Up%20plugin%20and%20I%20love%20it%20-%20check%20it%20out!%20http%3A%2F%2Fwordpress.org%2Fplugins%2Fnewsletter-sign-up%2F" target="_blank">Tweet about Newsletter Sign-Up</a></li>
|
208 |
-
</ul>';
|
209 |
-
$this->postbox($this->hook . '-donatebox', 'Donate $10, $20 or $50!', $content);
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* Renders a box with the latests posts from DannyvanKooten.com
|
214 |
-
*/
|
215 |
-
public function latest_posts() {
|
216 |
-
require_once(ABSPATH . WPINC . '/rss.php');
|
217 |
-
if ($rss = fetch_rss('http://feeds.feedburner.com/dannyvankooten')) {
|
218 |
-
$content = '<ul>';
|
219 |
-
$rss->items = array_slice($rss->items, 0, 5);
|
220 |
-
|
221 |
-
foreach ((array) $rss->items as $item) {
|
222 |
-
$content .= '<li class="dvk-rss-item">';
|
223 |
-
$content .= '<a target="_blank" href="' . clean_url($item['link'], $protocolls = null, 'display') . '">' . $item['title'] . '</a> ';
|
224 |
-
$content .= '</li>';
|
225 |
-
}
|
226 |
-
$content .= '<li class="dvk-rss"><a href="http://dannyvankooten.com/feed/">Subscribe to my RSS feed</a></li>';
|
227 |
-
$content .= '<li class="dvk-email"><a href="http://dannyvankooten.com/newsletter/">Subscribe by email</a></li>';
|
228 |
-
$content .= '<li class="dvk-twitter">You should follow me on twitter <a href="http://twitter.com/dannyvankooten">here</a></li>';
|
229 |
-
$content .= '</ul><br style="clear:both;" />';
|
230 |
-
} else {
|
231 |
-
$content = '<p>No updates..</p>';
|
232 |
-
}
|
233 |
-
$this->postbox($this->hook . '-latestpostbox', 'Latest blog posts..', $content);
|
234 |
-
}
|
235 |
-
|
236 |
-
|
237 |
-
/**
|
238 |
-
* Renders a box with a link to the support forums for NSU
|
239 |
-
*/
|
240 |
-
public function support_box() {
|
241 |
-
$content = '<p>Are you having trouble setting-up ' . $this->shortname . ', experiencing an error or got a great idea on how to improve it?</p><p>Please, post
|
242 |
-
your question or tip in the <a target="_blank" href="http://wordpress.org/tags/' . $this->hook . '">support forums</a> on WordPress.org. This is so that others can benefit from this too.</p>';
|
243 |
-
$this->postbox($this->hook . '-support-box', "Looking for support?", $content);
|
244 |
-
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* Output's the necessary HTML formatting for a postbox
|
248 |
-
*
|
249 |
-
* @param string $id
|
250 |
-
* @param string $title
|
251 |
-
* @param string $content
|
252 |
-
*/
|
253 |
-
public function postbox($id, $title, $content) {
|
254 |
-
?>
|
255 |
-
<div id="<?php echo $id; ?>" class="dvk-box">
|
256 |
-
|
257 |
-
<h3 class="hndle"><?php echo $title; ?></h3>
|
258 |
-
<div class="inside">
|
259 |
-
<?php echo $content; ?>
|
260 |
-
</div>
|
261 |
-
</div>
|
262 |
-
<?php
|
263 |
-
}
|
264 |
-
|
265 |
/**
|
266 |
* Adds the different menu pages
|
267 |
*/
|
268 |
public function add_option_page() {
|
269 |
-
add_menu_page($this->longname, "Newsl. Sign-up", $this->accesslvl, $this->hook, array($this, 'options_page_default'),
|
270 |
-
add_submenu_page($this->hook, "Newsletter Sign-Up :: Mailinglist Settings", "List Settings", $this->accesslvl, $this->hook, array($this, 'options_page_default'));
|
271 |
-
add_submenu_page($this->hook, "Newsletter Sign-Up :: Checkbox Settings", "Checkbox Settings", $this->accesslvl, $this->hook . '
|
272 |
-
add_submenu_page($this->hook, "Newsletter Sign-Up :: Form Settings", "Form Settings", $this->accesslvl, $this->hook . '
|
273 |
-
add_submenu_page($this->hook, "Newsletter Sign-Up :: Configuration Extractor", "Config Extractor", $this->accesslvl, $this->hook . '
|
274 |
}
|
275 |
|
276 |
/**
|
@@ -293,15 +240,6 @@ if (!class_exists('NewsletterSignUpAdmin')) {
|
|
293 |
register_setting('nsu_checkbox_group', 'nsu_checkbox', array($this, 'validate_checkbox_options'));
|
294 |
}
|
295 |
|
296 |
-
/**
|
297 |
-
* Removes the options from database, this function is hooked to deactivation of NSU.
|
298 |
-
*/
|
299 |
-
public function remove_options() {
|
300 |
-
delete_option('nsu_form');
|
301 |
-
delete_option('nsu_checkbox');
|
302 |
-
delete_option('nsu_mailinglist');
|
303 |
-
}
|
304 |
-
|
305 |
/**
|
306 |
* Validate the submitted options
|
307 |
* @param array $options The submitted options
|
@@ -311,12 +249,18 @@ if (!class_exists('NewsletterSignUpAdmin')) {
|
|
311 |
}
|
312 |
|
313 |
public function validate_form_options($options) {
|
|
|
314 |
$options['text_after_signup'] = strip_tags($options['text_after_signup'], '<a><b><strong><i><img><em><br><p><ul><li><ol>');
|
315 |
|
316 |
// redirect to url should start with http
|
317 |
if(isset($options['redirect_to']) && substr($options['redirect_to'],0,4) != 'http') {
|
318 |
$options['redirect_to'] = '';
|
319 |
}
|
|
|
|
|
|
|
|
|
|
|
320 |
|
321 |
return $options;
|
322 |
}
|
@@ -333,6 +277,7 @@ if (!class_exists('NewsletterSignUpAdmin')) {
|
|
333 |
}
|
334 |
|
335 |
public function validate_checkbox_options($options) {
|
|
|
336 |
return $options;
|
337 |
}
|
338 |
|
1 |
<?php
|
2 |
+
if (!class_exists('NSU_Admin')) {
|
3 |
|
4 |
+
class NSU_Admin {
|
5 |
|
6 |
private $hook = 'newsletter-sign-up';
|
7 |
private $longname = 'Newsletter Sign-Up';
|
9 |
private $plugin_url = 'http://dannyvankooten.com/wordpress-plugins/newsletter-sign-up/';
|
10 |
private $filename = 'newsletter-sign-up/newsletter-sign-up.php';
|
11 |
private $accesslvl = 'manage_options';
|
|
|
12 |
private $bp_active = FALSE;
|
13 |
private $options = array();
|
14 |
|
15 |
+
public function __construct() {
|
16 |
+
$this->options = NSU::instance()->get_options();
|
17 |
+
|
|
|
18 |
add_filter("plugin_action_links_{$this->filename}", array($this, 'add_settings_link'));
|
19 |
add_action('admin_menu', array($this, 'add_option_page'));
|
20 |
add_action('admin_init', array($this, 'settings_init'));
|
|
|
|
|
|
|
|
|
21 |
add_action( 'admin_enqueue_scripts', array($this, 'load_css_and_js') );
|
22 |
add_action('bp_include', array($this, 'set_bp_active'));
|
23 |
+
|
24 |
+
if(isset($_GET['nsu-hide-mc4wp-notice'])) {
|
25 |
+
add_option("nsu_hide_mc4wp_notice", true);
|
26 |
+
} elseif($this->options['mailinglist']['provider'] == 'mailchimp' && get_option('nsu_hide_mc4wp_notice') == false) {
|
27 |
+
add_action( 'admin_notices', array($this, 'notice_mailchimp_for_wp'));
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
public function get_checkbox_compatible_plugins()
|
34 |
+
{
|
35 |
+
|
36 |
+
$checkbox_plugins = array(
|
37 |
+
'comment_form' => "Comment form",
|
38 |
+
"registration_form" => "Registration form"
|
39 |
+
);
|
40 |
+
if(is_multisite()) { $checkbox_plugins['ms_form'] = "MultiSite forms"; }
|
41 |
+
if(class_exists("BuddyPress")) $checkbox_plugins['bp_form'] = "BuddyPress registration";
|
42 |
+
if(class_exists('bbPress')) $checkbox_plugins['bbpress_forms'] = "bbPress";
|
43 |
+
return $checkbox_plugins;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function notice_mailchimp_for_wp()
|
47 |
+
{
|
48 |
+
?>
|
49 |
+
<div class="updated">
|
50 |
+
<p><strong>Newsletter Sign-Up Notice:</strong> You are using MailChimp, great! Consider switching to <a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">MailChimp for WordPress</a>, you will <strong>love</strong> it.
|
51 |
+
It can be downloaded from the WordPress repository <a href="http://wordpress.org/plugins/mailchimp-for-wp/">here</a>. | <a href="?nsu-hide-mc4wp-notice=1">Hide Notice</a></p>
|
52 |
+
</div>
|
53 |
+
<?php
|
54 |
}
|
55 |
|
56 |
public function load_css_and_js($hook)
|
57 |
{
|
58 |
if(!stripos($hook, $this->hook)) { return false; }
|
59 |
|
60 |
+
wp_enqueue_style($this->hook, plugins_url('newsletter-sign-up/assets/css/admin.css'));
|
61 |
+
wp_enqueue_script(array('jquery'));
|
62 |
+
wp_enqueue_script($this->hook, plugins_url('newsletter-sign-up/assets/js/admin.js'));
|
63 |
}
|
64 |
|
65 |
/**
|
73 |
* The default settings page
|
74 |
*/
|
75 |
public function options_page_default() {
|
76 |
+
$tab = 'mailinglist-settings';
|
77 |
$opts = $this->options['mailinglist'];
|
78 |
|
79 |
$viewed_mp = NULL;
|
123 |
* The admin page for managing checkbox settings
|
124 |
*/
|
125 |
public function options_page_checkbox_settings() {
|
126 |
+
$tab = 'checkbox-settings';
|
127 |
$opts = $this->options['checkbox'];
|
128 |
require 'views/checkbox_settings.php';
|
129 |
}
|
132 |
* The admin page for managing form settings
|
133 |
*/
|
134 |
public function options_page_form_settings() {
|
135 |
+
$tab = 'form-settings';
|
136 |
$opts = $this->options['form'];
|
137 |
$opts['mailinglist'] = $this->options['mailinglist'];
|
138 |
require 'views/form_settings.php';
|
142 |
* The page for the configuration extractor
|
143 |
*/
|
144 |
public function options_page_config_helper() {
|
145 |
+
$tab = 'config-helper';
|
146 |
if (isset($_POST['form'])) {
|
147 |
$error = true;
|
148 |
|
209 |
require 'views/config_helper.php';
|
210 |
}
|
211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
/**
|
213 |
* Adds the different menu pages
|
214 |
*/
|
215 |
public function add_option_page() {
|
216 |
+
add_menu_page($this->longname, "Newsl. Sign-up", $this->accesslvl, $this->hook, array($this, 'options_page_default'), plugins_url('newsletter-sign-up/assets/img/icon.png'));
|
217 |
+
add_submenu_page($this->hook, "Newsletter Sign-Up :: Mailinglist Settings", "List Settings", $this->accesslvl, $this->hook, array($this, 'options_page_default'));
|
218 |
+
add_submenu_page($this->hook, "Newsletter Sign-Up :: Checkbox Settings", "Checkbox Settings", $this->accesslvl, $this->hook . '-checkbox-settings', array($this, 'options_page_checkbox_settings'));
|
219 |
+
add_submenu_page($this->hook, "Newsletter Sign-Up :: Form Settings", "Form Settings", $this->accesslvl, $this->hook . '-form-settings', array($this, 'options_page_form_settings'));
|
220 |
+
add_submenu_page($this->hook, "Newsletter Sign-Up :: Configuration Extractor", "Config Extractor", $this->accesslvl, $this->hook . '-config-helper', array($this, 'options_page_config_helper'));
|
221 |
}
|
222 |
|
223 |
/**
|
240 |
register_setting('nsu_checkbox_group', 'nsu_checkbox', array($this, 'validate_checkbox_options'));
|
241 |
}
|
242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
/**
|
244 |
* Validate the submitted options
|
245 |
* @param array $options The submitted options
|
249 |
}
|
250 |
|
251 |
public function validate_form_options($options) {
|
252 |
+
|
253 |
$options['text_after_signup'] = strip_tags($options['text_after_signup'], '<a><b><strong><i><img><em><br><p><ul><li><ol>');
|
254 |
|
255 |
// redirect to url should start with http
|
256 |
if(isset($options['redirect_to']) && substr($options['redirect_to'],0,4) != 'http') {
|
257 |
$options['redirect_to'] = '';
|
258 |
}
|
259 |
+
|
260 |
+
$options['name_required'] = (isset($options['name_required'])) ? 1 : 0;
|
261 |
+
$options['wpautop'] = (isset($options['wpautop'])) ? 1 : 0;
|
262 |
+
$options['use_html5'] = (isset($options['use_html5'])) ? 1 : 0;
|
263 |
+
$options['load_form_css'] = (isset($options['load_form_css'])) ? 1 : 0;
|
264 |
|
265 |
return $options;
|
266 |
}
|
277 |
}
|
278 |
|
279 |
public function validate_checkbox_options($options) {
|
280 |
+
$options['add_to_comment_form'] = (isset($options['add_to_comment_form'])) ? 1 : 0;
|
281 |
return $options;
|
282 |
}
|
283 |
|
includes/NSU_Checkbox.php
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class NSU_Checkbox {
|
4 |
+
|
5 |
+
private $showed_checkbox = false;
|
6 |
+
|
7 |
+
public function __construct()
|
8 |
+
{
|
9 |
+
|
10 |
+
$options = NSU::instance()->get_options();
|
11 |
+
$opts = $this->options = $options['checkbox'];
|
12 |
+
|
13 |
+
// add hooks
|
14 |
+
|
15 |
+
if($opts['add_to_comment_form'] == 1) {
|
16 |
+
add_action('thesis_hook_after_comment_box', array($this, 'output_checkbox'), 20);
|
17 |
+
add_action('comment_form', array($this, 'output_checkbox'), 20);
|
18 |
+
add_action('comment_post', array($this, 'grab_email_from_comment'), 20, 2);
|
19 |
+
}
|
20 |
+
|
21 |
+
if($opts['add_to_registration_form'] == 1) {
|
22 |
+
add_action('register_form',array($this, 'output_checkbox'), 20);
|
23 |
+
add_action('register_post',array($this, 'grab_email_from_wp_signup'), 50);
|
24 |
+
}
|
25 |
+
|
26 |
+
if($opts['add_to_buddypress_form'] == 1) {
|
27 |
+
add_action('bp_before_registration_submit_buttons', array($this, 'output_checkbox'), 20);
|
28 |
+
add_action('bp_complete_signup', array($this, 'grab_email_from_wp_signup'), 20);
|
29 |
+
}
|
30 |
+
|
31 |
+
if($opts['add_to_multisite_form'] == 1) {
|
32 |
+
add_action('signup_extra_fields', array($this, 'output_checkbox'), 20);
|
33 |
+
add_action('signup_blogform', array($this, 'add_hidden_checkbox'), 20);
|
34 |
+
add_filter('add_signup_meta', array($this, 'add_checkbox_to_usermeta'));
|
35 |
+
add_action('wpmu_activate_blog', array($this, 'grab_email_from_ms_blog_signup'), 20, 5);
|
36 |
+
add_action('wpmu_activate_user', array($this, 'grab_email_from_ms_user_signup'), 20, 3);
|
37 |
+
}
|
38 |
+
|
39 |
+
/* bbPress actions */
|
40 |
+
if($opts['add_to_bbpress_forms']) {
|
41 |
+
add_action('bbp_theme_after_topic_form_subscriptions', array($this, 'output_checkbox'), 10);
|
42 |
+
add_action('bbp_theme_after_reply_form_subscription', array($this, 'output_checkbox'), 10);
|
43 |
+
add_action('bbp_theme_anonymous_form_extras_bottom', array($this, 'output_checkbox'), 10);
|
44 |
+
add_action('bbp_new_topic', array($this, 'subscribe_from_bbpress_new_topic'), 10, 4);
|
45 |
+
add_action('bbp_new_reply', array($this, 'subscribe_from_bbpress_new_reply'), 10, 5);
|
46 |
+
}
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Output the checkbox
|
53 |
+
* Function can only run once.
|
54 |
+
*/
|
55 |
+
public function output_checkbox()
|
56 |
+
{
|
57 |
+
$opts = $this->options;
|
58 |
+
|
59 |
+
// If using option to hide checkbox for subscribers and cookie is set, set instance variable showed_checkbox to true so checkbox won't show.
|
60 |
+
if($opts['cookie_hide'] == 1 && isset($_COOKIE['ns_subscriber'])) $this->showed_checkbox = TRUE;
|
61 |
+
|
62 |
+
// User could have rendered the checkbox by manually adding 'the hook 'ns_comment_checkbox()' to their comment form
|
63 |
+
// If so, abandon function.
|
64 |
+
if($this->showed_checkbox) return false;
|
65 |
+
|
66 |
+
?>
|
67 |
+
<!-- Checkbox by Newsletter Sign-Up Checkbox v<?php echo NSU_VERSION_NUMBER; ?> - http://wordpress.org/plugins/newsletter-sign-up/ -->
|
68 |
+
<p id="ns-checkbox">
|
69 |
+
<input value="1" id="nsu_checkbox" type="checkbox" name="newsletter-signup-do" <?php checked($opts['precheck'], 1); ?> />
|
70 |
+
<label for="nsu_checkbox">
|
71 |
+
<?php _e($opts['text']); ?>
|
72 |
+
</label>
|
73 |
+
</p>
|
74 |
+
<!-- / Newsletter Sign-Up -->
|
75 |
+
<?php
|
76 |
+
|
77 |
+
$this->showed_checkbox = true;
|
78 |
+
return true;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Adds a hidden checkbox to the second page of the MultiSite sign-up form (the blog sign-up form) containing the checkbox value of the previous screen
|
83 |
+
*/
|
84 |
+
function add_hidden_checkbox()
|
85 |
+
{
|
86 |
+
?>
|
87 |
+
<input type="hidden" name="newsletter-signup-do" value="<?php echo (isset($_POST['newsletter-signup-do'])) ? 1 : 0; ?>" />
|
88 |
+
<?php
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Save the value of the checkbox to MultiSite sign-ups table
|
93 |
+
*/
|
94 |
+
function add_checkbox_to_usermeta($meta)
|
95 |
+
{
|
96 |
+
$meta['newsletter-signup-do'] = (isset($_POST['newsletter-signup-do'])) ? 1 : 0;
|
97 |
+
return $meta;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Perform the sign-up for users that registered trough a MultiSite register form
|
102 |
+
* This function differs because of the need to grab the emailadress from the user using get_userdata
|
103 |
+
* @param int $user_id : the ID of the new user
|
104 |
+
* @param string $password : the password, we don't actually use this
|
105 |
+
* @param array $meta : the meta values that belong to this user, holds the value of our 'newsletter-sign-up' checkbox.
|
106 |
+
*/
|
107 |
+
public function grab_email_from_ms_user_signup($user_id, $password = NULL,$meta = NULL){
|
108 |
+
if(!isset($meta['newsletter-signup-do']) || $meta['newsletter-signup-do'] != 1) return;
|
109 |
+
$user_info = get_userdata($user_id);
|
110 |
+
|
111 |
+
$email = $user_info->user_email;
|
112 |
+
$name = $user_info->first_name;
|
113 |
+
|
114 |
+
NSU::instance()->send_post_data($email, $name);
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Perform the sign-up for users that registered trough a MultiSite register form
|
119 |
+
* This function differs because of the need to grab the emailadress from the user using get_userdata
|
120 |
+
* @param int $blog_id The id of the new blow
|
121 |
+
* @param int $user_id The ID of the new user
|
122 |
+
* @param $a No idea, seriously.
|
123 |
+
* @param $b No idea, seriously.
|
124 |
+
* @param array $meta The meta values that belong to this user, holds the value of our 'newsletter-sign-up' checkbox.
|
125 |
+
*/
|
126 |
+
public function grab_email_from_ms_blog_signup($blog_id, $user_id, $a, $b ,$meta){
|
127 |
+
|
128 |
+
if(!isset($meta['newsletter-signup-do']) || $meta['newsletter-signup-do'] != 1) return;
|
129 |
+
$user_info = get_userdata($user_id);
|
130 |
+
|
131 |
+
$email = $user_info->user_email;
|
132 |
+
$name = $user_info->first_name;
|
133 |
+
|
134 |
+
NSU::instance()->send_post_data($email, $name);
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Grab the emailadress (and name) from a regular WP or BuddyPress sign-up and then send this to mailinglist.
|
139 |
+
*/
|
140 |
+
function grab_email_from_wp_signup()
|
141 |
+
{
|
142 |
+
if($_POST['newsletter-signup-do'] != 1) return;
|
143 |
+
|
144 |
+
if(isset($_POST['user_email'])) {
|
145 |
+
|
146 |
+
// gather emailadress from user who WordPress registered
|
147 |
+
$email = $_POST['user_email'];
|
148 |
+
$name = $_POST['user_login'];
|
149 |
+
|
150 |
+
} elseif(isset($_POST['signup_email'])) {
|
151 |
+
|
152 |
+
// gather emailadress from user who BuddyPress registered
|
153 |
+
$email = $_POST['signup_email'];
|
154 |
+
$name = $_POST['signup_username'];
|
155 |
+
|
156 |
+
} else { return; }
|
157 |
+
|
158 |
+
NSU::instance()->send_post_data($email, $name);
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Grab the emailadress and name from comment and then send it to mailinglist.
|
163 |
+
* @param int $cid : the ID of the comment
|
164 |
+
* @param object $comment : the comment object, optionally
|
165 |
+
*/
|
166 |
+
public function grab_email_from_comment($cid, $comment_approved = '')
|
167 |
+
{
|
168 |
+
if(!isset($_POST['newsletter-signup-do']) || $_POST['newsletter-signup-do'] != 1) { return false; }
|
169 |
+
if($comment_approved === 'spam') { return false; }
|
170 |
+
|
171 |
+
// get comment data
|
172 |
+
$comment = get_comment($cid);
|
173 |
+
|
174 |
+
$email = $comment->comment_author_email;
|
175 |
+
$name = $comment->comment_author;
|
176 |
+
|
177 |
+
return NSU::instance()->send_post_data($email, $name);
|
178 |
+
}
|
179 |
+
|
180 |
+
public function subscribe_from_bbpress($anonymous_data, $user_id)
|
181 |
+
{
|
182 |
+
if(!isset($_POST['newsletter-signup-do']) || $_POST['newsletter-signup-do'] != 1) { return false; }
|
183 |
+
|
184 |
+
if($anonymous_data) {
|
185 |
+
|
186 |
+
$email = $anonymous_data['bbp_anonymous_email'];
|
187 |
+
$name = $anonymous_data['bbp_anonymous_name'];
|
188 |
+
|
189 |
+
} elseif($user_id) {
|
190 |
+
|
191 |
+
$user_info = get_userdata($user_id);
|
192 |
+
$email = $user_info->user_email;
|
193 |
+
$name = $user_info->first_name . ' ' . $user_info->last_name;
|
194 |
+
|
195 |
+
} else {
|
196 |
+
return false;
|
197 |
+
}
|
198 |
+
|
199 |
+
return NSU::instance()->send_post_data($email, $name);
|
200 |
+
}
|
201 |
+
|
202 |
+
public function subscribe_from_bbpress_new_topic($topic_id, $forum_id, $anonymous_data, $topic_author)
|
203 |
+
{
|
204 |
+
return $this->subscribe_from_bbpress($anonymous_data, $topic_author);
|
205 |
+
}
|
206 |
+
|
207 |
+
public function subscribe_from_bbpress_new_reply($reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author)
|
208 |
+
{
|
209 |
+
return $this->subscribe_from_bbpress($anonymous_data, $reply_author);
|
210 |
+
}
|
211 |
+
|
212 |
+
}
|
includes/NSU_Form.php
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class NSU_Form {
|
4 |
+
|
5 |
+
private $validation_errors = array();
|
6 |
+
private $number_of_forms = 0;
|
7 |
+
private $options = array();
|
8 |
+
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
// add hooks
|
12 |
+
$options = NSU::instance()->get_options();
|
13 |
+
$this->options = $options;
|
14 |
+
|
15 |
+
// register the shortcode which can be used to output sign-up form
|
16 |
+
add_shortcode('newsletter-sign-up-form', array($this,'form_shortcode'));
|
17 |
+
add_shortcode('nsu-form', array($this,'form_shortcode'));
|
18 |
+
|
19 |
+
if(isset($_POST['nsu_submit'])) {
|
20 |
+
add_action('init', array($this, 'submit'));
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Check if ANY Newsletter Sign-Up form has been submitted.
|
26 |
+
*/
|
27 |
+
public function submit()
|
28 |
+
{
|
29 |
+
|
30 |
+
$opts = $this->options['form'];
|
31 |
+
$errors = array();
|
32 |
+
|
33 |
+
$email = (isset($_POST['nsu_email'])) ? $_POST['nsu_email'] : '';
|
34 |
+
$name = (isset($_POST['nsu_name'])) ? $_POST['nsu_name'] : '';
|
35 |
+
|
36 |
+
// has the honeypot been filled?
|
37 |
+
if(!empty($_POST['nsu_robocop'])) { return false; }
|
38 |
+
|
39 |
+
if($this->options['mailinglist']['subscribe_with_name'] == 1 && $opts['name_required'] == 1 && empty($name)) {
|
40 |
+
$errors['name-field'] = __($opts['text_empty_name']);
|
41 |
+
}
|
42 |
+
|
43 |
+
if(empty($email)) {
|
44 |
+
$errors['email-field'] = __($opts['text_empty_email']);
|
45 |
+
} elseif(!is_email($email)) {
|
46 |
+
$errors['email-field'] = __($opts['text_invalid_email']);
|
47 |
+
}
|
48 |
+
|
49 |
+
$this->validation_errors = $errors;
|
50 |
+
|
51 |
+
if(count($this->validation_errors) == 0) {
|
52 |
+
NSU::instance()->send_post_data($email, $name, 'form');
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* The NSU form shortcode function. Calls the output_form method
|
61 |
+
*
|
62 |
+
* @param array $atts Not used
|
63 |
+
* @param string $content Not used
|
64 |
+
* @return string Form HTML-code
|
65 |
+
*/
|
66 |
+
public function form_shortcode($atts = null,$content = null)
|
67 |
+
{
|
68 |
+
return $this->output_form(false);
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Generate the HTML for a form
|
73 |
+
* @param boolean $echo Should HTML be echo'ed?
|
74 |
+
* @return string The generated HTML
|
75 |
+
*/
|
76 |
+
public function output_form($echo = true)
|
77 |
+
{
|
78 |
+
$errors = $this->validation_errors;
|
79 |
+
$opts = NSU::instance()->get_options();
|
80 |
+
|
81 |
+
$additional_fields = '';
|
82 |
+
$output = "\n<!-- Form by Newsletter Sign-Up v". NSU_VERSION_NUMBER ." - http://wordpress.org/plugins/newsletter-sign-up/ -->\n";
|
83 |
+
|
84 |
+
$formno = $this->number_of_forms++;
|
85 |
+
|
86 |
+
/* Set up form variables for API usage or normal form */
|
87 |
+
if($opts['mailinglist']['use_api'] == 1) {
|
88 |
+
|
89 |
+
/* Using API, send form request to ANY page */
|
90 |
+
$form_action = '';
|
91 |
+
$email_id = 'nsu_email';
|
92 |
+
$name_id = 'nsu_name';
|
93 |
+
|
94 |
+
} else {
|
95 |
+
|
96 |
+
/* Using normal form request, set-up using configuration settings */
|
97 |
+
$form_action = $opts['mailinglist']['form_action'];
|
98 |
+
$email_id = $opts['mailinglist']['email_id'];
|
99 |
+
|
100 |
+
if(!empty($opts['mailinglist']['name_id'])) {
|
101 |
+
$name_id = $opts['mailinglist']['name_id'];
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
/* Set up additional fields */
|
107 |
+
if(isset($opts['mailinglist']['extra_data']) && is_array($opts['mailinglist']['extra_data'])) {
|
108 |
+
|
109 |
+
foreach($opts['mailinglist']['extra_data'] as $ed) {
|
110 |
+
if($ed['value'] == '%%NAME%%') continue;
|
111 |
+
$ed['value'] = str_replace("%%IP%%", $_SERVER['REMOTE_ADDR'], $ed['value']);
|
112 |
+
$additional_fields .= "<input type=\"hidden\" name=\"{$ed['name']}\" value=\"{$ed['value']}\" />";
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
$email_label = __($opts['form']['email_label'], 'nsu');
|
117 |
+
$name_label = __($opts['form']['name_label'], 'nsu');
|
118 |
+
|
119 |
+
if($opts['form']['use_html5']) {
|
120 |
+
$email_type = 'email';
|
121 |
+
$email_atts = 'placeholder="'. __($opts['form']['email_default_value'], 'nsu') .'" required';
|
122 |
+
$name_atts = 'placeholder="'. __($opts['form']['name_default_value'], 'nsu') .'" ';
|
123 |
+
if($opts['form']['name_required']) { $name_atts .= 'required '; }
|
124 |
+
} else {
|
125 |
+
$email_type = 'text';
|
126 |
+
$email_value = __($opts['form']['email_default_value'], 'nsu');
|
127 |
+
$email_atts = 'value="'. $email_value .'"';
|
128 |
+
$name_value = __($opts['form']['name_default_value'], 'nsu');
|
129 |
+
$name_atts = 'value="'. $name_value .'"';
|
130 |
+
}
|
131 |
+
|
132 |
+
$submit_button = __($opts['form']['submit_button'], 'nsu');
|
133 |
+
|
134 |
+
$text_after_signup = __($opts['form']['text_after_signup'], 'nsu');
|
135 |
+
$text_after_signup = ($opts['form']['wpautop'] == 1) ? wpautop(wptexturize($text_after_signup)) : $text_after_signup;
|
136 |
+
|
137 |
+
|
138 |
+
|
139 |
+
if(!isset($_POST['nsu_submit']) || count($errors) > 0) { //form has not been submitted yet
|
140 |
+
|
141 |
+
$output .= "<form class=\"nsu-form\" id=\"nsu-form-$formno\" action=\"$form_action\" method=\"post\">";
|
142 |
+
if($opts['mailinglist']['subscribe_with_name'] == 1) {
|
143 |
+
$output .= "<p><label for=\"nsu-name-$formno\">$name_label</label><input class=\"nsu-field\" id=\"nsu-name-$formno\" type=\"text\" name=\"$name_id\" $name_atts ";
|
144 |
+
if(!$opts['form']['use_html5']) $output .= "onblur=\"if(!this.value) this.value = '$name_value';\" onfocus=\"if(this.value == '$name_value') this.value=''\" ";
|
145 |
+
$output .= "/>";
|
146 |
+
if(isset($errors['name-field'])) $output .= '<span class="nsu-error error notice">'.$errors['name-field'].'</span>';
|
147 |
+
$output .= "</p>";
|
148 |
+
}
|
149 |
+
|
150 |
+
$output .= "<p><label for=\"nsu-email-$formno\">$email_label</label><input class=\"nsu-field\" id=\"nsu-email-$formno\" type=\"$email_type\" name=\"$email_id\" $email_atts ";
|
151 |
+
if(!$opts['form']['use_html5']) $output .= "onblur=\"if(!this.value) this.value = '$email_value';\" onfocus=\"if(this.value == '$email_value') this.value = ''\" ";
|
152 |
+
$output .= "/>";
|
153 |
+
if(isset($errors['email-field'])) $output .= '<span class="nsu-error error notice">'.$errors['email-field'].'</span>';
|
154 |
+
$output .= "</p>";
|
155 |
+
$output .= $additional_fields;
|
156 |
+
$output .= '<textarea name="nsu_robocop" style="display: none;"></textarea>';
|
157 |
+
$output .= "<p><input type=\"submit\" id=\"nsu-submit-$formno\" class=\"nsu-submit\" name=\"nsu_submit\" value=\"$submit_button\" /></p>";
|
158 |
+
$output .= "</form>";
|
159 |
+
|
160 |
+
} else { // form has been submitted
|
161 |
+
|
162 |
+
$output .= "<p id=\"nsu-signed-up-$formno\" class=\"nsu-signed-up\">". ($text_after_signup) . "</p>";
|
163 |
+
|
164 |
+
}
|
165 |
+
|
166 |
+
$output .= "\n<!-- / Newsletter Sign-Up -->\n";
|
167 |
+
|
168 |
+
if($echo) { echo $output; }
|
169 |
+
|
170 |
+
return $output;
|
171 |
+
|
172 |
+
}
|
173 |
+
|
174 |
+
}
|
{frontend → includes}/NewsletterSignUpWidget.php
RENAMED
@@ -11,7 +11,7 @@ if(!class_exists('NewsletterSignUpWidget')) {
|
|
11 |
}
|
12 |
|
13 |
function widget($args, $instance) {
|
14 |
-
|
15 |
/* Get Newsletter Sign-up options */
|
16 |
$options = get_option('nsu_form');
|
17 |
|
@@ -31,7 +31,9 @@ if(!class_exists('NewsletterSignUpWidget')) {
|
|
31 |
$instance['filter'] ? _e(wpautop($text_before_form),'nsu-widget') : _e($text_before_form,'nsu-widget');
|
32 |
?></div><?php
|
33 |
}
|
34 |
-
|
|
|
|
|
35 |
if(!empty($text_after_form)) {
|
36 |
?><div class="nsu-text-after-form"><?php
|
37 |
$instance['filter'] ? _e(wpautop($text_after_form),'nsu-widget') : _e($text_after_form,'nsu-widget');
|
11 |
}
|
12 |
|
13 |
function widget($args, $instance) {
|
14 |
+
|
15 |
/* Get Newsletter Sign-up options */
|
16 |
$options = get_option('nsu_form');
|
17 |
|
31 |
$instance['filter'] ? _e(wpautop($text_before_form),'nsu-widget') : _e($text_before_form,'nsu-widget');
|
32 |
?></div><?php
|
33 |
}
|
34 |
+
|
35 |
+
NSU::form()->output_form(true);
|
36 |
+
|
37 |
if(!empty($text_after_form)) {
|
38 |
?><div class="nsu-text-after-form"><?php
|
39 |
$instance['filter'] ? _e(wpautop($text_after_form),'nsu-widget') : _e($text_after_form,'nsu-widget');
|
includes/functions.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Displays the comment checkbox, call this function if your theme does not use the 'comment_form' action in the comments.php template.
|
5 |
+
*/
|
6 |
+
if(!function_exists('nsu_checkbox')) {
|
7 |
+
function nsu_checkbox() {
|
8 |
+
NSU::checkbox()->output_checkbox();
|
9 |
+
}
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Outputs a sign-up form, for usage in your theme files.
|
14 |
+
*/
|
15 |
+
if(!function_exists('nsu_form')) {
|
16 |
+
function nsu_form() {
|
17 |
+
NSU::form()->output_form(true);
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
/* Backwards Compatibility */
|
22 |
+
if(!function_exists('nsu_signup_form')) {
|
23 |
+
function nsu_signup_form()
|
24 |
+
{
|
25 |
+
nsu_form();
|
26 |
+
}
|
27 |
+
}
|
includes/views/checkbox_settings.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap" id="nsu-admin">
|
2 |
+
|
3 |
+
<?php include_once 'parts/navigation.php'; ?>
|
4 |
+
|
5 |
+
<h2>Newsletter Sign-Up :: Checkbox Settings</h2>
|
6 |
+
<?php settings_errors(); ?>
|
7 |
+
|
8 |
+
<div id="nsu-main">
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
<form method="post" action="options.php" id="ns_settings_page">
|
13 |
+
<?php settings_fields('nsu_checkbox_group'); ?>
|
14 |
+
<table class="form-table">
|
15 |
+
<tr valign="top"><th scope="row">Text to show after the checkbox</th>
|
16 |
+
<td><input class="widefat" type="text" name="nsu_checkbox[text]" value="<?php echo esc_attr($opts['text']); ?>" /></td>
|
17 |
+
</tr>
|
18 |
+
<tr valign="top"><th scope="row">Redirect to this url after signing up <small>(leave empty for no redirect)</small></th>
|
19 |
+
<td><input class="widefat" type="text" name="nsu_checkbox[redirect_to]" value="<?php echo esc_attr($opts['redirect_to']); ?>" />
|
20 |
+
|
21 |
+
<small>In general, I don't recommend setting a redirect url for the sign-up checkbox. This will cause some serious confusion, since
|
22 |
+
users expect to be redirected to the post they commented on.</small>
|
23 |
+
|
24 |
+
</td>
|
25 |
+
</tr>
|
26 |
+
<tr valign="top"><th scope="row"><label for="ns_precheck_checkbox">Pre-check the checkbox?</label></th>
|
27 |
+
<td><input type="checkbox" id="ns_precheck_checkbox" name="nsu_checkbox[precheck]" value="1" <?php checked($opts['precheck'], 1); ?> /></td>
|
28 |
+
</tr>
|
29 |
+
<tr valign="top">
|
30 |
+
<th scope="row"><label for="do_css_reset">Do a CSS 'reset' on the checkbox.</label> <small>(check this if checkbox appears in a weird place)</small></th>
|
31 |
+
<td><input type="checkbox" id="do_css_reset" name="nsu_checkbox[css_reset]" value="1" <?php checked($opts['css_reset'], 1); ?> /> </td>
|
32 |
+
</tr>
|
33 |
+
<tr valign="top"><th scope="row">Where to show the sign-up checkbox?</th>
|
34 |
+
<td>
|
35 |
+
<?php foreach($this->get_checkbox_compatible_plugins() as $code => $name) { ?>
|
36 |
+
<input type="checkbox" id="add_to_<?php echo $code; ?>" name="nsu_checkbox[add_to_<?php echo $code; ?>]" value="1"<?php checked($opts['add_to_'.$code], '1'); ?> /> <label for="add_to_<?php echo $code; ?>"><?php echo $name; ?></label>
|
37 |
+
<?php } ?>
|
38 |
+
</td>
|
39 |
+
</tr>
|
40 |
+
<tr valign="top"><th scope="row"><label for="ns_cookie_hide">Hide the checkbox for users who used it to subscribe before?</label><small>(uses a cookie)</small></th>
|
41 |
+
<td><input type="checkbox" id="ns_cookie_hide" name="nsu_checkbox[cookie_hide]" value="1"<?php
|
42 |
+
if ($opts['cookie_hide'] == '1') {
|
43 |
+
echo ' checked="checked"';
|
44 |
+
}
|
45 |
+
?> /></td>
|
46 |
+
</tr>
|
47 |
+
|
48 |
+
</table>
|
49 |
+
|
50 |
+
<?php submit_button(); ?>
|
51 |
+
|
52 |
+
</form>
|
53 |
+
</div>
|
54 |
+
|
55 |
+
<?php require 'parts/sidebar.php'; ?>
|
56 |
+
|
57 |
+
</div>
|
includes/views/config_helper.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap" id="nsu-admin">
|
2 |
+
|
3 |
+
|
4 |
+
<?php include_once 'parts/navigation.php'; ?>
|
5 |
+
|
6 |
+
<h2>Newsletter Sign-Up :: Config Extractor</h2>
|
7 |
+
|
8 |
+
|
9 |
+
<div id="nsu-main">
|
10 |
+
<?php if(isset($error)) { ?>
|
11 |
+
<div id="message" class="notice error"><p>Oops, I couldn't make any sense of that. Are you sure you submitted a form snippet?</p></div>
|
12 |
+
<?php } ?>
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
<?php if(isset($result)) { ?>
|
19 |
+
<table class="form-table">
|
20 |
+
<tr valign="top">
|
21 |
+
<th scope="row" style="font-weight:bold;">Form action:</th>
|
22 |
+
<td><?php echo $form_action; ?></td>
|
23 |
+
</tr>
|
24 |
+
<tr valign="top">
|
25 |
+
<th scope="row" style="font-weight:bold;">Email identifier:</th>
|
26 |
+
<td><?php echo $email_identifier; ?></td>
|
27 |
+
</tr>
|
28 |
+
<tr valign="top">
|
29 |
+
<th scope="row" style="font-weight:bold;">Name identifier:</th>
|
30 |
+
<td><?php echo $name_identifier; ?></td>
|
31 |
+
</tr>
|
32 |
+
<?php if(isset($additional_data) && count($additional_data) > 0) { ?>
|
33 |
+
<tr valign="top">
|
34 |
+
<th scope="row" colspan="2" style="font-weight:bold;">Additional data ( name / value):</th>
|
35 |
+
</tr>
|
36 |
+
<?php foreach($additional_data as $data) { ?>
|
37 |
+
<tr valign="top">
|
38 |
+
<td><?php echo $data[0]; ?></th>
|
39 |
+
<td><?php echo $data[1]; ?></td>
|
40 |
+
</tr>
|
41 |
+
<?php } ?>
|
42 |
+
<?php } ?>
|
43 |
+
</table>
|
44 |
+
|
45 |
+
<p>The above settings are there to help you, though they may not be right. Check out <a href="http://dannyvankooten.com/571/configuring-newsletter-sign-up-the-definitive-guide/">this post on my blog</a> for more information on how to manually
|
46 |
+
configure Newsletter Sign-up.</p>
|
47 |
+
<p>The form code below is a stripped down version of your sign-up form which will make it easier for you to extract the right values. Please also use this form when asking for support.</p>
|
48 |
+
<textarea class="widefat" rows="10"><?php echo esc_textarea($clean_form); ?></textarea>
|
49 |
+
|
50 |
+
<?php } else { ?>
|
51 |
+
<p>This tool was designed to help you extract the right configuration settings to make Newsletter Sign-Up work properly.</p>
|
52 |
+
<p>Please copy and paste a sign-up form you would normally embed on a HTML page in the textarea below and hit the extract button. The NSU Config Tool will then try to extract the right configuration settings for you. </p>
|
53 |
+
<form method="post" action="" id="ns_settings_page">
|
54 |
+
<textarea name="form" class="widefat" rows="10"></textarea>
|
55 |
+
|
56 |
+
<p class="submit">
|
57 |
+
<input type="submit" class="button-primary" style="margin:5px;" value="<?php _e('Extract') ?>" />
|
58 |
+
</p>
|
59 |
+
|
60 |
+
|
61 |
+
</form>
|
62 |
+
<?Php } ?>
|
63 |
+
|
64 |
+
</div>
|
65 |
+
|
66 |
+
<?php require 'parts/sidebar.php'; ?>
|
67 |
+
|
68 |
+
</div>
|
includes/views/dashboard.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap" id="nsu-admin">
|
2 |
+
|
3 |
+
<?php include_once 'parts/navigation.php'; ?>
|
4 |
+
|
5 |
+
<h2>Newsletter Sign-Up :: Mailinglist Settings</h2>
|
6 |
+
<?php settings_errors(); ?>
|
7 |
+
|
8 |
+
<div id="nsu-main">
|
9 |
+
|
10 |
+
<form method="post" action="options.php">
|
11 |
+
<?php settings_fields('nsu_mailinglist_group'); ?>
|
12 |
+
|
13 |
+
<table class="form-table">
|
14 |
+
<tr valign="top">
|
15 |
+
<td colspan="2"><p>These settings are the most important since without these Newsletter Sign-Up can't do it's job. Having trouble finding
|
16 |
+
the right configuration settings? Have a look at <a href="http://dannyvankooten.com/wordpress-plugins/newsletter-sign-up/">this post on my blog</a> or try the <a href="admin.php?page=newsletter-sign-up/config-helper">configuration extractor</a>.</p></td>
|
17 |
+
</tr>
|
18 |
+
<tr valign="top">
|
19 |
+
<th scope="row">Select your mailinglist provider: </th>
|
20 |
+
<td>
|
21 |
+
<select name="nsu_mailinglist[provider]" id="ns_mp_provider" onchange="document.location.href = 'admin.php?page=<?php echo $this->hook; ?>&mp=' + this.value">
|
22 |
+
<option value="other"<?php if ($viewed_mp == NULL || $viewed_mp == 'other')
|
23 |
+
echo ' SELECTED'; ?>>-- other / advanced</option>
|
24 |
+
<option value="mailchimp"<?php if ($viewed_mp == 'mailchimp')
|
25 |
+
echo ' SELECTED'; ?> >MailChimp</option>
|
26 |
+
<option value="ymlp"<?php if ($viewed_mp == 'ymlp')
|
27 |
+
echo ' SELECTED'; ?> >YMLP</option>
|
28 |
+
<option value="icontact"<?php if ($viewed_mp == 'icontact')
|
29 |
+
echo ' SELECTED'; ?> >iContact</option>
|
30 |
+
<option value="aweber"<?php if ($viewed_mp == 'aweber')
|
31 |
+
echo ' SELECTED'; ?> >Aweber</option>
|
32 |
+
<option value="phplist"<?php if ($viewed_mp == 'phplist')
|
33 |
+
echo ' SELECTED'; ?> >PHPList</option>
|
34 |
+
</select>
|
35 |
+
</td>
|
36 |
+
</tr>
|
37 |
+
|
38 |
+
<?php if(isset($viewed_mp) && file_exists(dirname(__FILE__) . '/parts/rows-' . $viewed_mp . '.php')) require 'parts/rows-' . $viewed_mp . '.php'; ?>
|
39 |
+
|
40 |
+
<tbody class="form_rows"<?php if (isset($viewed_mp) && in_array($viewed_mp, array('mailchimp', 'ymlp')) && isset($opts['use_api']) && $opts['use_api'] == 1)
|
41 |
+
echo ' style="display:none" '; ?>>
|
42 |
+
<tr valign="top"><th scope="row">Newsletter form action</th>
|
43 |
+
<td><input size="50%" type="text" id="ns_form_action" name="nsu_mailinglist[form_action]" value="<?php echo $opts['form_action']; ?>" /></td>
|
44 |
+
</tr>
|
45 |
+
<tr valign="top"><th scope="row">E-mail identifier <span class="ns_small">name attribute of input field that holds the emailadress</span></th>
|
46 |
+
<td><input size="50%" type="text" name="nsu_mailinglist[email_id]" value="<?php echo $opts['email_id']; ?>"/></td>
|
47 |
+
</tr>
|
48 |
+
</tbody>
|
49 |
+
<tbody>
|
50 |
+
<tr valign="top"><th scope="row"><label for="subscribe_with_name">Subscribe with name?</label></th>
|
51 |
+
<td><input type="checkbox" id="subscribe_with_name" name="nsu_mailinglist[subscribe_with_name]" value="1"<?php if($opts['subscribe_with_name'] == '1') echo ' checked'; ?> /></td>
|
52 |
+
</tr>
|
53 |
+
<tr class="name_dependent" valign="top"<?php if($opts['subscribe_with_name'] != 1) echo 'style="display:none;"'; ?>><th scope="row">Name identifier <span class="ns_small">name attribute of input field that holds the name</span></th>
|
54 |
+
<td><input size="25%" id="ns_name_id" type="text" name="nsu_mailinglist[name_id]" value="<?php echo $opts['name_id']; ?>" /></td>
|
55 |
+
</tr>
|
56 |
+
</tbody>
|
57 |
+
</table>
|
58 |
+
<p style="margin:10px;">
|
59 |
+
For some newsletter services you need to specify some additional static data, like a list ID or your account name. These fields are usually found as hidden fields in your sign-up form's HTML code.
|
60 |
+
You can specify these additional fields here using name / value pairs so they will be sent along with every sign-up request.
|
61 |
+
</p>
|
62 |
+
<p>If you use <em>%%NAME%%</em> or <em>%%IP%%</em> in the value fields it will be replaced by respectively the actual name or IP address of the subscriber.</p>
|
63 |
+
<table class="form-table">
|
64 |
+
<tr valign="top">
|
65 |
+
<th scope="column" style="font-weight:bold;">Name</th>
|
66 |
+
<th scope="column" style="font-weight:bold;">Value</th>
|
67 |
+
</tr>
|
68 |
+
<?php
|
69 |
+
$last_key = 0;
|
70 |
+
|
71 |
+
if (isset($opts['extra_data']) && is_array($opts['extra_data'])) :
|
72 |
+
foreach ($opts['extra_data'] as $key => $value) :
|
73 |
+
?>
|
74 |
+
<tr valign="top">
|
75 |
+
<td><input size="50%" type="text" name="nsu_mailinglist[extra_data][<?php echo $key; ?>][name]" value="<?php echo $value['name']; ?>" /></td>
|
76 |
+
<td><input size="50%" type="text" name="nsu_mailinglist[extra_data][<?php echo $key; ?>][value]" value="<?php echo $value['value']; ?>" /></td>
|
77 |
+
</tr>
|
78 |
+
<?php
|
79 |
+
$last_key = $key + 1;
|
80 |
+
endforeach;
|
81 |
+
endif;
|
82 |
+
?>
|
83 |
+
<tr valign="top">
|
84 |
+
<td><input size="50%" type="text" name="nsu_mailinglist[extra_data][<?php echo $last_key; ?>][name]" value="" /></td>
|
85 |
+
<td><input size="50%" type="text" name="nsu_mailinglist[extra_data][<?php echo $last_key; ?>][value]" value="" /></td>
|
86 |
+
</tr>
|
87 |
+
</table>
|
88 |
+
<p class="submit">
|
89 |
+
<input type="submit" class="button-primary" style="margin:5px;" value="<?php _e('Save Changes') ?>" />
|
90 |
+
</p>
|
91 |
+
</form>
|
92 |
+
<p class="nsu-tip">
|
93 |
+
Having trouble finding the right configuration settings? Try the <a href="admin.php?page=newsletter-sign-up/config-helper">configuration extractor</a>, it's there to help you!
|
94 |
+
</p>
|
95 |
+
|
96 |
+
</div>
|
97 |
+
|
98 |
+
|
99 |
+
<?php require 'parts/sidebar.php'; ?>
|
100 |
+
|
101 |
+
</div>
|
102 |
+
<br style="clear:both;" />
|
includes/views/form_settings.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap" id="nsu-admin">
|
2 |
+
|
3 |
+
<?php include_once 'parts/navigation.php'; ?>
|
4 |
+
|
5 |
+
<div id="nsu-main">
|
6 |
+
|
7 |
+
<h2>Newsletter Sign-Up :: Form Settings</h2>
|
8 |
+
<?php settings_errors(); ?>
|
9 |
+
|
10 |
+
<p>Customize your newsletter sign-up form by customizing the labels, input fields, buttons and validation texts using the settings below. </p>
|
11 |
+
|
12 |
+
<form method="post" action="options.php">
|
13 |
+
<?php settings_fields('nsu_form_group'); ?>
|
14 |
+
<table class="form-table">
|
15 |
+
<tr valign="top">
|
16 |
+
<th scope="row">E-mail label</th>
|
17 |
+
<td colspan="2"><input class="widefat" type="text" name="nsu_form[email_label]" value="<?php echo esc_attr($opts['email_label']); ?>" /></td>
|
18 |
+
</tr>
|
19 |
+
<tr valign="top">
|
20 |
+
<th scope="row">E-mail default value</th>
|
21 |
+
<td colspan="2"><input class="widefat" type="text" name="nsu_form[email_default_value]" value="<?php echo esc_attr($opts['email_default_value']); ?>" /></td>
|
22 |
+
</tr>
|
23 |
+
<tr valign="top" class="name_dependent" <?php if($opts['mailinglist']['subscribe_with_name'] != 1) echo 'style="display:none;"'; ?>>
|
24 |
+
<th scope="row">Name label</th>
|
25 |
+
<td colspan="2">
|
26 |
+
<input class="widefat" type="text" name="nsu_form[name_label]" value="<?php echo esc_attr($opts['name_label']); ?>" /><br />
|
27 |
+
<p><input type="checkbox" id="name_required" name="nsu_form[name_required]" value="1" <?php checked($opts['name_required'], 1); ?> />
|
28 |
+
<label for="name_required">Name is a required field?</label></p>
|
29 |
+
</td>
|
30 |
+
</tr>
|
31 |
+
<tr valign="top" class="name_dependent" <?php if($opts['mailinglist']['subscribe_with_name'] != 1) echo 'style="display:none;"'; ?>>
|
32 |
+
<th scope="row">Name default value</th>
|
33 |
+
<td colspan="2"><input class="widefat" type="text" name="nsu_form[name_default_value]" value="<?php echo esc_attr($opts['name_default_value']); ?>" /></td>
|
34 |
+
|
35 |
+
</tr>
|
36 |
+
<tr valign="top">
|
37 |
+
<th scope="row">Submit button text</th>
|
38 |
+
<td colspan="2"><input class="widefat" type="text" name="nsu_form[submit_button]" value="<?php echo esc_attr($opts['submit_button']); ?>" /></td>
|
39 |
+
</tr>
|
40 |
+
<tr valign="top">
|
41 |
+
<th scope="row">Text to replace the form with after a successful sign-up</th>
|
42 |
+
<td colspan="2">
|
43 |
+
<textarea class="widefat" rows="5" cols="50" name="nsu_form[text_after_signup]"><?php echo esc_textarea($opts['text_after_signup']); ?></textarea>
|
44 |
+
<p><input id="nsu_form_wpautop" name="nsu_form[wpautop]" type="checkbox" value="1" <?php if($opts['wpautop'] == 1) echo 'checked'; ?> /> <label for="nsu_form_wpautop"><?php _e('Automatically add paragraphs'); ?></label></p>
|
45 |
+
</td>
|
46 |
+
</tr>
|
47 |
+
|
48 |
+
<?php if($opts['mailinglist']['use_api'] == 1) { ?>
|
49 |
+
<tr valign="top">
|
50 |
+
<th scope="row">Redirect to this url after signing up <small>(leave empty for no redirect)</small></th>
|
51 |
+
<td colspan="2"><input class="widefat" type="text" name="nsu_form[redirect_to]" value="<?php echo $opts['redirect_to']; ?>" /></td>
|
52 |
+
</tr>
|
53 |
+
<?php } ?>
|
54 |
+
|
55 |
+
<tr valign="top">
|
56 |
+
<th scope="row"><label for="ns_load_form_styles">Load some default CSS</label></th>
|
57 |
+
<td><input type="checkbox" id="ns_load_form_styles" name="nsu_form[load_form_css]" value="1" <?php if($opts['load_form_css'] == 1) echo 'checked'; ?> /></td>
|
58 |
+
<td><small>Check this to load some default form CSS styles.</small></td>
|
59 |
+
</tr>
|
60 |
+
<tr valign="top">
|
61 |
+
<th scope="row"><label for="nsu_use_html_5">Use HTML 5?</label></th>
|
62 |
+
<td><input type="checkbox" id="nsu_use_html_5" name="nsu_form[use_html5]" value="1" <?php checked($opts['use_html5'], 1); ?> /></td>
|
63 |
+
<td><small>Use HTML5 fields and attributes? (recommended)</small></td>
|
64 |
+
</tr>
|
65 |
+
</table>
|
66 |
+
|
67 |
+
<?php submit_button(); ?>
|
68 |
+
|
69 |
+
|
70 |
+
<h3>Form text messages</h3>
|
71 |
+
<table class="form-table">
|
72 |
+
<?php if($opts['mailinglist']['subscribe_with_name']) { ?>
|
73 |
+
<tr valign="top">
|
74 |
+
<th scope="row">Empty name field message</th>
|
75 |
+
<td colspan="2"><input class="widefat" type="text" name="nsu_form[text_empty_name]" value="<?php echo esc_attr($opts['text_empty_name']); ?>" /></td>
|
76 |
+
</tr>
|
77 |
+
<?php } ?>
|
78 |
+
<tr valign="top">
|
79 |
+
<th scope="row">Empty email address field message</th>
|
80 |
+
<td colspan="2"><input class="widefat" type="text" name="nsu_form[text_empty_email]" value="<?php echo esc_attr($opts['text_empty_email']); ?>" /></td>
|
81 |
+
</tr>
|
82 |
+
<tr valign="top">
|
83 |
+
<th scope="row">Invalid email address message</th>
|
84 |
+
<td colspan="2"><input class="widefat" type="text" name="nsu_form[text_invalid_email]" value="<?php echo esc_attr($opts['text_invalid_email']); ?>" /></td>
|
85 |
+
</tr>
|
86 |
+
</table>
|
87 |
+
|
88 |
+
</form>
|
89 |
+
</div>
|
90 |
+
|
91 |
+
<?php require 'parts/sidebar.php'; ?>
|
92 |
+
|
93 |
+
</div>
|
includes/views/parts/navigation.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<h2 class="nav-tab-wrapper">
|
3 |
+
<a href="?page=newsletter-sign-up" class="nav-tab <?php echo ($tab == 'mailinglist-settings') ? 'nav-tab-active' : ''; ?>">Mailinglist Settings</a>
|
4 |
+
<a href="?page=newsletter-sign-up-checkbox-settings" class="nav-tab <?php echo ($tab == 'checkbox-settings') ? 'nav-tab-active' : ''; ?>">Checkbox Settings</a>
|
5 |
+
<a href="?page=newsletter-sign-up-form-settings" class="nav-tab <?php echo ($tab == 'form-settings') ? 'nav-tab-active' : ''; ?>">Form Settings</a>
|
6 |
+
<a href="?page=newsletter-sign-up-config-helper" class="nav-tab <?php echo ($tab == 'config-helper') ? 'nav-tab-active' : ''; ?>">Config Helper</a>
|
7 |
+
</h2>
|
{backend/views → includes/views/parts}/rows-aweber.php
RENAMED
File without changes
|
{backend/views → includes/views/parts}/rows-mailchimp.php
RENAMED
@@ -1,3 +1,7 @@
|
|
|
|
|
|
|
|
|
|
1 |
<tr valign="top">
|
2 |
<th scope="row"><label for="use_api">Use MailChimp API? <span class="ns_small">(recommended)</span></label></th>
|
3 |
<td><input type="checkbox" id="use_api" name="nsu_mailinglist[use_api]" value="1"<?php if (isset($opts['use_api']) && $opts['use_api'] == '1') { echo ' checked="checked"'; } ?> /></td>
|
@@ -30,15 +34,4 @@
|
|
30 |
<td><input size="50%" type="text" name="nsu_mailinglist[mc_groupings_groups]" value="<?php if (isset($opts['mc_groupings_groups'])) echo $opts['mc_groupings_groups']; ?>"; /></td>
|
31 |
</tr>
|
32 |
</tbody>
|
33 |
-
</tbody>
|
34 |
-
|
35 |
-
<tr valign="top" style="display:block;">
|
36 |
-
<td colspan="2">
|
37 |
-
<div id="setting-error-settings_updated" class="updated settings-error">
|
38 |
-
<p>
|
39 |
-
<strong>Notice:</strong> You are using MailChimp, great! Consider switching to my newer plugin called <a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">MailChimp for WordPress</a> which, surprisingly, focuses solely on MailChimp users.
|
40 |
-
It can be downloaded from the WordPress repository <a href="http://wordpress.org/plugins/mailchimp-for-wp/">here</a>.
|
41 |
-
</p>
|
42 |
-
</div>
|
43 |
-
</td>
|
44 |
-
</tr>
|
1 |
+
<tr valign="top">
|
2 |
+
<td colspan="3" style="font-weight:bold; font-style:italic;">I highly recommend switching to my newer plugin: <a href="http://wordpress.org/plugins/mailchimp-for-wp/">MailChimp for WordPress</a>. There is an awesome Lite version available for free from the WP repository, and an even more awesome <a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">Pro version from my website</a>.</td>
|
3 |
+
</tr>
|
4 |
+
|
5 |
<tr valign="top">
|
6 |
<th scope="row"><label for="use_api">Use MailChimp API? <span class="ns_small">(recommended)</span></label></th>
|
7 |
<td><input type="checkbox" id="use_api" name="nsu_mailinglist[use_api]" value="1"<?php if (isset($opts['use_api']) && $opts['use_api'] == '1') { echo ' checked="checked"'; } ?> /></td>
|
34 |
<td><input size="50%" type="text" name="nsu_mailinglist[mc_groupings_groups]" value="<?php if (isset($opts['mc_groupings_groups'])) echo $opts['mc_groupings_groups']; ?>"; /></td>
|
35 |
</tr>
|
36 |
</tbody>
|
37 |
+
</tbody>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{backend/views → includes/views/parts}/rows-phplist.php
RENAMED
File without changes
|
{backend/views → includes/views/parts}/rows-ymlp.php
RENAMED
File without changes
|
includes/views/parts/sidebar.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div id="nsu-sidebar">
|
2 |
+
|
3 |
+
<div id="nsu-donate-box">
|
4 |
+
<h3>Donate $10, $20 or $50</h3>
|
5 |
+
<p>If you like Newsletter Sign-Up and the free time I put into it, please consider donating a token of your appreciation.</p>
|
6 |
+
|
7 |
+
<form class="donate" action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
8 |
+
<input type="hidden" name="cmd" value="_donations">
|
9 |
+
<input type="hidden" name="business" value="AP87UHXWPNBBU">
|
10 |
+
<input type="hidden" name="lc" value="US">
|
11 |
+
<input type="hidden" name="item_name" value="Danny van Kooten">
|
12 |
+
<input type="hidden" name="item_number" value="Newsletter Sign-Up">
|
13 |
+
<input type="hidden" name="currency_code" value="USD">
|
14 |
+
<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHosted">
|
15 |
+
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
16 |
+
<img alt="" border="0" src="https://www.paypalobjects.com/nl_NL/i/scr/pixel.gif" width="1" height="1">
|
17 |
+
</form>
|
18 |
+
|
19 |
+
<p>Alternatively, you can: </p>
|
20 |
+
<ul>
|
21 |
+
<li><a href="http://wordpress.org/support/view/plugin-reviews/newsletter-sign-up?rate=5#postform" target="_blank">Give a 5★ rating on WordPress.org</a></li>
|
22 |
+
<li><a href="http://dannyvankooten.com/wordpress-plugins/newsletter-sign-up/" target="_blank">Blog about it and link to the plugin page</a></li>
|
23 |
+
<li><a href="http://twitter.com/?status=I%20manage%20my%20%23WordPress%20sign-up%20forms%20using%20%40DannyvanKooten%20%27s%20Newsletter%20Sign-Up%20plugin%20and%20I%20love%20it%20-%20check%20it%20out!%20http%3A%2F%2Fwordpress.org%2Fplugins%2Fnewsletter-sign-up%2F" target="_blank">Tweet about Newsletter Sign-Up</a></li>
|
24 |
+
</ul>
|
25 |
+
</div>
|
26 |
+
|
27 |
+
<div>
|
28 |
+
<h3>Other WordPress plugins by Danny</h3>
|
29 |
+
<ul class="">
|
30 |
+
<li class="mc4wp"><a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">MailChimp for WordPress</a></li>
|
31 |
+
<li><a href="http://dannyvankooten.com/wordpress-plugins/wysiwyg-widgets/">WYSIWYG Widgets</a></li>
|
32 |
+
<li class="rfb"><a href="http://dannyvankooten.com/wordpress-plugins/recent-facebook-posts/">Recent Facebook Posts</a></li>
|
33 |
+
|
34 |
+
<li class="dvk-email"><a href="http://dannyvankooten.com/newsletter/">Subscribe to Danny's newsletter</a> by e-mail</li>
|
35 |
+
<li class="dvk-twitter">You should follow me on twitter <a href="http://twitter.com/dannyvankooten">here</a></li>
|
36 |
+
</ul>
|
37 |
+
</div>
|
38 |
+
|
39 |
+
<div>
|
40 |
+
<h3>Need support?</h3>
|
41 |
+
<p>Please use the <a href="http://wordpress.org/support/plugin/newsletter-sign-up">WordPress.org support forums for Newsletter Sign-Up</a>.</p>
|
42 |
+
</div>
|
43 |
+
|
44 |
+
</div>
|
newsletter-sign-up.php
CHANGED
@@ -3,9 +3,9 @@
|
|
3 |
Plugin Name: Newsletter Sign-Up
|
4 |
Plugin URI: http://DannyvanKooten.com/wordpress-plugins/newsletter-sign-up/
|
5 |
Description: Adds various ways for your visitors to sign-up to your mailinglist (checkbox, widget, form)
|
6 |
-
Version:
|
7 |
Author: Danny van Kooten
|
8 |
-
Author URI: http://
|
9 |
License: GPL2
|
10 |
*/
|
11 |
|
@@ -25,29 +25,8 @@ License: GPL2
|
|
25 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
*/
|
27 |
|
28 |
-
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
if(is_admin()) {
|
34 |
-
require('backend/NewsletterSignUpAdmin.php');
|
35 |
-
$NewsletterSignUpAdmin = new NewsletterSignUpAdmin($NewsletterSignUp);
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Displays the comment checkbox, call this function if your theme does not use the 'comment_form' action in the comments.php template.
|
40 |
-
*/
|
41 |
-
function nsu_checkbox() {
|
42 |
-
$NewsletterSignUp = NewsletterSignUp::getInstance();
|
43 |
-
$NewsletterSignUp->output_checkbox();
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Outputs a sign-up form, for usage in your theme files.
|
48 |
-
*/
|
49 |
-
function nsu_signup_form()
|
50 |
-
{
|
51 |
-
$NewsletterSignUp = NewsletterSignUp::getInstance();
|
52 |
-
$NewsletterSignUp->output_form(true);
|
53 |
-
}
|
3 |
Plugin Name: Newsletter Sign-Up
|
4 |
Plugin URI: http://DannyvanKooten.com/wordpress-plugins/newsletter-sign-up/
|
5 |
Description: Adds various ways for your visitors to sign-up to your mailinglist (checkbox, widget, form)
|
6 |
+
Version: 2.0.1
|
7 |
Author: Danny van Kooten
|
8 |
+
Author URI: http://dannyvankooten.com
|
9 |
License: GPL2
|
10 |
*/
|
11 |
|
25 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
*/
|
27 |
|
28 |
+
define('NSU_VERSION_NUMBER', "2.0.1");
|
29 |
+
define("NSU_PLUGIN_DIR", plugin_dir_path(__FILE__));
|
30 |
|
31 |
+
require_once NSU_PLUGIN_DIR . 'includes/NSU.php';
|
32 |
+
new NSU();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://dannyvankooten.com/donate/
|
|
4 |
Tags: newsletter,sign-up,mailchimp,aweber,newsletter signup,checkbox,ymlp,email,phplist,icontact,mailinglist,checkbox,form widget,widget,newsletter widget,subscribe widget,form shortcode,mailchimp api
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.6
|
7 |
-
Stable tag:
|
8 |
|
9 |
The ultimate Newsletter plugin! Works with third-party newsletter services like MailChimp. Sign-up checkboxes, widget forms, shortcodes, it's all in there.
|
10 |
|
@@ -21,12 +21,13 @@ You can practically use the plugin for EVERY newsletter provider that's around i
|
|
21 |
|
22 |
**Features:**
|
23 |
|
24 |
-
* Add a "sign-up to our newsletter" checkbox to your comment form or
|
25 |
* Easy customizable Newsletter Sign-Up Widget
|
26 |
-
* Embed a sign-up form in your posts with a simple shortcode `[
|
27 |
-
* Embed a sign-up form in your template files by calling `
|
28 |
-
* Use the MailChimp or YMLP API or any other third
|
29 |
-
* Works with most major mailinglist services
|
|
|
30 |
* Compatible with [WYSIWYG Widgets](http://dannyvankooten.com/wordpress-plugins/wysiwyg-widgets/) to allow easy widget text editing.
|
31 |
|
32 |
**More info:**
|
@@ -35,13 +36,14 @@ You can practically use the plugin for EVERY newsletter provider that's around i
|
|
35 |
* Check out more [WordPress plugins](http://dannyvankooten.com/wordpress-plugins/) by Danny van Kooten
|
36 |
* You should follow [Danny on Twitter](http://twitter.com/DannyvanKooten) for lightning fast support and updates.
|
37 |
|
38 |
-
=
|
39 |
One of the things NSU does is adding a "Sign me up to your newsletter checkbox" to your comment and registration forms. Most visitors who care to comment are willing to subscribe to your newsletter too.
|
40 |
Signing up to your newsletter is as easy as ticking a checkbox!
|
41 |
|
|
|
|
|
42 |
= Sign-up forms =
|
43 |
-
Another strength of NSU is the ability to create sign-up forms and easily embed those in multiple places. Newsletter Sign-Up comes with a sign-up form widget, a shortcode to use in your posts and/or pages and a function call
|
44 |
-
to use in your template files. You can even choose to redirect the visitor to a certain page after signing-up, offering them exclusive content or a "thank you for signing up" message.
|
45 |
|
46 |
= Using MailChimp or YMLP? Use their API's! =
|
47 |
If you're using MailChimp or YMLP then you're in luck. Configuring is as easy as providing your API credentials so that Newsletter Sign-Up can work with the API of your newsletter provider.
|
@@ -97,7 +99,7 @@ Yes.
|
|
97 |
|
98 |
= Can I show a sign-up form by calling a function in my template files? =
|
99 |
|
100 |
-
Yes, use the following code snippet in your theme files to embed a sign-up form: `if(function_exists('
|
101 |
|
102 |
For more questions and answers go have a look at my website regarding [Newsletter Sign-Up](http://dannyvankooten.com/wordpress-plugins/newsletter-sign-up/)
|
103 |
|
@@ -109,6 +111,28 @@ For more questions and answers go have a look at my website regarding [Newslette
|
|
109 |
|
110 |
== Changelog ==
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
= 1.8.1 =
|
113 |
* Improved: automatic guessing of first and last names.
|
114 |
* Removed backwards compatibility for v1.6 and below
|
4 |
Tags: newsletter,sign-up,mailchimp,aweber,newsletter signup,checkbox,ymlp,email,phplist,icontact,mailinglist,checkbox,form widget,widget,newsletter widget,subscribe widget,form shortcode,mailchimp api
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.6
|
7 |
+
Stable tag: 2.0.1
|
8 |
|
9 |
The ultimate Newsletter plugin! Works with third-party newsletter services like MailChimp. Sign-up checkboxes, widget forms, shortcodes, it's all in there.
|
10 |
|
21 |
|
22 |
**Features:**
|
23 |
|
24 |
+
* Add a "sign-up to our newsletter" checkbox to your comment form or registration form
|
25 |
* Easy customizable Newsletter Sign-Up Widget
|
26 |
+
* Embed a sign-up form in your posts with a simple shortcode `[nsu-form]`.
|
27 |
+
* Embed a sign-up form in your template files by calling `nsu_form();`
|
28 |
+
* Use the MailChimp or YMLP API or any other third-party newsletter service.
|
29 |
+
* Works with most major mailinglist services like Aweber, Constant Contact, iContact, etc.
|
30 |
+
* Compatible with BuddyPress, MultiSite and bbPress.
|
31 |
* Compatible with [WYSIWYG Widgets](http://dannyvankooten.com/wordpress-plugins/wysiwyg-widgets/) to allow easy widget text editing.
|
32 |
|
33 |
**More info:**
|
36 |
* Check out more [WordPress plugins](http://dannyvankooten.com/wordpress-plugins/) by Danny van Kooten
|
37 |
* You should follow [Danny on Twitter](http://twitter.com/DannyvanKooten) for lightning fast support and updates.
|
38 |
|
39 |
+
= Sign-up checkboxes =
|
40 |
One of the things NSU does is adding a "Sign me up to your newsletter checkbox" to your comment and registration forms. Most visitors who care to comment are willing to subscribe to your newsletter too.
|
41 |
Signing up to your newsletter is as easy as ticking a checkbox!
|
42 |
|
43 |
+
You can also add the sign-up checkbox to your BuddyPress registration form, your MultiSite sign-up forms or your bbPress new topic and new reply forms.
|
44 |
+
|
45 |
= Sign-up forms =
|
46 |
+
Another strength of NSU is the ability to create sign-up forms and easily embed those in multiple places. Newsletter Sign-Up comes with a sign-up form widget, a shortcode to use in your posts and/or pages and a function call to use in your template files. You can even choose to redirect the visitor to a certain page after signing-up, offering them exclusive content or a "thank you for signing up" message.
|
|
|
47 |
|
48 |
= Using MailChimp or YMLP? Use their API's! =
|
49 |
If you're using MailChimp or YMLP then you're in luck. Configuring is as easy as providing your API credentials so that Newsletter Sign-Up can work with the API of your newsletter provider.
|
99 |
|
100 |
= Can I show a sign-up form by calling a function in my template files? =
|
101 |
|
102 |
+
Yes, use the following code snippet in your theme files to embed a sign-up form: `if(function_exists('nsu_form')) nsu_form();`
|
103 |
|
104 |
For more questions and answers go have a look at my website regarding [Newsletter Sign-Up](http://dannyvankooten.com/wordpress-plugins/newsletter-sign-up/)
|
105 |
|
111 |
|
112 |
== Changelog ==
|
113 |
|
114 |
+
= 2.0.1 =
|
115 |
+
* Fixed: not being able to uncheck "Use HTML 5" on form settings page
|
116 |
+
* Added: compatibility with bbPress, you can now add a sign-up checkbox to the post new topic and post new reply forms.
|
117 |
+
* Fixed: not being able to uncheck "add to comment form" in checkbox settings
|
118 |
+
* Fixed: compatibility with other plugins who use a 'functions.php' file (like GDE).
|
119 |
+
|
120 |
+
= 2.0 =
|
121 |
+
* Fixed: spam comments not being filtered
|
122 |
+
* Added: HTML 5 form fields (option)
|
123 |
+
* Added: Validation texts (option)
|
124 |
+
* Fixed: last update broke template functions
|
125 |
+
* Added: navigation tabs in back-end
|
126 |
+
|
127 |
+
= 1.9 =
|
128 |
+
* Improved: Code refactoring, less memory usage
|
129 |
+
* Improved: Admin panel clean-up
|
130 |
+
* Fixed: YMLP API
|
131 |
+
* Added: Translation filters to form shortcode output
|
132 |
+
* Added: Translation filters to checkbox label
|
133 |
+
* Added: SPAM Honeypot to sign-up form to prevent bot subscribers
|
134 |
+
* Removed: paragraph tags around hidden fields
|
135 |
+
|
136 |
= 1.8.1 =
|
137 |
* Improved: automatic guessing of first and last names.
|
138 |
* Removed backwards compatibility for v1.6 and below
|
screenshot-1.jpg
DELETED
Binary file
|
screenshot-2.jpg
DELETED
Binary file
|
screenshot-3.jpg
DELETED
Binary file
|