Newsletter Sign-Up - Version 1.6.1

Version Description

  • Fixed notice on frontend when e-mail field not filled in
  • Fixed provided values for First and Lastname field for MailChimp when using both.
Download this release

Release Info

Developer DvanKooten
Plugin Icon wp plugin Newsletter Sign-Up
Version 1.6.1
Comparing to
See all releases

Version 1.6.1

backend/NewsletterSignUpAdmin.php ADDED
@@ -0,0 +1,591 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!class_exists('NewsletterSignUpAdmin')) {
3
+
4
+ class NewsletterSignUpAdmin {
5
+
6
+ private $hook = 'newsletter-sign-up';
7
+ private $longname = 'Newsletter Sign-Up';
8
+ private $shortname = '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 $icon_url = '';
13
+ private $bp_active = FALSE;
14
+ private $actions = array();
15
+
16
+ function __construct() {
17
+
18
+ // If coming from older version of NSU, transfer settings to work with new settings architecture.
19
+ $this->transfer_settings();
20
+
21
+ $this->icon_url = plugins_url('/backend/img/icon.png', dirname(__FILE__));
22
+
23
+ add_filter("plugin_action_links_{$this->filename}", array(&$this, 'add_settings_link'));
24
+ add_action('admin_menu', array(&$this, 'add_option_page'));
25
+ add_action('admin_init', array(&$this, 'settings_init'));
26
+
27
+ // add dashboard widget hook
28
+ add_action('wp_dashboard_setup', array(&$this, 'widget_setup'));
29
+
30
+ // register function to remove options upon deactivation
31
+ register_deactivation_hook($this->filename, array(&$this, 'remove_options'));
32
+
33
+
34
+ /* Only do stuff on admin page of this plugin */
35
+ if (isset($_GET['page']) && stripos($_GET['page'], $this->hook) !== FALSE) {
36
+ add_action("admin_print_styles", array(&$this, 'add_admin_styles'));
37
+ add_action("admin_print_scripts", array(&$this, 'add_admin_scripts'));
38
+ }
39
+
40
+
41
+ add_action('bp_include', array(&$this, 'set_bp_active'));
42
+ }
43
+
44
+ /**
45
+ * If buddypress is loaded, set buddypress_active to TRUE
46
+ */
47
+ function set_bp_active() {
48
+ $this->bp_active = TRUE;
49
+ }
50
+
51
+ /**
52
+ * Enqueue the necessary stylesheets
53
+ */
54
+ function add_admin_styles() {
55
+ wp_enqueue_style($this->hook . '_css', plugins_url('/backend/css/backend.css', dirname(__FILE__)));
56
+ }
57
+
58
+ /**
59
+ * Enqueue the necessary admin scripts
60
+ */
61
+ function add_admin_scripts() {
62
+ wp_enqueue_script(array('jquery', 'dashboard', 'postbox'));
63
+ wp_enqueue_script('ns_admin_js', plugins_url('/backend/js/backend.js', dirname(__FILE__)));
64
+ }
65
+
66
+ /**
67
+ * The default settings page
68
+ */
69
+ function options_page_default() {
70
+ $opts = get_option('nsu_mailinglist');
71
+
72
+ $viewed_mp = NULL;
73
+ if (!empty($_GET['mp']))
74
+ $viewed_mp = $_GET['mp'];
75
+ elseif (empty($_GET['mp']) && isset($opts['provider']))
76
+ $viewed_mp = $opts['provider'];
77
+ if (!in_array($viewed_mp, array('mailchimp', 'icontact', 'aweber', 'phplist', 'ymlp', 'other')))
78
+ $viewed_mp = NULL;
79
+
80
+ // Fill in some predefined values if options not set or set for other newsletter service
81
+ if (!isset($opts['provider']) || $opts['provider'] != $viewed_mp) {
82
+ switch ($viewed_mp) {
83
+
84
+ case 'mailchimp':
85
+ if (empty($opts['email_id']))
86
+ $opts['email_id'] = 'EMAIL';
87
+ if (empty($opts['name_id']))
88
+ $opts['name_id'] = 'NAME';
89
+ break;
90
+
91
+ case 'ymlp':
92
+ if (empty($opts['email_id']))
93
+ $opts['email_id'] = 'YMP0';
94
+ break;
95
+
96
+ case 'aweber':
97
+ if (empty($opts['form_action']))
98
+ $opts['form_action'] = 'http://www.aweber.com/scripts/addlead.pl';
99
+ if (empty($opts['email_id']))
100
+ $opts['email_id'] = 'email';
101
+ if (empty($opts['name_id']))
102
+ $opts['name_id'] = 'name';
103
+ break;
104
+
105
+ case 'icontact':
106
+ if (empty($opts['email_id']))
107
+ $opts['email_id'] = 'fields_email';
108
+ break;
109
+ }
110
+ }
111
+
112
+ require 'views/dashboard.php';
113
+ }
114
+
115
+ /**
116
+ * The admin page for managing checkbox settings
117
+ */
118
+ function options_page_checkbox_settings() {
119
+ $opts = get_option('nsu_checkbox');
120
+ require 'views/checkbox_settings.php';
121
+ }
122
+
123
+ /**
124
+ * The admin page for managing form settings
125
+ */
126
+ function options_page_form_settings() {
127
+ $opts = get_option('nsu_form');
128
+ $opts['mailinglist'] = get_option('nsu_mailinglist');
129
+ require 'views/form_settings.php';
130
+ }
131
+
132
+ /**
133
+ * The page for the configuration extractor
134
+ */
135
+ function options_page_config_helper() {
136
+
137
+ if (isset($_POST['form'])) {
138
+ $error = true;
139
+
140
+ $form = $_POST['form'];
141
+
142
+ // strip unneccessary tags
143
+ $form = strip_tags($form, '<form><input><button>');
144
+
145
+
146
+ preg_match_all("'<(.*?)>'si", $form, $matches);
147
+
148
+ if (is_array($matches) && isset($matches[0])) {
149
+ $matches = $matches[0];
150
+ $html = stripslashes(join('', $matches));
151
+
152
+ $clean_form = htmlspecialchars(str_replace(array('><', '<input'), array(">\n<", "\t<input"), $html), ENT_NOQUOTES);
153
+
154
+ $doc = new DOMDocument();
155
+ $doc->strictErrorChecking = FALSE;
156
+ $doc->loadHTML($html);
157
+ $xml = simplexml_import_dom($doc);
158
+
159
+ if ($xml) {
160
+ $result = true;
161
+ $form = $xml->body->form;
162
+
163
+ if ($form) {
164
+ unset($error);
165
+ $form_action = (isset($form['action'])) ? $form['action'] : 'Can\'t help you on this one..';
166
+
167
+ if ($form->input) {
168
+
169
+ $additional_data = array();
170
+
171
+ /* Loop trough input fields */
172
+ foreach ($form->input as $input) {
173
+
174
+ // Check if this is a hidden field
175
+ if ($input['type'] == 'hidden') {
176
+ $additional_data[] = array($input['name'], $input['value']);
177
+ // Check if this is the input field that is supposed to hold the EMAIL data
178
+ } elseif (stripos($input['id'], 'email') !== FALSE || stripos($input['name'], 'email') !== FALSE) {
179
+ $email_identifier = $input['name'];
180
+
181
+ // Check if this is the input field that is supposed to hold the NAME data
182
+ } elseif (stripos($input['id'], 'name') !== FALSE || stripos($input['name'], 'name') !== FALSE) {
183
+ $name_identifier = $input['name'];
184
+ }
185
+ }
186
+ }
187
+ }
188
+
189
+
190
+
191
+ // Correct value's
192
+ if (!isset($email_identifier))
193
+ $email_identifier = 'Can\'t help you on this one..';
194
+ if (!isset($name_identifier))
195
+ $name_identifier = 'Can\'t help you on this one. Not using name data?';
196
+ }
197
+ }
198
+ }
199
+
200
+ require 'views/config_helper.php';
201
+ }
202
+
203
+ /**
204
+ * Show the rows that are unique for some mailinglist providers (i.e. MC API or YMLP API)
205
+ * @param string $mailinglist The mailinglist provider that is being viewed
206
+ */
207
+ function mailinglist_specific_rows($mailinglist) {
208
+ $opts = get_option('nsu_mailinglist');
209
+
210
+ switch ($mailinglist) {
211
+
212
+ case 'mailchimp':
213
+ ?>
214
+ <tr valign="top">
215
+ <th scope="row"><label for="use_api">Use MailChimp API? <span class="ns_small">(recommended)</span></label></th>
216
+ <td><input type="checkbox" id="use_api" name="nsu_mailinglist[use_api]" value="1"<?php
217
+ if (isset($opts['use_api']) && $opts['use_api'] == '1') {
218
+ echo ' checked="checked"';
219
+ }
220
+ ?> /></td>
221
+ </tr>
222
+ <tbody class="api_rows" <?php if (!isset($opts['use_api']) || $opts['use_api'] != 1)
223
+ echo ' style="display:none" '; ?>>
224
+ <tr valign="top"><th scope="row">MailChimp API Key <a target="_blank" href="http://admin.mailchimp.com/account/api">(?)</a></th>
225
+ <td><input size="50%" type="text" id="mc_api_key" name="nsu_mailinglist[mc_api_key]" value="<?php if (isset($opts['mc_api_key']))
226
+ echo $opts['mc_api_key']; ?>" /></td>
227
+ </tr>
228
+ <tr valign="top"><th scope="row">MailChimp List ID <a href="http://www.mailchimp.com/kb/article/how-can-i-find-my-list-id" target="_blank">(?)</a></th>
229
+ <td><input size="50%" type="text" name="nsu_mailinglist[mc_list_id]" value="<?php if (isset($opts['mc_list_id']))
230
+ echo $opts['mc_list_id']; ?>" /></td>
231
+ </tr>
232
+ </tbody>
233
+ <?php
234
+ break;
235
+
236
+ case 'ymlp':
237
+ ?>
238
+ <tr valign="top"><th scope="row"><label for="use_api">Use the YMLP API? <span class="ns_small">(recommended)</span></label></th>
239
+ <td><input type="checkbox" id="use_api" name="nsu_mailinglist[use_api]" value="1"<?php
240
+ if (isset($opts['use_api']) && $opts['use_api'] == '1') {
241
+ echo ' checked="checked"';
242
+ }
243
+ ?> /></td>
244
+ </tr>
245
+
246
+ <tbody class="api_rows"<?php if (!isset($opts['use_api']) || $opts['use_api'] != 1)
247
+ echo ' style="display:none" '; ?>>
248
+ <tr valign="top"><th scope="row">YMLP API Key <a target="_blank" href="http://www.ymlp.com/app/api.php">(?)</a></th>
249
+ <td><input size="50%" type="text" id="ymlp_api_key" name="nsu_mailinglist[ymlp_api_key]" value="<?php if (isset($opts['ymlp_api_key']))
250
+ echo $opts['ymlp_api_key']; ?>" /></td>
251
+ </tr>
252
+ <tr valign="top"><th scope="row">YMLP Username</th>
253
+ <td><input size="50%" type="text" id="ymlp_username" name="nsu_mailinglist[ymlp_username]" value="<?php if (isset($opts['ymlp_username']))
254
+ echo $opts['ymlp_username']; ?>" /></td>
255
+ </tr>
256
+ <tr valign="top"><th scope="row">YMLP GroupID<span class="ns_small">(starts at 1, check URL when 'viewing all contacts' in certain group)</span></th>
257
+ <td><input size="50%" type="text" id="ymlp_groupid" name="nsu_mailinglist[ymlp_groupid]" value="<?php if (isset($opts['ymlp_groupid']))
258
+ echo $opts['ymlp_groupid']; ?>" /></td>
259
+ </tr>
260
+ </tbody>
261
+ <?php
262
+ break;
263
+
264
+ case 'phplist':
265
+ ?>
266
+ <tr valign="top">
267
+ <th scope="row">PHPList list ID</th>
268
+ <td><input size="2" type="text" name="nsu_mailinglist[phplist_list_id]" value="<?php
269
+ if (isset($opts['phplist_list_id'])) {
270
+ echo $opts['phplist_list_id'];
271
+ } else {
272
+ echo 1;
273
+ };
274
+ ?>" /></td>
275
+ </tr>
276
+ <?php
277
+ break;
278
+
279
+ case 'aweber':
280
+ ?>
281
+ <tr valign="top">
282
+ <th scope="row">Aweber list name</th>
283
+ <td><input size="25%" type="text" name="nsu_mailinglist[aweber_list_name]" value="<?php if (isset($opts['aweber_list_name']))
284
+ echo $opts['aweber_list_name']; ?>" /></td>
285
+ </tr>
286
+ <?php
287
+ break;
288
+ }
289
+ }
290
+
291
+ /**
292
+ * Renders a donate box
293
+ */
294
+ function donate_box() {
295
+ $content = '<p>This plugin cost me countless hours of work. If you use it, please donate a token of your appreciation!</p>
296
+ <center>
297
+ <form id="dvk_donate" action="https://www.paypal.com/cgi-bin/webscr" method="post">
298
+ <input type="hidden" name="cmd" value="_s-xclick">
299
+ <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----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-----END PKCS7-----
300
+ ">
301
+ <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!">
302
+ <img alt="" border="0" src="https://www.paypalobjects.com/nl_NL/i/scr/pixel.gif" width="1" height="1">
303
+ </form>
304
+
305
+ </center>';
306
+ $this->postbox($this->hook . '-donatebox', 'Donate $10, $20 or $50!', $content);
307
+ }
308
+
309
+ /**
310
+ * Renders a box with the latests posts from DannyvanKooten.com
311
+ */
312
+ function latest_posts() {
313
+ require_once(ABSPATH . WPINC . '/rss.php');
314
+ if ($rss = fetch_rss('http://feeds.feedburner.com/dannyvankooten')) {
315
+ $content = '<ul>';
316
+ $rss->items = array_slice($rss->items, 0, 5);
317
+
318
+ foreach ((array) $rss->items as $item) {
319
+ $content .= '<li class="dvk-rss-item">';
320
+ $content .= '<a target="_blank" href="' . clean_url($item['link'], $protocolls = null, 'display') . '">' . $item['title'] . '</a> ';
321
+ $content .= '</li>';
322
+ }
323
+ $content .= '<li class="dvk-rss"><a href="http://dannyvankooten.com/feed/">Subscribe to my RSS feed</a></li>';
324
+ $content .= '<li class="dvk-email"><a href="http://dannyvankooten.com/newsletter/">Subscribe by email</a></li>';
325
+ $content .= '</ul><br style="clear:both;" />';
326
+ } else {
327
+ $content = '<p>No updates..</p>';
328
+ }
329
+ $this->postbox($this->hook . '-latestpostbox', 'Latest blog posts..', $content);
330
+ }
331
+
332
+ /**
333
+ * Renders a box with options on how to show your appreciations
334
+ */
335
+ function likebox() {
336
+ $content = '<p>Consider the following options, please:</p>
337
+ <ul>
338
+ <li><a href="http://DannyvanKooten.com/donate/" target="_blank">Buy me a beer</a></li>
339
+ <li><a href="http://wordpress.org/extend/plugins/' . $this->hook . '/" target="_blank">Give it a good rating on WordPress.org.</a></li>
340
+ <li>Tell others about this plugin.</li>
341
+ </ul>';
342
+ $this->postbox($this->hook . '-likebox', 'Like this plugin?', $content);
343
+ }
344
+
345
+ /**
346
+ * Renders a box with a link to the support forums for NSU
347
+ */
348
+ function support_box() {
349
+ $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
350
+ your question or tip in the <a target="_blank" href="http://wordpress.org/tags/' . $this->hook . '">Support forums</a> on WordPress.org</p>';
351
+ $this->postbox($this->hook . '-support-box', "Looking for support?", $content);
352
+ }
353
+
354
+ /**
355
+ * Output's the necessary HTML formatting for a postbox
356
+ *
357
+ * @param string $id
358
+ * @param string $title
359
+ * @param string $content
360
+ */
361
+ function postbox($id, $title, $content) {
362
+ ?>
363
+ <div id="<?php echo $id; ?>" class="postbox dvk-box">
364
+ <div class="handlediv" title="<?php _e('Click to toggle'); ?>"><br></div>
365
+ <h3 class="hndle"><span><?php echo $title; ?></span></h3>
366
+ <div class="inside">
367
+ <?php echo $content; ?>
368
+ </div>
369
+ </div>
370
+ <?php
371
+ }
372
+
373
+ /**
374
+ * Renders the DvK.com dashboard widget on the admin homepage.
375
+ */
376
+ function dashboard_widget() {
377
+ $options = get_option('dvkdbwidget');
378
+ if (isset($_POST['dvk_removedbwidget'])) {
379
+ $options['dontshow'] = true;
380
+ update_option('dvkdbwidget', $options);
381
+ }
382
+
383
+ if (isset($options['dontshow']) && $options['dontshow']) {
384
+ echo "If you reload, this widget will be gone and never appear again, unless you decide to delete the database option 'dvkdbwidget'.";
385
+ return;
386
+ }
387
+
388
+ require_once(ABSPATH . WPINC . '/rss.php');
389
+ if ($rss = fetch_rss('http://feeds.feedburner.com/dannyvankooten')) {
390
+ echo '<div class="rss-widget">';
391
+ echo '<a href="http://dannyvankooten.com/" title="Go to DannyvanKooten.com"><img src="http://static.dannyvankooten.com/images/dvk-64x64.png" class="alignright" alt="DannyvanKooten.com"/></a>';
392
+ echo '<ul>';
393
+ $rss->items = array_slice($rss->items, 0, 3);
394
+ foreach ((array) $rss->items as $item) {
395
+ echo '<li>';
396
+ echo '<a target="_blank" class="rsswidget" href="' . clean_url($item['link'], $protocolls = null, 'display') . '">' . $item['title'] . '</a> ';
397
+ echo '<span class="rss-date">' . date('F j, Y', strtotime($item['pubdate'])) . '</span>';
398
+ echo '<div class="rssSummary">' . $this->text_limit($item['summary'], 250) . '</div>';
399
+ echo '</li>';
400
+ }
401
+ echo '</ul>';
402
+ echo '<div style="border-top: 1px solid #ddd; padding-top: 10px; text-align:center;">';
403
+ echo '<a target="_blank" style="margin-right:10px;" href="http://feeds.feedburner.com/dannyvankooten"><img src="' . get_bloginfo('wpurl') . '/wp-includes/images/rss.png" alt=""/> Subscribe by RSS</a>';
404
+ echo '<a target="_blank" href="http://dannyvankooten.com/newsletter/"><img src="http://static.dannyvankooten.com/images/email-icon.png" alt=""/> Subscribe by email</a>';
405
+ echo '<form class="alignright" method="post"><input type="hidden" name="dvk_removedbwidget" value="true"/><input title="Remove this widget" type="submit" value=" X "/></form>';
406
+ echo '</div>';
407
+ echo '</div>';
408
+ }
409
+ }
410
+
411
+ /**
412
+ * Function that is hooked, adds the DvK.com dashboard widget.
413
+ */
414
+ function widget_setup() {
415
+ $options = get_option('dvkdbwidget');
416
+ if (!$options['dontshow'])
417
+ wp_add_dashboard_widget('dvk_db_widget', 'Latest posts on DannyvanKooten.com', array(&$this, 'dashboard_widget'));
418
+ }
419
+
420
+ function text_limit($text, $limit, $finish = '...') {
421
+ if (strlen($text) > $limit) {
422
+ $text = substr($text, 0, $limit);
423
+ $text = substr($text, 0, - ( strlen(strrchr($text, ' ')) ));
424
+ $text .= $finish;
425
+ }
426
+ return $text;
427
+ }
428
+
429
+ /**
430
+ * Adds the different menu pages
431
+ */
432
+ function add_option_page() {
433
+ add_menu_page($this->longname, "Newsl. Sign-up", $this->accesslvl, $this->hook, array(&$this, 'options_page_default'), $this->icon_url);
434
+ add_submenu_page($this->hook, "Newsletter Sign-Up :: Mailinglist Settings", "List Settings", $this->accesslvl, $this->hook, array($this, 'options_page_default'));
435
+ add_submenu_page($this->hook, "Newsletter Sign-Up :: Checkbox Settings", "Checkbox Settings", $this->accesslvl, $this->hook . '/checkbox-settings', array($this, 'options_page_checkbox_settings'));
436
+ add_submenu_page($this->hook, "Newsletter Sign-Up :: Form Settings", "Form Settings", $this->accesslvl, $this->hook . '/form-settings', array($this, 'options_page_form_settings'));
437
+ add_submenu_page($this->hook, "Newsletter Sign-Up :: Configuration Extractor", "Config Extractor", $this->accesslvl, $this->hook . '/config-helper', array($this, 'options_page_config_helper'));
438
+ }
439
+
440
+ /**
441
+ * Adds the settings link on the plugin's overview page
442
+ * @param array $links Array containing all the settings links for the various plugins.
443
+ * @return array The new array containing all the settings links
444
+ */
445
+ function add_settings_link($links) {
446
+ $settings_link = '<a href="admin.php?page=' . $this->hook . '">Settings</a>';
447
+ array_unshift($links, $settings_link);
448
+ return $links;
449
+ }
450
+
451
+ /**
452
+ * Check how long the plugin has been used
453
+ * If used for over 30 days, show a pop-up asking for a tweet or donation.
454
+ */
455
+ function check_usage_time() {
456
+ $opts = get_option('nsu');
457
+ if (isset($_GET['dontshowpopup']) && $_GET['dontshowpopup'] == 1) {
458
+ $opts['dontshowpopup'] = 1;
459
+ update_option('nsu', $opts);
460
+ }
461
+ if (!isset($opts['date_installed'])) {
462
+ // set installed_time to now, so we can show pop-up in 30 days
463
+ $opts['date_installed'] = strtotime('now');
464
+ update_option('nsu', $opts);
465
+ } elseif ((!isset($opts['dontshowpopup']) || $opts['dontshowpopup'] != 1) && $opts['date_installed'] < strtotime('-30 days')) {
466
+ // plugin has been installed for over 30 days
467
+ $this->actions['show_donate_box'] = true;
468
+ wp_enqueue_style('dvk_donate', plugins_url('/backend/css/donate.css', dirname(__FILE__)));
469
+ wp_enqueue_script('dvk_donate', plugins_url('/backend/js/donate.js', dirname(__FILE__)));
470
+ }
471
+ }
472
+
473
+ /**
474
+ * Registers the settings using WP Settings API.
475
+ */
476
+ function settings_init() {
477
+ register_setting('nsu_group', 'nsu', array(&$this, 'validate_options'));
478
+ register_setting('nsu_form_group', 'nsu_form', array(&$this, 'validate_form_options'));
479
+ register_setting('nsu_mailinglist_group', 'nsu_mailinglist', array(&$this, 'validate_mailinglist_options'));
480
+ register_setting('nsu_checkbox_group', 'nsu_checkbox', array(&$this, 'validate_checkbox_options'));
481
+ }
482
+
483
+ /**
484
+ * Transfer settings from old optionname for backwards compatibility
485
+ */
486
+ private function transfer_settings() {
487
+ if (($old_options = get_option('ns_options')) != false && get_option('nsu') == false) {
488
+
489
+ $nsu = array(
490
+ 'date_installed' => (isset($old_options['date_installed'])) ? $old_options['date_installed'] : strtotime('now'),
491
+ 'dontshowpopup' => (isset($old_options['dontshowpopup'])) ? $old_options['dontshowpopup'] : 0,
492
+ 'load_widget_styles' => (isset($old_options['load_widget_styles'])) ? $old_options['load_widget_styles'] : 0
493
+ );
494
+
495
+ // new form option holder
496
+ $nsu_form = $old_options['form'];
497
+
498
+ // new checkbox option holder
499
+ $nsu_checkbox = array(
500
+ 'text' => (isset($old_options['checkbox_text'])) ? $old_options['checkbox_text'] : 'Sign me up for the newsletter.',
501
+ 'precheck' => (isset($old_options['precheck_checkbox'])) ? $old_options['precheck_checkbox'] : 0,
502
+ 'add_to_comment_form' => (isset($old_options['add_to_comment_form'])) ? $old_options['add_to_comment_form'] : 0,
503
+ 'add_to_registration_form' => (isset($old_options['add_to_reg_form'])) ? $old_options['add_to_reg_form'] : 0,
504
+ 'add_to_buddypress_form' => (isset($old_options['add_to_bp_form'])) ? $old_options['add_to_bp_form'] : 0,
505
+ 'add_to_multisite_form' => (isset($old_options['add_to_ms_form'])) ? $old_options['add_to_ms_form'] : 0,
506
+ 'css_reset' => (isset($old_options['do_css_reset'])) ? $old_options['do_css_reset'] : 0,
507
+ 'cookie_hide' => (isset($old_options['cookie_hide'])) ? $old_options['cookie_hide'] : 0,
508
+ );
509
+
510
+ $nsu_mailinglist = array(
511
+ 'provider' => (isset($old_options['email_service'])) ? $old_options['email_service'] : '',
512
+ 'use_api' => (isset($old_options['use_api'])) ? $old_options['use_api'] : 0,
513
+ 'mc_api_key' => (isset($old_options['api_key'])) ? $old_options['api_key'] : '',
514
+ 'mc_list_id' => (isset($old_options['list_id'])) ? $old_options['list_id'] : '',
515
+ 'ymlp_api_key' => (isset($old_options['ymlp_api_key'])) ? $old_options['ymlp_api_key'] : '',
516
+ 'ymlp_username' => (isset($old_options['ymlp_username'])) ? $old_options['ymlp_username'] : '',
517
+ 'ymlp_groupid' => (isset($old_options['ymlp_groupid'])) ? $old_options['ymlp_groupid'] : '',
518
+ 'aweber_list_name' => (isset($old_options['aweber_list_name'])) ? $old_options['aweber_list_name'] : '',
519
+ 'phplist_list_id' => (isset($old_options['phplist_list_id'])) ? $old_options['phplist_list_id'] : '',
520
+ 'form_action' => (isset($old_options['form_action'])) ? $old_options['form_action'] : '',
521
+ 'email_id' => (isset($old_options['email_id'])) ? $old_options['email_id'] : '',
522
+ 'subscribe_with_name' => (isset($old_options['subscribe_with_name'])) ? $old_options['subscribe_with_name'] : 0,
523
+ 'name_id' => (isset($old_options['name_id'])) ? $old_options['name_id'] : '',
524
+ 'extra_data' => $old_options['extra_data']
525
+ );
526
+
527
+ delete_option('nsu');
528
+ delete_option('nsu_form');
529
+ delete_option('nsu_checkbox');
530
+ delete_option('nsu_mailinglist');
531
+
532
+ add_option('nsu', $nsu);
533
+ add_option('nsu_form', $nsu_form);
534
+ add_option('nsu_checkbox', $nsu_checkbox);
535
+ add_option('nsu_mailinglist', $nsu_mailinglist);
536
+
537
+ //delete_option('ns_options');
538
+ }
539
+ }
540
+
541
+ /**
542
+ * Removes the options from database, this function is hooked to deactivation of NSU.
543
+ */
544
+ function remove_options() {
545
+ // old option name
546
+ delete_option('ns_options');
547
+
548
+ // new option names
549
+ delete_option('nsu');
550
+ delete_option('nsu_form');
551
+ delete_option('nsu_checkbox');
552
+ delete_option('nsu_mailinglist');
553
+ }
554
+
555
+ /**
556
+ * Validate the submitted options
557
+ * @param array $options The submitted options
558
+ */
559
+ public function validate_options($options) {
560
+ return $options;
561
+ }
562
+
563
+ public function validate_form_options($options) {
564
+ $options['text_after_signup'] = strip_tags($options['text_after_signup'], '<a><b><strong><i><img><em><br><p><ul><li><ol>');
565
+
566
+ // redirect to url should start with http
567
+ if(isset($options['redirect_to']) && substr($options['redirect_to'],0,4) != 'http') {
568
+ $options['redirect_to'] = '';
569
+ }
570
+
571
+ return $options;
572
+ }
573
+
574
+ public function validate_mailinglist_options($options) {
575
+ if (is_array($options['extra_data'])) {
576
+ foreach ($options['extra_data'] as $key => $value) {
577
+ if (empty($value['name']))
578
+ unset($options['extra_data'][$key]);
579
+ }
580
+ }
581
+
582
+ return $options;
583
+ }
584
+
585
+ public function validate_checkbox_options($options) {
586
+ return $options;
587
+ }
588
+
589
+ }
590
+
591
+ }
backend/css/backend.css ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .dvk-box div.inside{
2
+ padding:10px;
3
+ }
4
+
5
+ .dvk-box p,.dvk-box ul{
6
+ margin:0;
7
+ margin-bottom:5px;
8
+ }
9
+ .dvk-box ul{
10
+ list-style:square;
11
+ margin-left:20px;
12
+ }
13
+ .dvk-box li{
14
+ margin:0;
15
+ margin-bottom:4px;
16
+ }
17
+ li.dvk-rss-item{
18
+ margin-left:-16px;
19
+ padding-left:25px;
20
+ background:url(http://static.dannyvankooten.com/images/dvk-16x16.png) no-repeat left center;
21
+ list-style:none;
22
+ }
23
+ li.dvk-rss{
24
+ margin-top:10px;
25
+ margin-left:-16px;
26
+ float:left;
27
+ padding-left:25px;
28
+ background:url(http://static.dannyvankooten.com/images/rss-icon.png) no-repeat left center;
29
+ list-style:none;
30
+ }
31
+ li.dvk-email{
32
+ margin:10px 0 0 10px;
33
+ float:left;
34
+ padding-left:25px;
35
+ background:url(http://static.dannyvankooten.com/images/email-icon.png) no-repeat left center;
36
+ list-style:none;
37
+ }
38
+ .postbox .inside{
39
+ padding:0 10px;
40
+ }
41
+
42
+ .dvk-box b,.dvk-box strong{
43
+ font-weight:bold;
44
+ }
45
+
46
+ #ns_settings_page input[type=text]{
47
+ width:75%;
48
+ }
49
+
50
+ span.ns_small{
51
+ font-style:italic;
52
+ font-size:10px;
53
+ display:block;
54
+ margin:2px 0;
55
+ }
56
+
57
+ #dvk-avatar{
58
+ vertical-align:top;
59
+ margin-right:10px;
60
+ display:inline-block;
61
+ height:32px;
62
+ width:32px;
63
+ background:url(http://static.dannyvankooten.com/images/dvk-avatar.png) no-repeat;
64
+ }
65
+
66
+ .nsu-tip{ font-size: 11px; font-style:italic; }
67
+ html,body{ height:auto !important; position:relative; }
68
+ .nsu-textarea{ width:100% !important; min-height:150px; }
69
+
70
+ #newsletter-sign-up-donatebox{ border:2px solid #0099ff; }
71
+ #newsletter-sign-up-donatebox h3{ font-weight:bold; color:#0099ff; }
backend/css/donate.css ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #dvk-donate-box{
2
+ display:none;
3
+ background:url(../img/overlay.png);
4
+ position:absolute;
5
+ left:0; top:0;
6
+ width:100%;
7
+ height:100%;
8
+ z-index:999;
9
+ }
10
+
11
+ #dvk-donate-box-content{
12
+ position:fixed;
13
+ left:50%;
14
+ top:50%;
15
+ width:300px;
16
+ height:220px;
17
+ padding:10px 25px;
18
+ margin-left:-175px;
19
+ margin-top:-135px;
20
+ background:white;
21
+ border:1px solid #DFDFDF;
22
+ -moz-border-radius: 6px;
23
+ -khtml-border-radius: 6px;
24
+ -webkit-border-radius: 6px;
25
+ border-radius: 6px;
26
+ }
27
+
28
+ #dvk-donate-box img.dvk-close{
29
+ position:absolute;
30
+ right:10px; top:10px;
31
+ cursor:pointer;
32
+ }
33
+ #dvk-donate-box a.dvk-dontshow{
34
+ font-size:10px;
35
+ position:absolute;
36
+ right:10px;
37
+ bottom:10px;
38
+ }
backend/css/newsletter-sign-up-backend.css ADDED
File without changes
backend/img/close.png ADDED
Binary file
backend/img/icon.png ADDED
Binary file
backend/img/overlay.png ADDED
Binary file
backend/js/backend.js ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function(){
2
+
3
+ var api_rows = jQuery("tbody.api_rows");
4
+ var form_rows = jQuery("tbody.form_rows");
5
+ var name_dependent_rows = jQuery('tr.name_dependent');
6
+
7
+ jQuery("#use_api").change(function(){
8
+ if(jQuery(this).attr('checked')) {
9
+ api_rows.show();
10
+ form_rows.hide();
11
+ } else {
12
+ api_rows.hide();
13
+ form_rows.show();
14
+ }
15
+ });
16
+
17
+ jQuery("#subscribe_with_name").change(function(){
18
+ if(jQuery(this).attr('checked')) {
19
+ name_dependent_rows.show();
20
+ } else {
21
+ name_dependent_rows.hide();
22
+ }
23
+ });
24
+
25
+ });
backend/js/donate.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function() {
2
+ jQuery('#dvk-donate-box').fadeIn();
3
+
4
+ jQuery('img.dvk-close').click(function() {
5
+ jQuery('#dvk-donate-box').fadeOut();
6
+ });
7
+ });
backend/views/checkbox_settings.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 if (isset($opts['text']))
16
+ echo $opts['text']; ?>" /></td>
17
+ </tr>
18
+ <tr valign="top"><th scope="row">Redirect to this url after signing up <span class="ns_small">(leave empty for no redirect)</span></th>
19
+ <td><input size="50%" type="text" name="nsu_checkbox[redirect_to]" value="<?php if (isset($opts['redirect_to']))
20
+ echo $opts['redirect_to']; ?>" />
21
+ <br />
22
+ <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
23
+ users expect to be redirected to the post they commented on.</p>
24
+
25
+ </td>
26
+ </tr>
27
+ <tr valign="top"><th scope="row"><label for="ns_precheck_checkbox">Pre-check the checkbox?</label></th>
28
+ <td><input type="checkbox" id="ns_precheck_checkbox" name="nsu_checkbox[precheck]" value="1"<?php
29
+ if (isset($opts['precheck']) && $opts['precheck'] == '1') {
30
+ echo ' checked="checked"';
31
+ }
32
+ ?> /></td>
33
+ </tr>
34
+ <tr valign="top">
35
+ <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>
36
+ <td><input type="checkbox" id="do_css_reset" name="nsu_checkbox[css_reset]" value="1"<?php
37
+ if (isset($opts['css_reset']) && $opts['css_reset'] == '1') {
38
+ echo ' checked="checked"';
39
+ }
40
+ ?> /> </td>
41
+ </tr>
42
+ <tr valign="top"><th scope="row">Where to show the sign-up checkbox?</th>
43
+ <td>
44
+ <input type="checkbox" id="add_to_comment_form" name="nsu_checkbox[add_to_comment_form]" value="1"<?php
45
+ if (isset($opts['add_to_comment_form']) && $opts['add_to_comment_form'] == '1') {
46
+ echo ' checked="checked"';
47
+ }
48
+ ?> /> <label for="add_to_comment_form">WordPress comment form</label><br />
49
+ <input type="checkbox" id="add_to_reg_form" name="nsu_checkbox[add_to_registration_form]" value="1"<?php
50
+ if (isset($opts['add_to_registration_form']) && $opts['add_to_registration_form'] == '1') {
51
+ echo ' checked="checked"';
52
+ }
53
+ ?> /> <label for="add_to_reg_form">WordPress registration form</label><br />
54
+ <?php if ($this->bp_active == TRUE) { ?>
55
+ <input type="checkbox" id="add_to_bp_form" name="nsu_checkbox[add_to_buddypress_form]" value="1"<?php
56
+ if (isset($opts['add_to_buddypress_form']) && $opts['add_to_buddypress_form'] == '1') {
57
+ echo ' checked="checked"';
58
+ }
59
+ ?> /> <label for="add_to_bp_form">BuddyPress registration form</label><br />
60
+ <?php
61
+ }
62
+ if (defined('MULTISITE') && MULTISITE == TRUE) {
63
+ ?>
64
+ <input type="checkbox" id="add_to_ms_form" name="nsu_checkbox[add_to_multisite_form]" value="1"<?php
65
+ if (isset($opts['add_to_multisite_form']) && $opts['add_to_multisite_form'] == '1') {
66
+ echo ' checked="checked"';
67
+ }
68
+ ?> /> <label for="add_to_ms_form">MultiSite registration form</label><br />
69
+ <?php } ?>
70
+ </td>
71
+ </tr>
72
+ <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>
73
+ <td><input type="checkbox" id="ns_cookie_hide" name="nsu_checkbox[cookie_hide]" value="1"<?php
74
+ if (isset($opts['cookie_hide']) && $opts['cookie_hide'] == '1') {
75
+ echo ' checked="checked"';
76
+ }
77
+ ?> /></td>
78
+ </tr>
79
+
80
+ </table>
81
+
82
+ <p class="submit">
83
+ <input type="submit" class="button-primary" style="margin:5px;" value="<?php _e('Save Changes') ?>" />
84
+ </p>
85
+
86
+ </form>
87
+ </div>
88
+ </div>
89
+ </div></div></div></div>
90
+ <div class="postbox-container" style="width:30%;">
91
+ <div class="metabox-holder">
92
+ <div class="meta-box-sortables">
93
+ <?php
94
+ $this->likebox();
95
+ $this->donate_box();
96
+ $this->latest_posts();
97
+ $this->support_box();
98
+ ?>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ </div>
103
+ <?php if (isset($this->actions['show_donate_box']) && $this->actions['show_donate_box']) { ?>
104
+ <div id="dvk-donate-box">
105
+ <div id="dvk-donate-box-content">
106
+ <img width="16" height="16" class="dvk-close" src="<?php echo plugins_url('/backend/img/close.png', dirname(__FILE__)); ?>" alt="X">
107
+ <h3>Support me</h3>
108
+ <p>I noticed you've been using <?php echo $this->shortname; ?> for at least 30 days, would you like to show me a token of your appreciation by buying me a beer or tweet about <?php echo $this->shortname; ?>?</p>
109
+
110
+ <table>
111
+ <tr>
112
+ <td>
113
+ <form id="dvk_donate" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">
114
+ <input type="hidden" name="cmd" value="_s-xclick">
115
+ <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----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-----END PKCS7-----">
116
+ <input type="image" src="https://www.paypalobjects.com/WEBSCR-640-20110306-1/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
117
+ <img alt="" border="0" src="https://www.paypalobjects.com/WEBSCR-640-20110306-1/nl_NL/i/scr/pixel.gif" width="1" height="1">
118
+ </form>
119
+ </td>
120
+ <td>
121
+ <a href="http://twitter.com/share" class="twitter-share-button" data-url="<?php echo $this->plugin_url; ?>" data-text="Showing my appreciation to @DannyvanKooten for his awsome #WordPress plugin: <?php echo $this->shortname; ?>" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
122
+ </td>
123
+ </tr>
124
+ </table>
125
+ <a class="dvk-dontshow" href="options-general.php?page=<?php echo $this->hook ?>&dontshowpopup=1">(do not show me this pop-up again)</a>
126
+ </div>
127
+ </div>
128
+ <?php } ?>
backend/views/config_helper.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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:30%;">
66
+ <div class="metabox-holder">
67
+ <div class="meta-box-sortables">
68
+ <?php
69
+ $this->likebox();
70
+ $this->donate_box();
71
+ $this->latest_posts();
72
+ $this->support_box();
73
+ ?>
74
+ </div>
75
+ </div>
76
+ </div>
77
+ </div>
backend/views/dashboard.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <?php $this->mailinglist_specific_rows($viewed_mp); ?>
38
+ <tbody class="form_rows"<?php if (isset($viewed_mp) && in_array($viewed_mp, array('mailchimp', 'ymlp')) && isset($opts['use_api']) && $opts['use_api'] == 1)
39
+ echo ' style="display:none" '; ?>>
40
+ <tr valign="top"><th scope="row">Newsletter form action</th>
41
+ <td><input size="50%" type="text" id="ns_form_action" name="nsu_mailinglist[form_action]" value="<?php if (isset($opts['form_action']))
42
+ echo $opts['form_action']; ?>" /></td>
43
+ </tr>
44
+ <tr valign="top"><th scope="row">E-mail identifier <span class="ns_small">name attribute of input field that holds the emailadress</span></th>
45
+ <td><input size="50%" type="text" name="nsu_mailinglist[email_id]" value="<?php if (isset($opts['email_id']))
46
+ 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 (isset($opts['subscribe_with_name']) && $opts['subscribe_with_name'] == '1') {
52
+ echo ' checked="checked"';
53
+ } ?> /></td>
54
+ </tr>
55
+ <tr class="name_dependent" valign="top"<?php if (!isset($opts['subscribe_with_name']) || $opts['subscribe_with_name'] != 1)
56
+ echo 'style="display:none;"'; ?>><th scope="row">Name identifier <span class="ns_small">name attribute of input field that holds the name</span></th>
57
+ <td><input size="25%" id="ns_name_id" type="text" name="nsu_mailinglist[name_id]" value="<?php if (isset($opts['name_id']))
58
+ echo $opts['name_id']; ?>" /></td>
59
+ </tr>
60
+ </tbody>
61
+ </table>
62
+ <p style="margin:10px;">
63
+ 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.
64
+ You can specify these additional fields here using name / value pairs so they will be sent along with every sign-up request.
65
+ </p>
66
+ <table class="form-table">
67
+ <tr valign="top">
68
+ <th scope="column" style="font-weight:bold;">Name</th>
69
+ <th scope="column" style="font-weight:bold;">Value</th>
70
+ </tr>
71
+ <?php
72
+ $last_key = 0;
73
+
74
+ if (isset($opts['extra_data']) && is_array($opts['extra_data'])) :
75
+ foreach ($opts['extra_data'] as $key => $value) :
76
+ ?>
77
+ <tr valign="top">
78
+ <td><input size="50%" type="text" name="nsu_mailinglist[extra_data][<?php echo $key; ?>][name]" value="<?php echo $value['name']; ?>" /></td>
79
+ <td><input size="50%" type="text" name="nsu_mailinglist[extra_data][<?php echo $key; ?>][value]" value="<?php echo $value['value']; ?>" /></td>
80
+ </tr>
81
+ <?php
82
+ $last_key = $key + 1;
83
+ endforeach;
84
+ endif;
85
+ ?>
86
+ <tr valign="top">
87
+ <td><input size="50%" type="text" name="nsu_mailinglist[extra_data][<?php echo $last_key; ?>][name]" value="" /></td>
88
+ <td><input size="50%" type="text" name="nsu_mailinglist[extra_data][<?php echo $last_key; ?>][value]" value="" /></td>
89
+ </tr>
90
+ </table>
91
+ <p class="submit">
92
+ <input type="submit" class="button-primary" style="margin:5px;" value="<?php _e('Save Changes') ?>" />
93
+ </p>
94
+ </form>
95
+ <p class="nsu-tip">
96
+ 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!
97
+ </p>
98
+ </div>
99
+ </div></div></div></div></div>
100
+ <div class="postbox-container" style="width:30%;">
101
+ <div class="metabox-holder">
102
+ <div class="meta-box-sortables">
103
+ <?php
104
+ $this->likebox();
105
+ $this->donate_box();
106
+ $this->latest_posts();
107
+ $this->support_box();
108
+ ?>
109
+ </div>
110
+ </div>
111
+ </div>
112
+ </div>
113
+ <?php if (isset($this->actions['show_donate_box']) && $this->actions['show_donate_box']) { ?>
114
+ <div id="dvk-donate-box">
115
+ <div id="dvk-donate-box-content">
116
+ <img width="16" height="16" class="dvk-close" src="<?php echo plugins_url('/backend/img/close.png', dirname(__FILE__)); ?>" alt="X">
117
+ <h3>Support me</h3>
118
+ <p>I noticed you've been using <?php echo $this->shortname; ?> for at least 30 days, would you like to show me a token of your appreciation by buying me a beer or tweet about <?php echo $this->shortname; ?>?</p>
119
+
120
+ <table>
121
+ <tr>
122
+ <td>
123
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
124
+ <input type="hidden" name="cmd" value="_s-xclick">
125
+ <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----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-----END PKCS7-----
126
+ ">
127
+ <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!">
128
+ <img alt="" border="0" src="https://www.paypalobjects.com/nl_NL/i/scr/pixel.gif" width="1" height="1">
129
+ </form>
130
+
131
+ </td>
132
+ <td>
133
+ <a href="http://twitter.com/share" class="twitter-share-button" data-url="<?php echo $this->plugin_url; ?>" data-text="Showing my appreciation to @DannyvanKooten for his awsome #WordPress plugin: <?php echo $this->shortname; ?>" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
134
+ </td>
135
+ </tr>
136
+ </table>
137
+ <a class="dvk-dontshow" href="options-general.php?page=<?php echo $this->hook ?>&dontshowpopup=1">(do not show me this pop-up again)</a>
138
+ </div>
139
+ </div>
140
+ <?php } ?>
backend/views/form_settings.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 if (isset($opts['email_label']))
20
+ echo $opts['email_label']; ?>" /></td>
21
+ </tr>
22
+ <tr valign="top">
23
+ <th scope="row">E-mail default value</th>
24
+ <td><input size="50%" type="text" name="nsu_form[email_default_value]" value="<?php if(isset($opts['email_default_value'])) echo $opts['email_default_value']; ?>" /></td>
25
+ </tr>
26
+ <tr valign="top" class="name_dependent" <?php if (!isset($opts['mailinglist']['subscribe_with_name']) || $opts['mailinglist']['subscribe_with_name'] != 1)
27
+ echo 'style="display:none;"'; ?>><th scope="row">Name label <span class="ns_small">(if using subscribe with name)</span></th>
28
+ <td>
29
+ <input size="50%" type="text" name="nsu_form[name_label]" value="<?php if (isset($opts['name_label']))
30
+ echo $opts['name_label']; ?>" /><br />
31
+ <input type="checkbox" id="name_required" name="nsu_form[name_required]" value="1"<?php if (isset($opts['name_required']) && $opts['name_required'] == '1') {
32
+ echo ' checked="checked"';
33
+ } ?> />
34
+ <label for="name_required">Name is a required field?</label>
35
+ </td>
36
+
37
+ </tr>
38
+ <tr valign="top" class="name_dependent" <?php if (!isset($opts['mailinglist']['subscribe_with_name']) || $opts['mailinglist']['subscribe_with_name'] != 1)
39
+ echo 'style="display:none;"'; ?>>
40
+ <th scope="row">Name default value</th>
41
+ <td>
42
+ <input size="50%" type="text" name="nsu_form[name_default_value]" value="<?php if (isset($opts['name_default_value']))
43
+ echo $opts['name_default_value']; ?>" />
44
+ </td>
45
+
46
+ </tr>
47
+ <tr valign="top"><th scope="row">Submit button value</th>
48
+ <td><input size="50%" type="text" name="nsu_form[submit_button]" value="<?php if (isset($opts['submit_button']))
49
+ echo $opts['submit_button']; ?>" /></td>
50
+ </tr>
51
+ <tr valign="top"><th scope="row">Text to replace the form with after a successful sign-up</th>
52
+ <td>
53
+ <textarea style="width:100%;" rows="5" cols="50" name="nsu_form[text_after_signup]"><?php if (isset($opts['text_after_signup']))
54
+ echo $opts['text_after_signup']; ?></textarea>
55
+ <p><input id="nsu_form_wpautop" name="nsu_form[wpautop]" type="checkbox" value="1" <?php if (isset($opts['wpautop']) && $opts['wpautop'] == 1)
56
+ echo 'checked'; ?> />&nbsp;<label for="nsu_form_wpautop"><?php _e('Automatically add paragraphs'); ?></label></p>
57
+ </td>
58
+ </tr>
59
+
60
+ <?php if(isset($opts['mailinglist']['use_api']) && $opts['mailinglist']['use_api'] == 1) { ?>
61
+ <tr valign="top"><th scope="row">Redirect to this url after signing up <span class="ns_small">(leave empty for no redirect)</span></th>
62
+ <td><input size="50%" type="text" name="nsu_form[redirect_to]" value="<?php if (isset($opts['redirect_to']))
63
+ echo $opts['redirect_to']; ?>" /></td>
64
+ </tr>
65
+ <?php } ?>
66
+
67
+ <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>
68
+ <td><input type="checkbox" id="ns_load_form_styles" name="nsu_form[load_form_css]" value="1" <?php if (isset($opts['load_form_css']) && $opts['load_form_css'] == 1)
69
+ echo 'CHECKED'; ?> /></td>
70
+ </tr>
71
+ </table>
72
+ <p class="submit">
73
+ <input type="submit" class="button-primary" style="margin:5px;" value="<?php _e('Save Changes') ?>" />
74
+ </p>
75
+
76
+ <?php
77
+ $tips = array(
78
+ 'You can embed a sign-up form in your posts and pages by
79
+ using the shortcode <b><em>[nsu-form]</em></b> or by calling <b><em>&lt;?php if(function_exists(\'nsu_signup_form\')) nsu_signup_form(); ?&gt;</em></b> from your template files.',
80
+ '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
81
+ easier customizing'
82
+ );
83
+ $random_key = array_rand($tips);
84
+ ?>
85
+ <p class="nsu-tip">Tip: <?php echo $tips[$random_key]; ?></p>
86
+
87
+ </form>
88
+ <br style="clear:both;" />
89
+ </div></div></div></div></div></div>
90
+ <div class="postbox-container" style="width:30%;">
91
+ <div class="metabox-holder">
92
+ <div class="meta-box-sortables">
93
+ <?php
94
+ $this->likebox();
95
+ $this->donate_box();
96
+ $this->latest_posts();
97
+ $this->support_box();
98
+ ?>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ </div>
103
+ <?php if (isset($this->actions['show_donate_box']) && $this->actions['show_donate_box']) { ?>
104
+ <div id="dvk-donate-box">
105
+ <div id="dvk-donate-box-content">
106
+ <img width="16" height="16" class="dvk-close" src="<?php echo plugins_url('/backend/img/close.png', dirname(__FILE__)); ?>" alt="X">
107
+ <h3>Support me</h3>
108
+ <p>I noticed you've been using <?php echo $this->shortname; ?> for at least 30 days, would you like to show me a token of your appreciation by buying me a beer or tweet about <?php echo $this->shortname; ?>?</p>
109
+
110
+ <table>
111
+ <tr>
112
+ <td>
113
+ <form id="dvk_donate" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post">
114
+ <input type="hidden" name="cmd" value="_s-xclick">
115
+ <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----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-----END PKCS7-----">
116
+ <input type="image" src="https://www.paypalobjects.com/WEBSCR-640-20110306-1/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
117
+ <img alt="" border="0" src="https://www.paypalobjects.com/WEBSCR-640-20110306-1/nl_NL/i/scr/pixel.gif" width="1" height="1">
118
+ </form>
119
+ </td>
120
+ <td>
121
+ <a href="http://twitter.com/share" class="twitter-share-button" data-url="<?php echo $this->plugin_url; ?>" data-text="Showing my appreciation to @DannyvanKooten for his awsome #WordPress plugin: <?php echo $this->shortname; ?>" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
122
+ </td>
123
+ </tr>
124
+ </table>
125
+ <a class="dvk-dontshow" href="options-general.php?page=<?php echo $this->hook ?>&dontshowpopup=1">(do not show me this pop-up again)</a>
126
+ </div>
127
+ </div>
128
+ <?php } ?>
frontend/NewsletterSignUp.php ADDED
@@ -0,0 +1,512 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $this->get_options();
14
+ $this->add_hooks();
15
+ }
16
+
17
+ private function get_options() {
18
+ $this->options = get_option('nsu');
19
+ $this->options['form'] = get_option('nsu_form');
20
+ $this->options['mailinglist'] = get_option('nsu_mailinglist');
21
+ $this->options['checkbox'] = get_option('nsu_checkbox');
22
+ }
23
+
24
+ /**
25
+ * Registers the Newsletter Sign-Up Widget
26
+ * @return type
27
+ */
28
+ function register_widget()
29
+ {
30
+ return register_widget('NewsletterSignUpWidget');
31
+ }
32
+
33
+ /**
34
+ * Factory method for NewsletterSignUp class. Only instantiate once.
35
+ * @return NewsletterSignUp Instance of Newsletter Sign-Up class
36
+ */
37
+ public static function getInstance() {
38
+ if(!isset(self::$instance)) self::$instance = new NewsletterSignUp();
39
+
40
+ return self::$instance;
41
+ }
42
+
43
+ /**
44
+ * Add all the various WP filters and actions
45
+ */
46
+ function add_hooks()
47
+ {
48
+ // widget hooks
49
+ add_action('widgets_init',array(&$this,'register_widget'));
50
+ add_action('init',array(&$this,'check_for_form_submit'));
51
+
52
+ // register the shortcode which can be used to output sign-up form
53
+ add_shortcode('newsletter-sign-up-form',array(&$this,'form_shortcode'));
54
+ add_shortcode('nsu-form',array(&$this,'form_shortcode'));
55
+
56
+ // Build stylesheet url --------------
57
+ $stylesheet_opts = '?';
58
+ $enqueue = false;
59
+ // Load CSS to reset the checkbox' position?
60
+ if(isset($this->options['checkbox']['css_reset']) && $this->options['checkbox']['css_reset'] == 1) {
61
+ $stylesheet_opts .= 'checkbox_reset=1';
62
+ $enqueue = true;
63
+ }
64
+ // Load CSS to reset label and input fields for the sign-up form?
65
+ if(isset($this->options['form']['load_form_css']) && $this->options['form']['load_form_css'] == 1) {
66
+ $stylesheet_opts .= '&form_css=1';
67
+ $enqueue = true;
68
+ }
69
+
70
+ // Only enqueue stylesheet if asked to by user.
71
+ if($enqueue) { wp_enqueue_style('ns_checkbox_style',plugins_url("/frontend/css/newsletter-sign-up.php$stylesheet_opts",dirname(__FILE__))); }
72
+
73
+ // Add to comment form? If so, add necessary actions. Try to add automatically.
74
+ if(isset($this->options['checkbox']['add_to_comment_form']) && $this->options['checkbox']['add_to_comment_form'] == 1) {
75
+ add_action('thesis_hook_after_comment_box',array(&$this,'output_checkbox'),20);
76
+ add_action('comment_form',array(&$this,'output_checkbox'),20);
77
+ add_action('comment_approved_',array(&$this,'grab_email_from_comment'),10,1);
78
+ add_action('comment_post', array(&$this,'grab_email_from_comment'), 50, 2);
79
+ }
80
+
81
+ // If add_to_reg_form is ticked, add corresponding actions
82
+ if(isset($this->options['checkbox']['add_to_registration_form']) && $this->options['checkbox']['add_to_registration_form'] == 1) {
83
+ add_action('register_form',array(&$this,'output_checkbox'),20);
84
+ add_action('register_post',array(&$this,'grab_email_from_wp_signup'), 50);
85
+ }
86
+
87
+ // If add_to_bp_form is ticked, add BuddyPress actions
88
+ if(isset($this->options['checkbox']['add_to_buddypress_form']) && $this->options['checkbox']['add_to_buddypress_form'] == 1) {
89
+ add_action('bp_before_registration_submit_buttons',array(&$this,'output_checkbox'),20);
90
+ add_action('bp_complete_signup',array(&$this,'grab_email_from_wp_signup'),20);
91
+ }
92
+
93
+ // If running a MultiSite, add to registration form and add actions.
94
+ if(isset($this->options['checkbox']['add_to_multisite_form']) && $this->options['checkbox']['add_to_multisite_form'] == 1) {
95
+ add_action('signup_extra_fields',array(&$this,'output_checkbox'),20);
96
+ add_action('signup_blogform',array(&$this,'add_hidden_checkbox'),20);
97
+ add_filter('add_signup_meta',array(&$this,'add_checkbox_to_usermeta'));
98
+ add_action('wpmu_activate_blog',array(&$this,'grab_email_from_ms_blog_signup'),20,5);
99
+ add_action('wpmu_activate_user',array(&$this,'grab_email_from_ms_user_signup'),20,3);
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Check if ANY Newsletter Sign-Up form has been submitted.
105
+ */
106
+ function check_for_form_submit()
107
+ {
108
+ $opts = $this->options['form'];
109
+ $errors = array();
110
+
111
+
112
+
113
+ if(isset($_POST['nsu_submit']))
114
+ {
115
+ $email = (isset($_POST['nsu_email'])) ? $_POST['nsu_email'] : '';
116
+ $naam = (isset($_POST['nsu_name'])) ? $_POST['nsu_name'] : '';
117
+
118
+ if(isset($this->options['mailinglist']['subscribe_with_name']) && $this->options['mailinglist']['subscribe_with_name'] == 1 && isset($opts['name_required']) && $opts['name_required'] == 1 && empty($naam)) {
119
+ $errors['name-field'] = 'Please fill in the name field.';
120
+ }
121
+
122
+ if(empty($email)) {
123
+ $errors['email-field'] = 'Please fill in the email address field.';
124
+ } elseif(!is_email($email)) {
125
+ $errors['email-field'] = 'Please enter a valid email address.';
126
+ }
127
+
128
+ $this->validation_errors = $errors;
129
+
130
+
131
+ if(count($this->validation_errors) == 0)
132
+ $this->send_post_data($email,$naam,'form');
133
+ }
134
+ return;
135
+ }
136
+
137
+
138
+ /**
139
+ * Output the checkbox (only once).
140
+ */
141
+ public function output_checkbox()
142
+ {
143
+ $opts = $this->options['checkbox'];
144
+ // If using option to hide checkbox for subscribers and cookie is set, set instance variable showed_checkbox to true so checkbox won't show.
145
+ if(isset($opts['cookie_hide']) && $opts['cookie_hide'] == 1 && isset($_COOKIE['ns_subscriber'])) $this->showed_checkbox = TRUE;
146
+
147
+ // User could have rendered the checkbox by manually adding 'the hook 'ns_comment_checkbox()' to their comment form
148
+ // If so, abandon function.
149
+ if($this->showed_checkbox) return false;
150
+
151
+ ?>
152
+ <p id="ns-checkbox">
153
+ <input value="1" id="nsu_checkbox" type="checkbox" name="newsletter-signup-do" <?php if(isset($opts['precheck']) && $opts['precheck'] == 1) echo 'checked="checked" '; ?>/>
154
+ <label for="nsu_checkbox">
155
+ <?php if(!empty($opts['text'])) { echo $opts['text']; } else { echo "Sign me up for the newsletter!"; } ?>
156
+ </label>
157
+ </p>
158
+ <?php
159
+
160
+ $this->showed_checkbox = true;
161
+ return true;
162
+ }
163
+
164
+ /**
165
+ * 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
166
+ */
167
+ function add_hidden_checkbox()
168
+ {
169
+ ?>
170
+ <input type="hidden" name="newsletter-signup-do" value="<?php echo (isset($_POST['newsletter-signup-do'])) ? 1 : 0; ?>" />
171
+ <?php
172
+ }
173
+
174
+ /**
175
+ * Save the value of the checkbox to MultiSite sign-ups table
176
+ */
177
+ function add_checkbox_to_usermeta($meta)
178
+ {
179
+ $meta['newsletter-signup-do'] = (isset($_POST['newsletter-signup-do'])) ? 1 : 0;
180
+ return $meta;
181
+ }
182
+
183
+ /**
184
+ * Send the post data to the newsletter service, mimic form request
185
+ */
186
+ function send_post_data($email, $naam = '', $type = 'checkbox')
187
+ {
188
+ $opts = $this->options['mailinglist'];
189
+ // when not using api and no form action has been given, abandon.
190
+ if(empty($opts['use_api']) && empty($opts['form_action'])) return;
191
+
192
+ $post_data = array();
193
+
194
+ /* Are we using API? */
195
+ if(isset($opts['use_api']) && $opts['use_api'] == 1) {
196
+
197
+ switch($opts['provider']) {
198
+
199
+ /* Send data using the YMLP API */
200
+ case 'ymlp':
201
+ $request_uri = "http://www.ymlp.com/api/Contacts.Add?";
202
+ $request_uri .= "Key=" . $opts['ymlp_api_key'];
203
+ $request_uri .= "&Username=" . $opts['ymlp_username'];
204
+ $request_uri .= "&Email=" . $email;
205
+ $request_uri .= "&GroupID=" . $opts['ymlp_groupid'];
206
+ $request_uri .= $this->add_additional_data(array('format' => 'query_string', 'api' => 'ymlp'));
207
+ $result = wp_remote_get($request_uri);
208
+ break;
209
+
210
+ /* Send data using the MailChimp API */
211
+ case 'mailchimp':
212
+ $request = array(
213
+ 'apikey' => $opts['mc_api_key'],
214
+ 'id' => $opts['mc_list_id'],
215
+ 'email_address' => $email,
216
+ 'double_optin' => TRUE,
217
+ 'merge_vars' => array(
218
+ 'OPTIN_TIME' => date('Y-M-D H:i:s')
219
+ )
220
+ );
221
+
222
+ /* Subscribe with name? If so, add name to merge_vars array */
223
+ if(isset($opts['subscribe_with_name']) && $opts['subscribe_with_name'] == 1) {
224
+ // Try to provide values for First and Lastname fields
225
+ // These can be overridden, of just ignored by mailchimp.
226
+ $request['merge_vars']['FNAME'] = substr($naam,0,strpos($naam,' '));
227
+ $request['merge_vars']['LNAME'] = substr($naam,strpos($naam,' '));
228
+ $request['merge_vars'][$opts['name_id']] = $naam;
229
+ }
230
+ // Add any set additional data to merge_vars array
231
+ $request['merge_vars'] = array_merge($request['merge_vars'],$this->add_additional_data());
232
+
233
+ $result = wp_remote_post(
234
+ 'http://'.substr($opts['mc_api_key'],-3).'.api.mailchimp.com/1.3/?output=php&method=listSubscribe',
235
+ array( 'body' => json_encode($request))
236
+ );
237
+
238
+
239
+ break;
240
+
241
+ }
242
+
243
+ } else {
244
+ /* We are not using API, mimic a normal form request */
245
+
246
+ $post_data = array(
247
+ $opts['email_id'] => $email,
248
+ );
249
+
250
+ // Subscribe with name? Add to $post_data array.
251
+ if(isset($opts['subscribe_with_name']) && $opts['subscribe_with_name'] == 1) $post_data[$opts['name_id']] = $naam;
252
+
253
+ // Add list specific data
254
+ switch($opts['provider']) {
255
+
256
+ case 'aweber':
257
+ $post_data['listname'] = $opts['aweber_list_name'];
258
+ $post_data['redirect'] = get_bloginfo('wpurl');
259
+ $post_data['meta_message'] = '1';
260
+ $post_data['meta_required'] = 'email';
261
+ break;
262
+
263
+ case 'phplist':
264
+ $post_data['list['.$opts['phplist_list_id'].']'] = 'signup';
265
+ $post_data['subscribe'] = "Subscribe";
266
+ $post_data["htmlemail"] = "1";
267
+ $post_data['emailconfirm'] = $emailadres;
268
+ $post_data['makeconfirmed']='0';
269
+ break;
270
+
271
+ }
272
+
273
+ $post_data = array_merge($post_data,$this->add_additional_data($post_data));
274
+
275
+ $result = wp_remote_post($opts['form_action'],
276
+ array( 'body' => $post_data )
277
+ );
278
+
279
+ }
280
+
281
+ // store a cookie, if preferred by site owner
282
+ if(isset($opts['cookie_hide']) && $opts['cookie_hide'] == 1) @setcookie('ns_subscriber',TRUE,time() + 9999999);
283
+
284
+ // Check if we should redirect to a given page
285
+ if($type == 'form' && isset($this->options['form']['redirect_to']) && strlen($this->options['form']['redirect_to']) > 6) {
286
+ wp_redirect( $this->options['form']['redirect_to']);
287
+ exit;
288
+ } elseif($type == 'checkbox' && isset($this->options['checkbox']['redirect_to']) && strlen($this->options['checkbox']['redirect_to']) > 6) {
289
+ wp_redirect( $this->options['checkbox']['redirect_to']);
290
+ exit;
291
+ }
292
+
293
+ }
294
+
295
+ /**
296
+ * Returns array with additional data names as key, values as value.
297
+ * @param array $args, the normal form data (name, email, list variables)
298
+ */
299
+ function add_additional_data($args = array())
300
+ {
301
+ $opts = $this->options['mailinglist'];
302
+ $defaults = array(
303
+ 'format' => 'array',
304
+ 'api' => NULL
305
+ );
306
+
307
+ $args = wp_parse_args( $args, $defaults );
308
+
309
+ if($args['format'] == 'query_string') {
310
+
311
+ $add_data = "";
312
+ if(isset($opts['extra_data']) && is_array($opts['extra_data'])) {
313
+ foreach($opts['extra_data'] as $key => $value) {
314
+ if($args['api'] == 'ymlp') $value['name'] = str_replace('YMP','Field',$value['name']);
315
+ $add_data .= "&".$value['name']."=".$value['value'];
316
+ }
317
+ }
318
+ return $add_data;
319
+ }
320
+
321
+ $add_data = array();
322
+ if(isset($opts['extra_data']) && is_array($opts['extra_data'])) {
323
+ foreach($opts['extra_data'] as $key => $value) {
324
+ $add_data[$value['name']] = $value['value'];
325
+ }
326
+ }
327
+
328
+ return $add_data;
329
+ }
330
+
331
+ /**
332
+ * Perform the sign-up for users that registered trough a MultiSite register form
333
+ * This function differs because of the need to grab the emailadress from the user using get_userdata
334
+ * @param int $user_id : the ID of the new user
335
+ * @param string $password : the password, we don't actually use this
336
+ * @param array $meta : the meta values that belong to this user, holds the value of our 'newsletter-sign-up' checkbox.
337
+ */
338
+ function grab_email_from_ms_user_signup($user_id, $password = NULL,$meta = NULL){
339
+ if(!isset($meta['newsletter-signup-do']) || $meta['newsletter-signup-do'] != 1) return;
340
+ $user_info = get_userdata($user_id);
341
+
342
+ $email = $user_info->user_email;
343
+ $naam = $user_info->first_name;
344
+
345
+ $this->send_post_data($email,$naam);
346
+ }
347
+
348
+ /**
349
+ * Perform the sign-up for users that registered trough a MultiSite register form
350
+ * This function differs because of the need to grab the emailadress from the user using get_userdata
351
+ * @param int $blog_id The id of the new blow
352
+ * @param int $user_id The ID of the new user
353
+ * @param $a No idea, seriously.
354
+ * @param $b No idea, seriously.
355
+ * @param array $meta The meta values that belong to this user, holds the value of our 'newsletter-sign-up' checkbox.
356
+ */
357
+ function grab_email_from_ms_blog_signup($blog_id, $user_id, $a, $b ,$meta){
358
+
359
+ if(!isset($meta['newsletter-signup-do']) || $meta['newsletter-signup-do'] != 1) return;
360
+ $user_info = get_userdata($user_id);
361
+
362
+ $email = $user_info->user_email;
363
+ $naam = $user_info->first_name;
364
+
365
+ $this->send_post_data($email,$naam);
366
+ }
367
+
368
+ /**
369
+ * Grab the emailadress (and name) from a regular WP or BuddyPress sign-up and then send this to mailinglist.
370
+ */
371
+ function grab_email_from_wp_signup()
372
+ {
373
+ if($_POST['newsletter-signup-do'] != 1) return;
374
+
375
+ if(isset($_POST['user_email'])) {
376
+
377
+ // gather emailadress from user who WordPress registered
378
+ $email = $_POST['user_email'];
379
+ $naam = $_POST['user_login'];
380
+
381
+ } elseif(isset($_POST['signup_email'])) {
382
+
383
+ // gather emailadress from user who BuddyPress registered
384
+ $email = $_POST['signup_email'];
385
+ $naam = $_POST['signup_username'];
386
+
387
+ } else { return; }
388
+
389
+ $this->send_post_data($email,$naam);
390
+ }
391
+
392
+ /**
393
+ * Grab the emailadress and name from comment and then send it to mailinglist.
394
+ * @param int $cid : the ID of the comment
395
+ * @param object $comment : the comment object, optionally
396
+ */
397
+ function grab_email_from_comment($cid,$comment = NULL)
398
+ {
399
+ if($_POST['newsletter-signup-do'] != 1) return;
400
+
401
+ $cid = (int) $cid;
402
+
403
+ // get comment data
404
+ if(!is_object($comment)) $comment = get_comment($cid);
405
+
406
+ // if spam, abandon function
407
+ if($comment->comment_karma != 0) return;
408
+
409
+ $email = $comment->comment_author_email;
410
+ $naam = $comment->comment_author;
411
+
412
+ $this->send_post_data($email,$naam);
413
+ }
414
+
415
+ /**
416
+ * The NSU form shortcode function. Calls the output_form method
417
+ *
418
+ * @param array $atts Not used
419
+ * @param string $content Not used
420
+ * @return string Form HTML-code
421
+ */
422
+ function form_shortcode($atts = null,$content = null)
423
+ {
424
+ return $this->output_form(false);
425
+ }
426
+
427
+ /**
428
+ * Generate the HTML for a form
429
+ * @param boolean $echo Should HTML be echo'ed?
430
+ * @return string The generated HTML
431
+ */
432
+ public function output_form($echo = true)
433
+ {
434
+ $errors = $this->validation_errors;
435
+ $opts = $this->options;
436
+ $additional_fields = '';
437
+ $output = '';
438
+
439
+ $this->no_of_forms++;
440
+ $formno = $this->no_of_forms;
441
+
442
+ /* Set up form variables for API usage or normal form */
443
+ if(isset($opts['mailinglist']['use_api']) && $opts['mailinglist']['use_api'] == 1) {
444
+
445
+ /* Using API, send form request to widget-signup.php */
446
+ $form_action = "";
447
+ $email_id = 'nsu_email';
448
+ $name_id = 'nsu_name';
449
+
450
+ } else {
451
+
452
+ /* Using normal form request, set-up using configuration settings */
453
+ $form_action = $opts['mailinglist']['form_action'];
454
+ $email_id = $opts['mailinglist']['email_id'];
455
+
456
+ if(isset($opts['mailinglist']['name_id'])) {
457
+ $name_id = $opts['mailinglist']['name_id'];
458
+ }
459
+
460
+ }
461
+
462
+ /* Set up additional fields */
463
+ if(isset($opts['mailinglist']['extra_data']) && is_array($opts['mailinglist']['extra_data'])) :
464
+ foreach($opts['mailinglist']['extra_data'] as $ed) :
465
+ $additional_fields .= "<input type=\"hidden\" name=\"{$ed['name']}\" value=\"{$ed['value']}\" />";
466
+ endforeach;
467
+ endif;
468
+
469
+ $email_label = (!empty($opts['form']['email_label'])) ? $opts['form']['email_label'] : 'E-mail:';
470
+ $name_label = (!empty($opts['form']['name_label'])) ? $opts['form']['name_label'] : 'Name:';
471
+
472
+ $email_value = (!empty($opts['form']['email_default_value'])) ? $opts['form']['email_default_value'] : '';
473
+ $name_value = (!empty($opts['form']['name_default_value'])) ? $opts['form']['name_default_value'] : '';
474
+
475
+ $submit_button = (!empty($opts['form']['submit_button'])) ? $opts['form']['submit_button'] : __('Sign-Up');
476
+
477
+ $text_after_signup = (!empty($opts['form']['text_after_signup'])) ? $opts['form']['text_after_signup'] : 'Thanks for signing up to our newsletter. Please check your inbox to confirm your email address.';
478
+ $text_after_signup = (isset($opts['form']['wpautop']) && $opts['form']['wpautop'] == 1) ? wpautop(wptexturize($text_after_signup)) : $text_after_signup;
479
+
480
+
481
+
482
+ if(!isset($_POST['nsu_submit']) || count($errors) > 0) { //form has not been submitted yet
483
+
484
+ $output .= "<form class=\"nsu-form\" id=\"nsu-form-$formno\" action=\"$form_action\" method=\"post\">";
485
+ if(isset($opts['mailinglist']['subscribe_with_name']) && $opts['mailinglist']['subscribe_with_name'] == 1) {
486
+ $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\" onfocus=\"if(this.value == '$name_value') this.value=''\" />";
487
+ if(isset($errors['name-field'])) $output .= '<span class="nsu-error error notice">'.$errors['name-field'].'</span>';
488
+ $output .= "</p>";
489
+ }
490
+
491
+ $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\" onfocus=\"if(this.value == '$email_value') this.value=''\" />";
492
+ if(isset($errors['email-field'])) $output .= '<span class="nsu-error error notice">'.$errors['email-field'].'</span>';
493
+ $output .= "</p>";
494
+ $output .= $additional_fields;
495
+ $output .= "<p><input type=\"submit\" id=\"nsu-submit-$formno\" class=\"nsu-submit\" name=\"nsu_submit\" value=\"$submit_button\" /></p>";
496
+ $output .= "</form>";
497
+
498
+ } else { // form has been submitted
499
+
500
+ $output = "<p id=\"nsu-signed-up-$formno\" class=\"nsu-signed-up\">$text_after_signup</p>";
501
+
502
+ }
503
+
504
+ if($echo) {
505
+ echo $output;
506
+ }
507
+
508
+ return $output;
509
+
510
+ }
511
+ }
512
+ }
frontend/NewsletterSignUpWidget.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!class_exists('NewsletterSignUpWidget')) {
4
+
5
+ class NewsletterSignUpWidget extends WP_Widget {
6
+
7
+ function __construct() {
8
+ $widget_ops = array('classname' => 'nsu_widget', 'description' => __('Adds a newsletter sign-up form.'));
9
+ $control_ops = array('width' => 400, 'height' => 350);
10
+ parent::__construct(false, 'Newsletter Sign-Up Widget', $widget_ops, $control_ops);
11
+ }
12
+
13
+ function widget($args, $instance) {
14
+ $NewsletterSignUp = NewsletterSignUp::getInstance();
15
+ /* Get Newsletter Sign-up options */
16
+ $options = get_option('nsu_form');
17
+
18
+ /* Provide some defaults */
19
+ $defaults = array( 'title' => 'Sign up for our newsletter!', 'text_before_form' => '', 'text_after_form' => '');
20
+ $instance = wp_parse_args( (array) $instance, $defaults );
21
+
22
+ extract( $args );
23
+ extract($instance);
24
+ $title = apply_filters('widget_title', $title);
25
+
26
+ echo $before_widget;
27
+ echo $before_title . $title . $after_title;
28
+
29
+ if(!empty($text_before_form)) {
30
+ ?><div class="nsu-text-before-form"><?php
31
+ $instance['filter'] ? _e(wpautop($text_before_form),'nsu-widget') : _e($text_before_form,'nsu-widget');
32
+ ?></div><?php
33
+ }
34
+ $NewsletterSignUp->output_form(true);
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');
38
+ ?></div><?php
39
+ }
40
+
41
+ echo $after_widget;
42
+ }
43
+
44
+ function update($new_instance, $old_instance) {
45
+ $instance = $old_instance;
46
+ $instance['title'] = strip_tags($new_instance['title']);
47
+
48
+ if ( current_user_can('unfiltered_html') ) {
49
+ $instance['text_before_form'] = $new_instance['text_before_form'];
50
+ $instance['text_after_form'] = $new_instance['text_after_form'];
51
+ } else {
52
+ $instance['text_before_form'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text_before_form']) ) );
53
+ $instance['text_after_form'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text_after_form']) ) );
54
+ }
55
+ $instance['filter'] = isset($new_instance['filter']);
56
+
57
+ return $instance;
58
+ }
59
+
60
+ function form($instance) {
61
+ $defaults = array( 'title' => 'Sign up for our newsletter!', 'text_before_form' => '', 'text_after_form' => '');
62
+ $instance = wp_parse_args( (array) $instance, $defaults );
63
+
64
+ extract($instance);
65
+ $title = strip_tags($title);
66
+
67
+ ?>
68
+
69
+
70
+ <p>
71
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
72
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
73
+ </p>
74
+
75
+ <label title="You can use the following HTML-codes: &lt;a&gt;, &lt;strong&gt;, &lt;br /&gt;,&lt;em&gt; &lt;img ..&gt;" for="<?php echo $this->get_field_id('text_before_form'); ?>"><?php _e('Text to show before the form:'); ?></label>
76
+ <textarea rows="8" cols="10" class="widefat wysiwyg-overlay-toggle" id="<?php echo $this->get_field_id('text_before_form'); ?>" name="<?php echo $this->get_field_name('text_before_form'); ?>"><?php echo $text_before_form; ?></textarea>
77
+ <br />
78
+ <label for="<?php echo $this->get_field_id('text_after_form'); ?>"><?php _e('Text to show after the form:'); ?></label>
79
+ <textarea rows="8" cols="10" class="widefat wysiwyg-overlay-toggle" id="<?php echo $this->get_field_id('text_after_form'); ?>" name="<?php echo $this->get_field_name('text_after_form'); ?>"><?php echo $text_after_form; ?></textarea>
80
+
81
+ <p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> />&nbsp;<label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs'); ?></label></p>
82
+
83
+ <p>
84
+ You can further configure the sign-up form at the <a href="admin.php?page=newsletter-sign-up/form-settings">Newsletter Sign-Up configuration page</a>.
85
+ </p>
86
+
87
+ <p style="font-size:11px; font-style:italic;">Tip: You can also use <a href="http://wordpress.org/extend/plugins/wysiwyg-widgets/" target="_blank">WYSIWYG Widgets</a> in combination with the shortcode <strong>[nsu-form]</strong> to render a sign-up form in your widget area's.</p>
88
+ <?php
89
+ }
90
+
91
+ }
92
+ }
frontend/css/newsletter-sign-up.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php header('Content-type: text/css');
2
+
3
+ if (isset($_GET['checkbox_reset']) && $_GET['checkbox_reset'] == 1) { ?>
4
+ p#ns-checkbox{ clear:both; display:block; }
5
+
6
+ #ns-checkbox input{ margin:0 5px 0 0; display:inline-block; width:13px; height:13px; }
7
+
8
+ #ns-checkbox label{ display:inline-block; }
9
+ <?php }
10
+ if (isset($_GET['form_css']) && $_GET['form_css'] == 1) { ?>
11
+ .nsu-form { margin:10px 0; }
12
+
13
+ .nsu-form p,.nsu-text-before-form,.nsu-text-after-form{ clear:both; display:block; margin:5px 0; }
14
+ .nsu-text-before-form ul,nsu-text-after-form ul,.nsu-text-before-form ol,nsu-text-after-form ol{ margin-left:15px; }
15
+
16
+ .nsu-form label{display:block; font-weight:bold; }
17
+ .nsu-form input{ padding:2px; display:block; color:#999; }
18
+ .nsu-form input:focus, .nsu-form input:active{ color:#000; }
19
+
20
+ .nsu-field{ background:white; }
21
+ input.nsu-submit{ color:#000; }
22
+
23
+ .nsu-error { font-size:75%; font-style:italic; }
24
+ <?php } ?>
newsletter-sign-up.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
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: 1.6.1
7
+ Author: Danny van Kooten
8
+ Author URI: http://DannyvanKooten.com
9
+ License: GPL2
10
+ */
11
+
12
+ /* Copyright 2010 Danny van Kooten (email : danny@vkimedia.com)
13
+
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License, version 2, as
16
+ published by the Free Software Foundation.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU General Public License for more details.
22
+
23
+ You should have received a copy of the GNU General Public License
24
+ along with this program; if not, write to the Free Software
25
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
+ */
27
+
28
+ /*
29
+ TO DO
30
+
31
+ * Add %%NAME%% to use in additional data
32
+ * Add %%IP%% to use in additional data
33
+
34
+ */
35
+
36
+ require('frontend/NewsletterSignUpWidget.php');
37
+ require('frontend/NewsletterSignUp.php');
38
+
39
+ $NewsletterSignUp = NewsletterSignUp::getInstance();
40
+
41
+ if(is_admin()) {
42
+ require('backend/NewsletterSignUpAdmin.php');
43
+ $NewsletterSignUpAdmin = new NewsletterSignUpAdmin();
44
+ }
45
+
46
+ /**
47
+ * Displays the comment checkbox, call this function if your theme does not use the 'comment_form' action in the comments.php template.
48
+ */
49
+ function nsu_checkbox() {
50
+ $NewsletterSignUp = NewsletterSignUp::getInstance();
51
+ $NewsletterSignUp->output_checkbox();
52
+ }
53
+
54
+ /**
55
+ * Deprecated
56
+ * Just an alias for nsu_checkbox(), for backwards compatibility.
57
+ */
58
+ function ns_comment_checkbox()
59
+ {
60
+ nsu_checkbox();
61
+ }
62
+
63
+ /**
64
+ * Outputs a sign-up form, for usage in your theme files.
65
+ */
66
+ function nsu_signup_form()
67
+ {
68
+ $NewsletterSignUp = NewsletterSignUp::getInstance();
69
+ $NewsletterSignUp->output_form(true);
70
+ }
readme.txt ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: DvanKooten
3
+ Donate link: http://dannyvankooten.com/donate/
4
+ Tags: newsletter,sign-up,mailchimp,aweber,newsletter signup,checkbox,ymlp,email,email address,subscribe,subscribers,phplist,icontact,mailinglist,checkbox,form widget,widget,newsletter widget,subscribe widget
5
+ Requires at least: 2.7
6
+ Tested up to: 3.2.1
7
+ Stable tag: 1.6.1
8
+
9
+ Boost your mailinglist size by adding various ways for your visitors to subscribe: A newsletter sign-up checkbox for your comment forms, a sign-up form widget and a shortcode to embed a sign-up form in your posts.
10
+
11
+ == Description ==
12
+
13
+ = Newsletter Sign-Up =
14
+
15
+ Boost your mailinglist size with this newsletter plugin! This plugin adds various ways for your visitors to subscribe to your third-party newsletter: A checkbox to your comment or registration forms,
16
+ a sign-up form widget and a shortcode to easily embed newsletter sign-up forms in your posts and pages.
17
+
18
+ This plugin currently supports the following newsletter providers but is not limited to those: MailChimp, YMLP, Aweber, iContact, PHPList, Feedblitz.
19
+ You can practically use the plugin for EVERY newsletter provider that's around if you use the right configuration settings.
20
+
21
+ **Features:**
22
+
23
+ * Add a "sign-up to our newsletter" checkbox to your comment form or register form (including BuddyPress or MultiSite forms)
24
+ * Add a customizable newsletter sign-up form as a widget.
25
+ * Embed a customizable sign-up form in your posts or pages by using the shortcode `[newsletter-sign-up-form]`.
26
+ * Embed a sign-up form in your template files by calling `nsu_signup_form();`
27
+ * Use the MailChimp or YMLP API or any other third party newsletter provider.
28
+ * Works with most major mailinglist services because of the form mimicing feature.
29
+ * Compatible with [WYSIWYG Widgets](http://dannyvankooten.com/wordpress-plugins/wysiwyg-widgets/) to allow easy widget text editing.
30
+
31
+ **More info:**
32
+
33
+ * [Newsletter Sign-Up](http://dannyvankooten.com/wordpress-plugins/newsletter-sign-up/)
34
+ * Check out more [WordPress plugins](http://dannyvankooten.com/wordpress-plugins/) by the same author
35
+ * [Follow Danny on Twitter](http://twitter.com/DannyvanKooten) for lightning fast support and updates.
36
+
37
+ = "Sign me up" checkbox =
38
+ 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.
39
+ Signing up to your newsletter is as easy as ticking a checkbox!
40
+
41
+ = Sign-up forms =
42
+ 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
43
+ 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.
44
+
45
+ = Using MailChimp or YMLP? Use their API's! =
46
+ 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.
47
+
48
+ = Customizable =
49
+ All generated forms come with common CSS classes and unique CSS identifiers so that you can easily style them to your likings.
50
+
51
+ = Easy to setup =
52
+ Configuring Newsletter Sign-Up has been made as easy as possible. With the Configuration Extractor that comes with Newsletter Sign-Up all you have to is provide your sign-up form HTML code, the configuration extractor
53
+ tool will then analyze it and try to extract the right values for you.
54
+
55
+
56
+ == Installation ==
57
+
58
+ 1. Upload the contents of newsletter-sign-up.zip to your plugins directory.
59
+ 1. Activate the plugin
60
+ 1. Specify your newsletter service settings. For more info head over to: [How to configure Newsletter Sign-Up](http://dannyvankooten.com/wordpress-plugins/newsletter-sign-up/)
61
+ 1. That's all. Watch your list grow!
62
+ 1. Optional: Install [WYSIWYG Widgets](http://dannyvankooten.com/wordpress-plugins/wysiwyg-widgets/) if you want to be able to easily edit the widget's form text.
63
+
64
+ == Frequently Asked Questions ==
65
+
66
+ = What does this plugin do? =
67
+
68
+ This plugin adds various way to your WP blog for visitors to subscribe to your third party newsletter service. What once started out as a simple 'Sign me up to your newsletter' checkbox at your comment form is now a
69
+ superb e-mail address gatherer. This plugin respects double opt-in rules, it's all legit.
70
+
71
+ = What is the shortcode to embed a sign-up form in my posts? =
72
+
73
+ Its `[newsletter-sign-up-form]`.
74
+
75
+ = Why does the checkbox not show up? =
76
+
77
+ You're theme probably does not support the comment hook this plugin uses to add the checkbox to your comment form. You can manually place the checkbox
78
+ by calling `<?php if(function_exists('nsu_checkbox')) nsu_checkbox(); ?>` inside the form tags of your comment form. Usually this file can be found in your theme folder as `comments.php`.
79
+
80
+ = Where can I get the form action of my sign-up form? =
81
+
82
+ Look at the source code of your sign-up form and check for `<form action="http://www.yourmailinglist.com/signup?a=asd123"`....
83
+ The action attribute is what you need here.
84
+
85
+ = Where can I get the email identifier of my sign-up form? =
86
+
87
+ Take a look at the source code of your sign-up form and look for the input field that holds the email address. You'll need the NAME attribute of this input field, eg: `<input type="text" name="emailid"....` (in this case emailid is what you need)
88
+
89
+ = Can I let my users subscribe with their name too? =
90
+
91
+ Yes, it's possible. Just provide your name identifier (finding it is much like the email identifier) and the plugin will try to submit the user's name along with the request.
92
+
93
+ = Can I also show a checkbox at the BuddyPress sign-up form? =
94
+
95
+ Yes.
96
+
97
+ = Can I show a sign-up form by calling a function in my template files? =
98
+
99
+ Yes, use the following code snippet in your theme files to embed a sign-up form: `if(function_exists('nsu_signup_form')) nsu_signup_form();`
100
+
101
+ For more questions and answers go have a look at my website regarding [Newsletter Sign-Up](http://dannyvankooten.com/wordpress-plugins/newsletter-sign-up/)
102
+
103
+ == Screenshots ==
104
+
105
+ 1. The mailinglist configuration page of Newsletter Sign-Up in the WordPress admin panel.
106
+ 2. The form configuration page in the WP Admin panel.
107
+ 3. The "sign-up" checkbox in action @ Twenty Eleven
108
+
109
+ == Changelog ==
110
+
111
+ = 1.6.1 =
112
+ * Fixed notice on frontend when e-mail field not filled in
113
+ * Fixed provided values for First and Lastname field for MailChimp when using both.
114
+
115
+ = 1.6 =
116
+ * Improvement: Huge backend changes. Everything is split up for increased maintainability.
117
+ * Improvement: Better code documenting
118
+ * Improvement: Consistent function names (with backwards compatibility for old function names)
119
+ * Improvement: Only load frontend CSS file if actually needed / asked to.
120
+ * Added: Added CSS class to text after signing up
121
+ * Added: Added option to automatically add paragraph's to text after signing up.
122
+ * Added: Added option to set default value for e-mail and name field.
123
+ * Added: Option to redirect to a given url after signing-up
124
+ * Added: More elegant error handling.
125
+ * Fix: "Hide checkbox for subscribers" did not work after version 1.5.1
126
+
127
+ = 1.5.2 =
128
+ * Fix: Fixed widget, it was broken after v1.5.1.
129
+
130
+ = 1.5.1 =
131
+ * Improvement: Minor code improvements
132
+ * Improvement: Minor backend changes
133
+
134
+ = 1.5.0 =
135
+ * Added: Config Extractor, a tool that helps you extract the right configuration settings when manually configuring.
136
+ * Improvement: Some code refactoring, more to come..
137
+
138
+ = 1.4.3 =
139
+ * Improvement: Added CSS classes to the form's label's and input fields.
140
+ * Improvement: Added unique ID's to each form and input field
141
+ * Added: Compatibilty with [WYSIWYG Widgets Plugin](http://dannyvankooten.com/wordpress-plugins/wysiwyg-widgets/) . Install that plugin if you want to be able
142
+ to easily edit the widget's text. :)
143
+
144
+ = 1.4.2 =
145
+ * Improvement: Made the label at comment form and registration forms clickable so it checks the checkbox.
146
+ * Improvement: Made 'email' a required field when submitting the sign-up form.
147
+ * Improvement: Made 'name' an optionally required field when submitting the sign-up form.
148
+
149
+ = 1.4.1 =
150
+ * Added: the function `nsu_signup_form()` which you can call from your theme files to output a sign-up form, just like the shortcode.
151
+
152
+ = 1.4 =
153
+ * Improvement: Hide metaboxes in the NSU configuration screen
154
+ * Improvement: Edit all widget labels in NSU configuration screen instead of widget options. (You might have to reconfigure some of your settings, sorry!)
155
+ * Added: Ability to add a sign-up form to your posts or pages using the shortcode `[newsletter-sign-up-form]`
156
+ * Some more restructuring of the code.
157
+
158
+ = 1.3.3 =
159
+ * Improvement: Users can now edit the widget labels for the email and name input fields.
160
+ * Improvement: You can now use some common HTML-codes in the widget text's
161
+ * Improvement: Linebreaks (\n) are now converted to HTML linebreaks in frontend.
162
+ * Fixed: Widget typo in the label for the email input field.
163
+
164
+ = 1.3.2 =
165
+ * Fixed bug: not loading the widget's default CSS after submitting option page.
166
+ * Fixed bug: 404 error after submitting the widget using API and 'subscribe with name'.
167
+ * Improvement: Added id's to the input fields in the widget.
168
+
169
+ = 1.3.1 =
170
+ * Fixed: parse error, unexpected T_FUNCTION for older versions of PHP which do not support anonymous functions.
171
+
172
+ = 1.3 =
173
+ * Added a widget: adds a sign-up form to your widget areas
174
+
175
+ = 1.2 =
176
+ * Fixed critical bug causing all custom form requests to fail (iow no sign-up request was made). Sorry!
177
+ * Fixed bug in backend: empty aweber list id field
178
+
179
+ = 1.1.2 =
180
+ * Re-added the predefined form values for Aweber, iContact and MailChimp
181
+ * Fixed PHPList fatal error
182
+ * Added additional data support when using YMLP API
183
+
184
+ = 1.1.1 =
185
+ * Fixed small bug for YMLP or MailChimp API users
186
+
187
+ = 1.1 =
188
+ * Changed the backend for different newsletters
189
+ * Added YMLP API support
190
+ * Added MailChimp API support
191
+ * Now uses the WordPress HTTP API
192
+ * Removed the ReadOnly attribute of prefilled fields
193
+ * Now works with MultiSite registration forms too
194
+ * Fixed inline CSS, now uses optional stylesheet
195
+ * Better documentation
196
+
197
+ = 1.0.6 =
198
+ * Fixed a missing argument error.
199
+
200
+ = 1.0.5 =
201
+ * Fixed some undefined indexes notices in the frontend
202
+
203
+ = 1.0.4 =
204
+ * Small change in seconds before timeout when making the POST request.
205
+ * Fixed bug with addititional data not being properly saved.
206
+
207
+ = 1.0.3 =
208
+ * Changed the plugin's backend structure
209
+ * Added the <a href="http://dannyvankooten.com">DannyvanKooten.com</a> dashboard widget.
210
+
211
+ = 1.0.2 =
212
+ * Added option to send custom data along with the sign-up request.
213
+
214
+ = 1.0.1 =
215
+ * Improved script and stylesheet loading - now only loads on NS options page.
216
+ * Added option to show checkbox at the BuddyPress register form
217
+
218
+ = 1.0 =
219
+ * Stable release
220
+ * Added CURL support
221
+ * Added option to show a checkbox at WP registration form
222
+ * Added option to subscribe commenters with their name
223
+
224
+ = 0.1 =
225
+ Beta release
screenshot-1.jpg ADDED
Binary file
screenshot-2.jpg ADDED
Binary file
screenshot-3.jpg ADDED
Binary file