Newsletter Sign-Up - Version 2.0.9

Version Description

  • Dec 5, 2019 =

  • Fix code styling to adhere to WordPress' coding standards

  • Add the plugin to GitHub: ibericode/newsletter-sign-up

  • Update tested WordPress version

Download this release

Release Info

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

Code changes from version 2.0.8 to 2.0.9

Files changed (85) hide show
  1. includes/NSU.php +0 -294
  2. includes/NSU_Admin.php +0 -325
  3. includes/NewsletterSignUpWidget.php +0 -91
  4. includes/class-nsu-admin.php +326 -0
  5. includes/{NSU_Checkbox.php → class-nsu-checkbox.php} +10 -13
  6. includes/{NSU_Form.php → class-nsu-form.php} +15 -17
  7. includes/class-nsu-widget.php +91 -0
  8. includes/class-nsu.php +371 -0
  9. includes/functions.php +10 -14
  10. includes/index.php +6 -6
  11. includes/views/checkbox-settings.php +62 -0
  12. includes/views/checkbox_settings.php +0 -62
  13. includes/views/config-helper.php +73 -0
  14. includes/views/config_helper.php +0 -73
  15. includes/views/dashboard.php +149 -113
  16. includes/views/form-settings.php +105 -0
  17. includes/views/form_settings.php +0 -90
  18. includes/views/index.php +6 -6
  19. includes/views/parts/index.php +6 -6
  20. includes/views/parts/navigation.php +5 -6
  21. includes/views/parts/rows-aweber.php +7 -3
  22. includes/views/parts/rows-mailchimp.php +59 -23
  23. includes/views/parts/rows-phplist.php +5 -3
  24. includes/views/parts/rows-ymlp.php +31 -11
  25. includes/views/parts/sidebar.php +21 -15
  26. newsletter-sign-up.php +36 -36
  27. phpcs.xml +49 -0
  28. readme.txt +20 -13
  29. trunk/LICENSE +339 -0
  30. trunk/assets/css/admin.css +21 -0
  31. trunk/assets/css/checkbox.css +6 -0
  32. trunk/assets/css/css.php +16 -0
  33. trunk/assets/css/form.css +14 -0
  34. trunk/assets/css/index.php +6 -0
  35. trunk/assets/img/close.png +0 -0
  36. trunk/assets/img/email-icon.png +0 -0
  37. trunk/assets/img/icon.png +0 -0
  38. trunk/assets/img/index.php +6 -0
  39. trunk/assets/img/mailchimp-for-wp-icon.png +0 -0
  40. trunk/assets/img/overlay.png +0 -0
  41. trunk/assets/img/recent-facebook-posts-icon.png +0 -0
  42. trunk/assets/img/rss-icon.png +0 -0
  43. trunk/assets/img/twitter-icon.png +0 -0
  44. trunk/assets/index.php +6 -0
  45. trunk/assets/js/admin.js +34 -0
  46. trunk/assets/js/index.php +6 -0
  47. trunk/includes/class-nsu-admin.php +330 -0
  48. trunk/includes/class-nsu-checkbox.php +242 -0
  49. trunk/includes/class-nsu-form.php +186 -0
  50. trunk/includes/class-nsu-widget.php +92 -0
  51. trunk/includes/class-nsu.php +371 -0
  52. trunk/includes/functions.php +23 -0
  53. trunk/includes/index.php +6 -0
  54. trunk/includes/views/checkbox-settings.php +62 -0
  55. trunk/includes/views/config-helper.php +73 -0
  56. trunk/includes/views/dashboard.php +149 -0
  57. trunk/includes/views/form-settings.php +105 -0
  58. trunk/includes/views/index.php +6 -0
  59. trunk/includes/views/parts/index.php +6 -0
  60. trunk/includes/views/parts/navigation.php +7 -0
  61. trunk/includes/views/parts/rows-aweber.php +12 -0
  62. trunk/includes/views/parts/rows-mailchimp.php +113 -0
  63. trunk/includes/views/parts/rows-phplist.php +12 -0
  64. trunk/includes/views/parts/rows-ymlp.php +57 -0
  65. trunk/includes/views/parts/sidebar.php +35 -0
  66. trunk/index.php +6 -0
  67. trunk/newsletter-sign-up.php +36 -0
  68. trunk/phpcs.xml +49 -0
  69. trunk/readme.txt +235 -0
  70. trunk/vendor/autoload.php +7 -0
  71. trunk/vendor/composer/ClassLoader.php +445 -0
  72. trunk/vendor/composer/LICENSE +21 -0
  73. trunk/vendor/composer/autoload_classmap.php +9 -0
  74. trunk/vendor/composer/autoload_namespaces.php +9 -0
  75. trunk/vendor/composer/autoload_psr4.php +9 -0
  76. trunk/vendor/composer/autoload_real.php +52 -0
  77. trunk/vendor/composer/autoload_static.php +15 -0
  78. vendor/autoload.php +7 -0
  79. vendor/composer/ClassLoader.php +445 -0
  80. vendor/composer/LICENSE +21 -0
  81. vendor/composer/autoload_classmap.php +9 -0
  82. vendor/composer/autoload_namespaces.php +9 -0
  83. vendor/composer/autoload_psr4.php +9 -0
  84. vendor/composer/autoload_real.php +52 -0
  85. vendor/composer/autoload_static.php +15 -0
includes/NSU.php DELETED
@@ -1,294 +0,0 @@
1
- <?php
2
-
3
- class NSU {
4
-
5
- private $options = array();
6
- private static $instance = null;
7
- private static $checkbox = null;
8
- private static $form = null;
9
-
10
- public function __construct() {
11
- self::$instance = $this;
12
-
13
- $opts = $this->get_options();
14
-
15
- self::checkbox();
16
- self::form();
17
-
18
- // widget hooks
19
- add_action( 'widgets_init', array( $this, 'register_widget' ) );
20
-
21
- // check if this is an AJAX request
22
- if ( !defined( "DOING_AJAX" ) || !DOING_AJAX ) {
23
-
24
- if ( is_admin() ) {
25
-
26
- // backend only
27
- require_once NSU_PLUGIN_DIR . '/includes/NSU_Admin.php';
28
- new NSU_Admin();
29
-
30
- } else {
31
-
32
- // frontend only
33
- require_once NSU_PLUGIN_DIR . '/includes/functions.php';
34
-
35
- add_action( 'wp_enqueue_scripts', array( $this, 'load_stylesheets' ) );
36
- add_action( 'login_enqueue_scripts', array( $this, 'load_stylesheets' ) );
37
-
38
- }
39
- }
40
- }
41
-
42
- public static function checkbox() {
43
- if ( !self::$checkbox ) {
44
- require_once NSU_PLUGIN_DIR .'/includes/NSU_Checkbox.php';
45
- self::$checkbox = new NSU_Checkbox;
46
- }
47
-
48
- return self::$checkbox;
49
- }
50
-
51
- public static function form() {
52
- if ( !self::$form ) {
53
- require_once NSU_PLUGIN_DIR . '/includes/NSU_Form.php';
54
- self::$form = new NSU_Form;
55
- }
56
-
57
- return self::$form;
58
- }
59
-
60
-
61
- /**
62
- * Initalize options
63
- *
64
- * @return array $options
65
- */
66
- public function get_options() {
67
- if ( empty( $this->options ) ) {
68
- $keys = array( 'form', 'mailinglist', 'checkbox' );
69
-
70
- $defaults = array(
71
- 'form' => array( 'load_form_css' => 0, 'submit_button' => 'Sign up',
72
- 'name_label' => 'Name:', 'email_label' => "Email:", 'email_default_value' => 'Your emailaddress..', 'name_required' => 0, 'name_default_value' => 'Your name..', 'wpautop' => 0,
73
- 'text_after_signup' => 'Thanks for signing up to our newsletter. Please check your inbox to confirm your email address.', 'redirect_to' => '',
74
- 'text_empty_name' => 'Please fill in the name field.', 'text_empty_email' => 'Please fill in the email field.', 'text_invalid_email' => 'Please enter a valid email address.'
75
- ),
76
- 'mailinglist' => array( 'provider' => '', 'use_api' => 0, 'subscribe_with_name' => 0, 'email_id' => '', 'name_id' => '', 'form_action' => '' ),
77
- 'checkbox' => array( 'text' => 'Sign me up for the newsletter', 'redirect_to' => '', 'precheck' => 0, 'cookie_hide' => 0, 'css_reset' => 0,
78
- 'add_to_registration_form' => 0, 'add_to_comment_form' => 1, 'add_to_buddypress_form' => 0,
79
- 'add_to_multisite_form' => 0, 'add_to_bbpress_forms' => 0
80
- )
81
- );
82
-
83
- foreach ( $keys as $key ) {
84
- if ( ( $option = get_option( 'nsu_'. $key ) ) == false ) {
85
- add_option( 'nsu_'. $key, $defaults[$key] );
86
- }
87
-
88
- $this->options[$key] = array_merge( $defaults[$key], (array) $option );
89
- }
90
-
91
- }
92
-
93
- return $this->options;
94
- }
95
-
96
- /**
97
- * Registers the Newsletter Sign-Up Widget
98
- */
99
- public function register_widget() {
100
- require_once NSU_PLUGIN_DIR . '/includes/NewsletterSignUpWidget.php';
101
- register_widget( 'NewsletterSignUpWidget' );
102
- }
103
-
104
- /**
105
- * Factory method for NewsletterSignUp class. Only instantiate once.
106
- *
107
- * @return NSU Instance of Newsletter Sign-Up class
108
- */
109
- public static function instance() {
110
- if ( !self::$instance ) self::$instance = new NSU();
111
-
112
- return self::$instance;
113
- }
114
-
115
- public function load_stylesheets() {
116
- $opts = $this->get_options();
117
-
118
- $stylesheets = array();
119
- if ( $opts['checkbox']['css_reset'] == 1 ) { $stylesheets['checkbox'] = 1; }
120
- if ( $opts['form']['load_form_css'] == 1 ) { $stylesheets['form'] = 1; }
121
-
122
- if ( !empty( $stylesheets ) ) {
123
- $stylesheet_url = add_query_arg( $stylesheets, plugins_url( "/assets/css/css.php", dirname( __FILE__ ) ) );
124
- wp_enqueue_style( 'newsletter-sign-up', $stylesheet_url );
125
- }
126
-
127
- }
128
-
129
-
130
-
131
-
132
- /**
133
- * Send the post data to the newsletter service, mimic form request
134
- */
135
- function send_post_data( $email, $name = '', $type = 'checkbox' ) {
136
- $opts = $this->options['mailinglist'];
137
-
138
- // when not using api and no form action has been given, abandon.
139
- if ( empty( $opts['use_api'] ) && empty( $opts['form_action'] ) ) return;
140
-
141
- /* Are we using API? */
142
- if ( $opts['use_api'] == 1 ) {
143
-
144
- switch ( $opts['provider'] ) {
145
-
146
- /* Send data using the YMLP API */
147
- case 'ymlp':
148
- $data = array(
149
- 'key' => $opts['ymlp_api_key'],
150
- 'username' => $opts['ymlp_username'],
151
- 'Email' => $email,
152
- 'GroupId' => $opts['ymlp_groupid'],
153
- 'output' => 'JSON'
154
- );
155
-
156
- $data = array_merge( $data, $this->add_additional_data( array( 'api' => 'ymlp' ) ) );
157
- $data = http_build_query( $data );
158
- $url = 'https://www.ymlp.com/api/Contacts.Add?'.$data;
159
-
160
- $result = wp_remote_post( $url );
161
-
162
- break;
163
-
164
- /* Send data using the MailChimp API */
165
- case 'mailchimp':
166
- $request = array(
167
- 'apikey' => $opts['mc_api_key'],
168
- 'id' => $opts['mc_list_id'],
169
- 'email_address' => $email,
170
- 'double_optin' => ( isset( $opts['mc_no_double_optin'] ) && $opts['mc_no_double_optin'] == 1 ) ? FALSE : TRUE,
171
- 'merge_vars' => array(
172
- 'OPTIN_TIME' => date( 'Y-M-D H:i:s' )
173
- )
174
- );
175
-
176
- if ( isset( $opts['mc_use_groupings'] ) && $opts['mc_use_groupings'] == 1 && !empty( $opts['mc_groupings_name'] ) ) {
177
- $request['merge_vars']['GROUPINGS'] = array(
178
- array( 'name' => $opts['mc_groupings_name'], 'groups' => $opts['mc_groupings_groups'] )
179
- );
180
- }
181
-
182
- /* Subscribe with name? If so, add name to merge_vars array */
183
- if ( isset( $opts['subscribe_with_name'] ) && $opts['subscribe_with_name'] == 1 ) {
184
- // Try to provide values for First and Lastname fields
185
- // These can be overridden, of just ignored by mailchimp.
186
- $strpos = strpos( $name, ' ' );
187
-
188
- $request['merge_vars']['FNAME'] = $name;
189
-
190
- if ( $strpos ) {
191
- $request['merge_vars']['FNAME'] = substr( $name, 0, $strpos );
192
- $request['merge_vars']['LNAME'] = substr( $name, $strpos );
193
- } else {
194
- $request['merge_vars']['FNAME'] = $name;
195
- }
196
-
197
- $request['merge_vars'][$opts['name_id']] = $name;
198
- }
199
-
200
- // Add any set additional data to merge_vars array
201
- $request['merge_vars'] = array_merge( $request['merge_vars'], $this->add_additional_data( array( 'email' => $email, 'name' => $name ) ) );
202
-
203
- $result = wp_remote_post(
204
- 'https://'.substr( $opts['mc_api_key'], -3 ).'.api.mailchimp.com/1.3/?output=php&method=listSubscribe',
205
- array( 'body' => json_encode( $request ) )
206
- );
207
-
208
- break;
209
-
210
- }
211
-
212
- } else {
213
- /* We are not using API, mimic a normal form request */
214
-
215
- $post_data = array(
216
- $opts['email_id'] => $email,
217
- );
218
-
219
- // Subscribe with name? Add to $post_data array.
220
- if ( $opts['subscribe_with_name'] == 1 ) $post_data[$opts['name_id']] = $name;
221
-
222
- // Add list specific data
223
- switch ( $opts['provider'] ) {
224
-
225
- case 'aweber':
226
- $post_data['listname'] = $opts['aweber_list_name'];
227
- $post_data['redirect'] = get_bloginfo( 'wpurl' );
228
- $post_data['meta_message'] = '1';
229
- $post_data['meta_required'] = 'email';
230
- break;
231
-
232
- case 'phplist':
233
- $post_data['list['.$opts['phplist_list_id'].']'] = 'signup';
234
- $post_data['subscribe'] = "Subscribe";
235
- $post_data["htmlemail"] = "1";
236
- $post_data['emailconfirm'] = $email;
237
- $post_data['makeconfirmed']='0';
238
- break;
239
-
240
- }
241
-
242
- $post_data = array_merge( $post_data, $this->add_additional_data( array_merge( array( 'email' => $email, 'name' => $name ), $post_data ) ) );
243
-
244
- $result = wp_remote_post( $opts['form_action'],
245
- array( 'body' => $post_data )
246
- );
247
-
248
- }
249
-
250
- // store a cookie, if preferred by site owner
251
- if ( $type == 'checkbox' && $this->options['checkbox']['cookie_hide'] == 1 ) @setcookie( 'ns_subscriber', TRUE, time() + 9999999 );
252
-
253
- // Check if we should redirect to a given page
254
- if ( $type == 'form' && strlen( $this->options['form']['redirect_to'] ) > 6 ) {
255
- wp_redirect( $this->options['form']['redirect_to'] );
256
- exit;
257
- } elseif ( $type == 'checkbox' && strlen( $this->options['checkbox']['redirect_to'] ) > 6 ) {
258
- wp_redirect( $this->options['checkbox']['redirect_to'] );
259
- exit;
260
- }
261
-
262
- return true;
263
- }
264
-
265
-
266
- /**
267
- * Returns array with additional data names as key, values as value.
268
- *
269
- * @param array $args, the normal form data (name, email, list variables)
270
- * @return array
271
- */
272
- function add_additional_data( $args = array() ) {
273
- $opts = $this->options['mailinglist'];
274
- $defaults = array(
275
- 'format' => 'array',
276
- 'api' => NULL
277
- );
278
-
279
- $args = wp_parse_args( $args, $defaults );
280
-
281
- $add_data = array();
282
- if ( isset( $opts['extra_data'] ) && is_array( $opts['extra_data'] ) ) {
283
- foreach ( $opts['extra_data'] as $key => $value ) {
284
- if ( $args['api'] == 'ymlp' ) $value['name'] = str_replace( 'YMP', 'Field', $value['name'] );
285
- $value['value'] = str_replace( "%%NAME%%", $args['name'], $value['value'] );
286
- $value['value'] = str_replace( "%%IP%%", $_SERVER['REMOTE_ADDR'], $value['value'] );
287
- $add_data[$value['name']] = $value['value'];
288
- }
289
- }
290
-
291
- return $add_data;
292
- }
293
-
294
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/NSU_Admin.php DELETED
@@ -1,325 +0,0 @@
1
- <?php
2
- if (!class_exists('NSU_Admin')) {
3
-
4
- class NSU_Admin {
5
-
6
- private $hook = 'newsletter-sign-up';
7
- private $longname = 'Newsletter Sign-Up';
8
- private $shortname = 'Newsletter Sign-Up';
9
- private $plugin_url = 'https://dannyvankooten.com/wordpress-plugins/newsletter-sign-up/';
10
- private $filename = 'newsletter-sign-up/newsletter-sign-up.php';
11
- private $accesslvl = 'manage_options';
12
- private $bp_active = FALSE;
13
- private $options = array();
14
-
15
- public function __construct() {
16
- $this->options = NSU::instance()->get_options();
17
-
18
- add_filter("plugin_action_links_{$this->filename}", array($this, 'add_settings_link'));
19
- add_action('admin_menu', array($this, 'add_option_page'));
20
- add_action('admin_init', array($this, 'settings_init'));
21
- add_action( 'admin_enqueue_scripts', array($this, 'load_css_and_js') );
22
- add_action('bp_include', array($this, 'set_bp_active'));
23
-
24
- if(isset($_GET['nsu-hide-mc4wp-notice'])) {
25
- add_option("nsu_hide_mc4wp_notice", true, false);
26
- } elseif($this->options['mailinglist']['provider'] == 'mailchimp' && get_option('nsu_hide_mc4wp_notice') == false) {
27
- add_action( 'admin_notices', array($this, 'notice_mailchimp_for_wp'));
28
- }
29
-
30
-
31
- }
32
-
33
- public function get_checkbox_compatible_plugins()
34
- {
35
-
36
- $checkbox_plugins = array(
37
- 'comment_form' => "Comment form",
38
- "registration_form" => "Registration form"
39
- );
40
- if(is_multisite()) { $checkbox_plugins['ms_form'] = "MultiSite forms"; }
41
- if(class_exists("BuddyPress")) $checkbox_plugins['bp_form'] = "BuddyPress registration";
42
- if(class_exists('bbPress')) $checkbox_plugins['bbpress_forms'] = "bbPress";
43
- return $checkbox_plugins;
44
- }
45
-
46
- public function notice_mailchimp_for_wp()
47
- {
48
- ?>
49
- <div class="updated">
50
- <p><strong>Newsletter Sign-Up Notice:</strong> You are using MailChimp, great! Please consider switching to our improved <a href="https://mc4wp.com/">MailChimp for WordPress</a> plugin.
51
- It can be downloaded from the WordPress repository <a href="https://wordpress.org/plugins/mailchimp-for-wp/">here</a>. | <a href="?nsu-hide-mc4wp-notice=1">Hide Notice</a></p>
52
- </div>
53
- <?php
54
- }
55
-
56
- public function load_css_and_js($hook)
57
- {
58
- if(!stripos($hook, $this->hook)) { return false; }
59
-
60
- wp_enqueue_style($this->hook, plugins_url('newsletter-sign-up/assets/css/admin.css'));
61
- wp_enqueue_script($this->hook, plugins_url('newsletter-sign-up/assets/js/admin.js'), array('jquery'));
62
- }
63
-
64
- /**
65
- * If buddypress is loaded, set buddypress_active to TRUE
66
- */
67
- public function set_bp_active() {
68
- $this->bp_active = TRUE;
69
- }
70
-
71
- /**
72
- * The default settings page
73
- */
74
- public function options_page_default() {
75
- $tab = 'mailinglist-settings';
76
- $opts = $this->options['mailinglist'];
77
-
78
- $viewed_mp = NULL;
79
- if (!empty($_GET['mp']))
80
- $viewed_mp = $_GET['mp'];
81
- elseif (empty($_GET['mp']) && isset($opts['provider']))
82
- $viewed_mp = $opts['provider'];
83
- if (!in_array($viewed_mp, array('mailchimp', 'icontact', 'aweber', 'phplist', 'ymlp', 'other')))
84
- $viewed_mp = NULL;
85
-
86
- // Fill in some predefined values if options not set or set for other newsletter service
87
- if ($opts['provider'] != $viewed_mp) {
88
- switch ($viewed_mp) {
89
-
90
- case 'mailchimp':
91
- if (empty($opts['email_id']))
92
- $opts['email_id'] = 'EMAIL';
93
- if (empty($opts['name_id']))
94
- $opts['name_id'] = 'NAME';
95
- break;
96
-
97
- case 'ymlp':
98
- if (empty($opts['email_id']))
99
- $opts['email_id'] = 'YMP0';
100
- break;
101
-
102
- case 'aweber':
103
- if (empty($opts['form_action']))
104
- $opts['form_action'] = 'http://www.aweber.com/scripts/addlead.pl';
105
- if (empty($opts['email_id']))
106
- $opts['email_id'] = 'email';
107
- if (empty($opts['name_id']))
108
- $opts['name_id'] = 'name';
109
- break;
110
-
111
- case 'icontact':
112
- if (empty($opts['email_id']))
113
- $opts['email_id'] = 'fields_email';
114
- break;
115
- }
116
- }
117
-
118
- require_once NSU_PLUGIN_DIR . '/includes/views/dashboard.php';
119
- }
120
-
121
- /**
122
- * The admin page for managing checkbox settings
123
- */
124
- public function options_page_checkbox_settings() {
125
- $tab = 'checkbox-settings';
126
- $opts = $this->options['checkbox'];
127
- require_once NSU_PLUGIN_DIR . '/includes/views/checkbox_settings.php';
128
- }
129
-
130
- /**
131
- * The admin page for managing form settings
132
- */
133
- public function options_page_form_settings() {
134
- $tab = 'form-settings';
135
- $opts = $this->options['form'];
136
- $opts['mailinglist'] = $this->options['mailinglist'];
137
- require_once NSU_PLUGIN_DIR . '/includes/views/form_settings.php';
138
- }
139
-
140
- /**
141
- * The page for the configuration extractor
142
- */
143
- public function options_page_config_helper() {
144
- $tab = 'config-helper';
145
-
146
- if ( isset( $_POST['form'] ) && ! empty( $_POST['form'] ) ) {
147
-
148
- $result = $this->extract_form_config( $_POST['form'] );
149
-
150
- }
151
-
152
- require_once NSU_PLUGIN_DIR . '/includes/views/config_helper.php';
153
- }
154
-
155
- private function extract_form_config( $form_html ) {
156
-
157
- // strip unneccessary tags
158
- $form = stripslashes( strip_tags($form_html, '<form><label><input><select><textarea><button>') );
159
-
160
- // set defaults
161
- $form_action = '';
162
- $email_name = 'Sorry, can\'t help you with this one.';
163
- $name_name = 'Sorry, can\'t help you with this one.';
164
- $additional_data = array();
165
-
166
- preg_match_all("'<(.*?)>'si", $form, $matches);
167
-
168
- if( is_array( $matches ) && isset($matches[0])) {
169
- $matches = $matches[0];
170
- $html = join('', $matches);
171
- } else {
172
- $html = $form;
173
- }
174
-
175
- // fake wrap in html and body tags
176
- $html = '<html><body>' . $html . '</body></html>';
177
-
178
- $doc = new DOMDocument();
179
- $doc->strictErrorChecking = false;
180
- $doc->loadHTML( $html);
181
-
182
- $xml = simplexml_import_dom($doc);
183
-
184
- if ( is_object( $xml ) ) {
185
- $form = $xml->body->form;
186
-
187
- if ($form) {
188
-
189
- $form_action = (isset($form['action'])) ? $form['action'] : 'Can\'t help you on this one..';
190
-
191
-
192
- if ( $form->input ) {
193
-
194
- /* Loop trough input fields */
195
- foreach ($form->input as $input) {
196
-
197
-
198
- // Check if this is a hidden field
199
- if ($input['type'] == 'hidden') {
200
- $additional_data[] = array($input['name'], $input['value']);
201
- // Check if this is the input field that is supposed to hold the EMAIL data
202
- } elseif (stripos($input['id'], 'email') !== FALSE || stripos($input['name'], 'email') !== FALSE) {
203
- $email_name = $input['name'];
204
-
205
- // Check if this is the input field that is supposed to hold the NAME data
206
- } elseif (stripos($input['id'], 'name') !== FALSE || stripos($input['name'], 'name') !== FALSE) {
207
- $name_name = $input['name'];
208
- }
209
-
210
- // remove input attributes
211
- unset($input['id']);
212
- unset($input['class']);
213
- unset($input['style']);
214
- unset($input['onfocus']);
215
- unset($input['onblur']);
216
- unset($input['size']);
217
- }
218
- }
219
-
220
- // remove form attributes
221
- unset($form['target']);
222
- unset($form['id']);
223
- unset($form['name']);
224
- unset($form['class']);
225
- unset($form['onsubmit']);
226
- unset($form['enctype']);
227
- }
228
-
229
- }
230
-
231
- $doc->removeChild($doc->firstChild);
232
- $doc->replaceChild($doc->firstChild->firstChild->firstChild, $doc->firstChild);
233
-
234
- $simpler_form = $doc->saveHTML();
235
-
236
- // add tabs for improved readability
237
- $simpler_form = str_replace(array('><', '<input'), array(">\n<", "\t<input"), $simpler_form);
238
-
239
-
240
- return array(
241
- 'simpler_form' => $simpler_form,
242
- 'form_action' => $form_action,
243
- 'email_name' => $email_name,
244
- 'name_name' => $name_name,
245
- 'additional_data' => $additional_data
246
- );
247
- }
248
-
249
-
250
- /**
251
- * Adds the different menu pages
252
- */
253
- public function add_option_page() {
254
- add_menu_page($this->longname, "Newsl. Sign-up", $this->accesslvl, $this->hook, array($this, 'options_page_default'), plugins_url('newsletter-sign-up/assets/img/icon.png'));
255
- add_submenu_page($this->hook, "Newsletter Sign-Up :: Mailinglist Settings", "List Settings", $this->accesslvl, $this->hook, array($this, 'options_page_default'));
256
- add_submenu_page($this->hook, "Newsletter Sign-Up :: Checkbox Settings", "Checkbox Settings", $this->accesslvl, $this->hook . '-checkbox-settings', array($this, 'options_page_checkbox_settings'));
257
- add_submenu_page($this->hook, "Newsletter Sign-Up :: Form Settings", "Form Settings", $this->accesslvl, $this->hook . '-form-settings', array($this, 'options_page_form_settings'));
258
- add_submenu_page($this->hook, "Newsletter Sign-Up :: Configuration Extractor", "Config Extractor", $this->accesslvl, $this->hook . '-config-helper', array($this, 'options_page_config_helper'));
259
- }
260
-
261
- /**
262
- * Adds the settings link on the plugin's overview page
263
- * @param array $links Array containing all the settings links for the various plugins.
264
- * @return array The new array containing all the settings links
265
- */
266
- public function add_settings_link($links) {
267
- $url = admin_url( 'admin.php?page='.$this->hook);
268
- $settings_link = '<a href="'. $url . '">Settings</a>';
269
- array_unshift($links, $settings_link);
270
- return $links;
271
- }
272
-
273
- /**
274
- * Registers the settings using WP Settings API.
275
- */
276
- public function settings_init() {
277
- register_setting('nsu_form_group', 'nsu_form', array($this, 'validate_form_options'));
278
- register_setting('nsu_mailinglist_group', 'nsu_mailinglist', array($this, 'validate_mailinglist_options'));
279
- register_setting('nsu_checkbox_group', 'nsu_checkbox', array($this, 'validate_checkbox_options'));
280
- }
281
-
282
- /**
283
- * Validate the submitted options
284
- * @param array $options The submitted options
285
- * @return array
286
- */
287
- public function validate_options($options) {
288
- return $options;
289
- }
290
-
291
- public function validate_form_options($options) {
292
-
293
- $options['text_after_signup'] = strip_tags($options['text_after_signup'], '<a><b><strong><i><img><em><br><p><ul><li><ol>');
294
-
295
- // redirect to url should start with http
296
- if(isset($options['redirect_to']) && substr($options['redirect_to'],0,4) != 'http') {
297
- $options['redirect_to'] = '';
298
- }
299
-
300
- $options['name_required'] = (isset($options['name_required'])) ? 1 : 0;
301
- $options['wpautop'] = (isset($options['wpautop'])) ? 1 : 0;
302
- $options['load_form_css'] = (isset($options['load_form_css'])) ? 1 : 0;
303
-
304
- return $options;
305
- }
306
-
307
- public function validate_mailinglist_options($options) {
308
- if (is_array($options['extra_data'])) {
309
- foreach ($options['extra_data'] as $key => $value) {
310
- if (empty($value['name']))
311
- unset($options['extra_data'][$key]);
312
- }
313
- }
314
-
315
- return $options;
316
- }
317
-
318
- public function validate_checkbox_options($options) {
319
- $options['add_to_comment_form'] = (isset($options['add_to_comment_form'])) ? 1 : 0;
320
- return $options;
321
- }
322
-
323
- }
324
-
325
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/NewsletterSignUpWidget.php DELETED
@@ -1,91 +0,0 @@
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' => __('Displays a newsletter sign-up form.'));
9
- $control_ops = array('width' => 400, 'height' => 350);
10
- parent::__construct(false, 'Newsletter Sign-Up', $widget_ops, $control_ops);
11
- }
12
-
13
- function widget($args, $instance) {
14
-
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
-
35
- NSU::form()->output_form(true);
36
-
37
- if(!empty($text_after_form)) {
38
- ?><div class="nsu-text-after-form"><?php
39
- $instance['filter'] ? _e(wpautop($text_after_form),'nsu-widget') : _e($text_after_form,'nsu-widget');
40
- ?></div><?php
41
- }
42
-
43
- echo $after_widget;
44
- }
45
-
46
- function update($new_instance, $old_instance) {
47
- $instance = $old_instance;
48
- $instance['title'] = strip_tags($new_instance['title']);
49
-
50
- if ( current_user_can('unfiltered_html') ) {
51
- $instance['text_before_form'] = $new_instance['text_before_form'];
52
- $instance['text_after_form'] = $new_instance['text_after_form'];
53
- } else {
54
- $instance['text_before_form'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text_before_form']) ) );
55
- $instance['text_after_form'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text_after_form']) ) );
56
- }
57
- $instance['filter'] = isset($new_instance['filter']);
58
-
59
- return $instance;
60
- }
61
-
62
- function form($instance) {
63
- $defaults = array( 'title' => 'Sign up for our newsletter!', 'text_before_form' => '', 'text_after_form' => '');
64
- $instance = wp_parse_args( (array) $instance, $defaults );
65
-
66
- extract($instance);
67
- $title = strip_tags($title);
68
-
69
- ?>
70
-
71
- <p>
72
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
73
- <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; ?>" />
74
- </p>
75
-
76
- <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>
77
- <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>
78
- <br />
79
- <label for="<?php echo $this->get_field_id('text_after_form'); ?>"><?php _e('Text to show after the form:'); ?></label>
80
- <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>
81
-
82
- <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>
83
-
84
- <p>
85
- Configure the sign-up form at the <a href="<?php admin_url( 'admin.php?page=newsletter-sign-up-form-settings'); ?>">Newsletter Sign-Up configuration page</a>.
86
- </p>
87
- <?php
88
- }
89
-
90
- }
91
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-nsu-admin.php ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class NSU_Admin {
4
+
5
+ private $hook = 'newsletter-sign-up';
6
+ private $longname = 'Newsletter Sign-Up';
7
+ private $filename = 'newsletter-sign-up/newsletter-sign-up.php';
8
+ private $accesslvl = 'manage_options';
9
+ private $bp_active = false;
10
+ private $options = array();
11
+
12
+ public function __construct() {
13
+ $this->options = NSU::instance()->get_options();
14
+
15
+ add_filter( "plugin_action_links_{$this->filename}", array( $this, 'add_settings_link' ) );
16
+ add_action( 'admin_menu', array( $this, 'add_option_page' ) );
17
+ add_action( 'admin_init', array( $this, 'settings_init' ) );
18
+ add_action( 'admin_enqueue_scripts', array( $this, 'load_css_and_js' ) );
19
+ add_action( 'bp_include', array( $this, 'set_bp_active' ) );
20
+
21
+ if ( isset( $_GET['nsu-hide-mc4wp-notice'] ) ) {
22
+ add_option( 'nsu_hide_mc4wp_notice', true, false );
23
+ } elseif ( $this->options['mailinglist']['provider'] == 'mailchimp' && get_option( 'nsu_hide_mc4wp_notice' ) == false ) {
24
+ add_action( 'admin_notices', array( $this, 'notice_mailchimp_for_wp' ) );
25
+ }
26
+
27
+ }
28
+
29
+ public function get_checkbox_compatible_plugins() {
30
+ $checkbox_plugins = array(
31
+ 'comment_form' => 'Comment form',
32
+ 'registration_form' => 'Registration form',
33
+ );
34
+ if ( is_multisite() ) {
35
+ $checkbox_plugins['ms_form'] = 'MultiSite forms'; }
36
+ if ( class_exists( 'BuddyPress' ) ) {
37
+ $checkbox_plugins['bp_form'] = 'BuddyPress registration';
38
+ }
39
+ if ( class_exists( 'bbPress' ) ) {
40
+ $checkbox_plugins['bbpress_forms'] = 'bbPress';
41
+ }
42
+ return $checkbox_plugins;
43
+ }
44
+
45
+ public function notice_mailchimp_for_wp() { ?>
46
+ <div class="updated">
47
+ <p><strong>Newsletter Sign-Up Notice:</strong> You are using Mailchimp, great! Please consider switching to our improved <a href="https://mc4wp.com/">Mailchimp for WordPress</a> plugin.
48
+ It can be downloaded from the WordPress repository <a href="https://wordpress.org/plugins/mailchimp-for-wp/">here</a>. | <a href="?nsu-hide-mc4wp-notice=1">Hide Notice</a></p>
49
+ </div>
50
+ <?php
51
+ }
52
+
53
+ public function load_css_and_js( $hook ) {
54
+ if ( ! stripos( $hook, $this->hook ) ) {
55
+ return false; }
56
+
57
+ wp_enqueue_style( $this->hook, plugins_url( 'newsletter-sign-up/assets/css/admin.css' ) );
58
+ wp_enqueue_script( $this->hook, plugins_url( 'newsletter-sign-up/assets/js/admin.js' ), array( 'jquery' ) );
59
+ }
60
+
61
+ /**
62
+ * If buddypress is loaded, set buddypress_active to TRUE
63
+ */
64
+ public function set_bp_active() {
65
+ $this->bp_active = true;
66
+ }
67
+
68
+ /**
69
+ * The default settings page
70
+ */
71
+ public function options_page_default() {
72
+ $tab = 'mailinglist-settings';
73
+ $opts = $this->options['mailinglist'];
74
+
75
+ $viewed_mp = null;
76
+ if ( ! empty( $_GET['mp'] ) ) {
77
+ $viewed_mp = $_GET['mp'];
78
+ } elseif ( empty( $_GET['mp'] ) && isset( $opts['provider'] ) ) {
79
+ $viewed_mp = $opts['provider'];
80
+ }
81
+ if ( ! in_array( $viewed_mp, array( 'mailchimp', 'icontact', 'aweber', 'phplist', 'ymlp', 'other' ) ) ) {
82
+ $viewed_mp = null;
83
+ }
84
+
85
+ // Fill in some predefined values if options not set or set for other newsletter service
86
+ if ( $opts['provider'] != $viewed_mp ) {
87
+ switch ( $viewed_mp ) {
88
+
89
+ case 'mailchimp':
90
+ if ( empty( $opts['email_id'] ) ) {
91
+ $opts['email_id'] = 'EMAIL';
92
+ }
93
+ if ( empty( $opts['name_id'] ) ) {
94
+ $opts['name_id'] = 'NAME';
95
+ }
96
+ break;
97
+
98
+ case 'ymlp':
99
+ if ( empty( $opts['email_id'] ) ) {
100
+ $opts['email_id'] = 'YMP0';
101
+ }
102
+ break;
103
+
104
+ case 'aweber':
105
+ if ( empty( $opts['form_action'] ) ) {
106
+ $opts['form_action'] = 'http://www.aweber.com/scripts/addlead.pl';
107
+ }
108
+ if ( empty( $opts['email_id'] ) ) {
109
+ $opts['email_id'] = 'email';
110
+ }
111
+ if ( empty( $opts['name_id'] ) ) {
112
+ $opts['name_id'] = 'name';
113
+ }
114
+ break;
115
+
116
+ case 'icontact':
117
+ if ( empty( $opts['email_id'] ) ) {
118
+ $opts['email_id'] = 'fields_email';
119
+ }
120
+ break;
121
+ }
122
+ }
123
+
124
+ require_once NSU_PLUGIN_DIR . '/includes/views/dashboard.php';
125
+ }
126
+
127
+ /**
128
+ * The admin page for managing checkbox settings
129
+ */
130
+ public function options_page_checkbox_settings() {
131
+ $tab = 'checkbox-settings';
132
+ $opts = $this->options['checkbox'];
133
+ require_once NSU_PLUGIN_DIR . '/includes/views/checkbox-settings.php';
134
+ }
135
+
136
+ /**
137
+ * The admin page for managing form settings
138
+ */
139
+ public function options_page_form_settings() {
140
+ $tab = 'form-settings';
141
+ $opts = $this->options['form'];
142
+ $opts['mailinglist'] = $this->options['mailinglist'];
143
+ require_once NSU_PLUGIN_DIR . '/includes/views/form-settings.php';
144
+ }
145
+
146
+ /**
147
+ * The page for the configuration extractor
148
+ */
149
+ public function options_page_config_helper() {
150
+ $tab = 'config-helper';
151
+
152
+ if ( isset( $_POST['form'] ) && ! empty( $_POST['form'] ) ) {
153
+
154
+ $result = $this->extract_form_config( $_POST['form'] );
155
+
156
+ }
157
+
158
+ require_once NSU_PLUGIN_DIR . '/includes/views/config-helper.php';
159
+ }
160
+
161
+ private function extract_form_config( $form_html ) {
162
+
163
+ // strip unneccessary tags
164
+ $form = stripslashes( strip_tags( $form_html, '<form><label><input><select><textarea><button>' ) );
165
+
166
+ // set defaults
167
+ $form_action = '';
168
+ $email_name = 'Sorry, can\'t help you with this one.';
169
+ $name_name = 'Sorry, can\'t help you with this one.';
170
+ $additional_data = array();
171
+
172
+ preg_match_all( "'<(.*?)>'si", $form, $matches );
173
+
174
+ if ( is_array( $matches ) && isset( $matches[0] ) ) {
175
+ $matches = $matches[0];
176
+ $html = join( '', $matches );
177
+ } else {
178
+ $html = $form;
179
+ }
180
+
181
+ // fake wrap in html and body tags
182
+ $html = '<html><body>' . $html . '</body></html>';
183
+
184
+ $doc = new DOMDocument();
185
+ $doc->strictErrorChecking = false;
186
+ $doc->loadHTML( $html );
187
+
188
+ $xml = simplexml_import_dom( $doc );
189
+
190
+ if ( is_object( $xml ) ) {
191
+ $form = $xml->body->form;
192
+
193
+ if ( $form ) {
194
+
195
+ $form_action = ( isset( $form['action'] ) ) ? $form['action'] : 'Can\'t help you on this one..';
196
+
197
+ if ( $form->input ) {
198
+
199
+ /* Loop trough input fields */
200
+ foreach ( $form->input as $input ) {
201
+
202
+ // Check if this is a hidden field
203
+ if ( $input['type'] == 'hidden' ) {
204
+ $additional_data[] = array( $input['name'], $input['value'] );
205
+ // Check if this is the input field that is supposed to hold the EMAIL data
206
+ } elseif ( stripos( $input['id'], 'email' ) !== false || stripos( $input['name'], 'email' ) !== false ) {
207
+ $email_name = $input['name'];
208
+
209
+ // Check if this is the input field that is supposed to hold the NAME data
210
+ } elseif ( stripos( $input['id'], 'name' ) !== false || stripos( $input['name'], 'name' ) !== false ) {
211
+ $name_name = $input['name'];
212
+ }
213
+
214
+ // remove input attributes
215
+ unset( $input['id'] );
216
+ unset( $input['class'] );
217
+ unset( $input['style'] );
218
+ unset( $input['onfocus'] );
219
+ unset( $input['onblur'] );
220
+ unset( $input['size'] );
221
+ }
222
+ }
223
+
224
+ // remove form attributes
225
+ unset( $form['target'] );
226
+ unset( $form['id'] );
227
+ unset( $form['name'] );
228
+ unset( $form['class'] );
229
+ unset( $form['onsubmit'] );
230
+ unset( $form['enctype'] );
231
+ }
232
+ }
233
+
234
+ $doc->removeChild( $doc->firstChild );
235
+ $doc->replaceChild( $doc->firstChild->firstChild->firstChild, $doc->firstChild );
236
+
237
+ $simpler_form = $doc->saveHTML();
238
+
239
+ // add tabs for improved readability
240
+ $simpler_form = str_replace( array( '><', '<input' ), array( ">\n<", "\t<input" ), $simpler_form );
241
+
242
+ return array(
243
+ 'simpler_form' => $simpler_form,
244
+ 'form_action' => $form_action,
245
+ 'email_name' => $email_name,
246
+ 'name_name' => $name_name,
247
+ 'additional_data' => $additional_data,
248
+ );
249
+ }
250
+
251
+
252
+ /**
253
+ * Adds the different menu pages
254
+ */
255
+ public function add_option_page() {
256
+ add_menu_page( $this->longname, 'Newsl. Sign-up', $this->accesslvl, $this->hook, array( $this, 'options_page_default' ), plugins_url( 'newsletter-sign-up/assets/img/icon.png' ) );
257
+ add_submenu_page( $this->hook, 'Newsletter Sign-Up :: Mailinglist Settings', 'List Settings', $this->accesslvl, $this->hook, array( $this, 'options_page_default' ) );
258
+ add_submenu_page( $this->hook, 'Newsletter Sign-Up :: Checkbox Settings', 'Checkbox Settings', $this->accesslvl, $this->hook . '-checkbox-settings', array( $this, 'options_page_checkbox_settings' ) );
259
+ add_submenu_page( $this->hook, 'Newsletter Sign-Up :: Form Settings', 'Form Settings', $this->accesslvl, $this->hook . '-form-settings', array( $this, 'options_page_form_settings' ) );
260
+ add_submenu_page( $this->hook, 'Newsletter Sign-Up :: Configuration Extractor', 'Config Extractor', $this->accesslvl, $this->hook . '-config-helper', array( $this, 'options_page_config_helper' ) );
261
+ }
262
+
263
+ /**
264
+ * Adds the settings link on the plugin's overview page
265
+ * @param array $links Array containing all the settings links for the various plugins.
266
+ * @return array The new array containing all the settings links
267
+ */
268
+ public function add_settings_link( $links ) {
269
+ $url = admin_url( 'admin.php?page=' . $this->hook );
270
+ $settings_link = '<a href="' . $url . '">Settings</a>';
271
+ array_unshift( $links, $settings_link );
272
+ return $links;
273
+ }
274
+
275
+ /**
276
+ * Registers the settings using WP Settings API.
277
+ */
278
+ public function settings_init() {
279
+ register_setting( 'nsu_form_group', 'nsu_form', array( $this, 'validate_form_options' ) );
280
+ register_setting( 'nsu_mailinglist_group', 'nsu_mailinglist', array( $this, 'validate_mailinglist_options' ) );
281
+ register_setting( 'nsu_checkbox_group', 'nsu_checkbox', array( $this, 'validate_checkbox_options' ) );
282
+ }
283
+
284
+ /**
285
+ * Validate the submitted options
286
+ * @param array $options The submitted options
287
+ * @return array
288
+ */
289
+ public function validate_options( $options ) {
290
+ return $options;
291
+ }
292
+
293
+ public function validate_form_options( $options ) {
294
+
295
+ $options['text_after_signup'] = strip_tags( $options['text_after_signup'], '<a><b><strong><i><img><em><br><p><ul><li><ol>' );
296
+
297
+ // redirect to url should start with http
298
+ if ( isset( $options['redirect_to'] ) && substr( $options['redirect_to'], 0, 4 ) != 'http' ) {
299
+ $options['redirect_to'] = '';
300
+ }
301
+
302
+ $options['name_required'] = ( isset( $options['name_required'] ) ) ? 1 : 0;
303
+ $options['wpautop'] = ( isset( $options['wpautop'] ) ) ? 1 : 0;
304
+ $options['load_form_css'] = ( isset( $options['load_form_css'] ) ) ? 1 : 0;
305
+
306
+ return $options;
307
+ }
308
+
309
+ public function validate_mailinglist_options( $options ) {
310
+ if ( is_array( $options['extra_data'] ) ) {
311
+ foreach ( $options['extra_data'] as $key => $value ) {
312
+ if ( empty( $value['name'] ) ) {
313
+ unset( $options['extra_data'][ $key ] );
314
+ }
315
+ }
316
+ }
317
+
318
+ return $options;
319
+ }
320
+
321
+ public function validate_checkbox_options( $options ) {
322
+ $options['add_to_comment_form'] = ( isset( $options['add_to_comment_form'] ) ) ? 1 : 0;
323
+ return $options;
324
+ }
325
+
326
+ }
includes/{NSU_Checkbox.php → class-nsu-checkbox.php} RENAMED
@@ -1,7 +1,6 @@
1
  <?php
2
 
3
  class NSU_Checkbox {
4
-
5
  /**
6
  * @var bool
7
  */
@@ -11,29 +10,27 @@ class NSU_Checkbox {
11
  private $options;
12
 
13
  public function __construct() {
14
-
15
  $options = NSU::instance()->get_options();
16
- $opts = $this->options = $options['checkbox'];
17
 
18
  // add hooks
19
-
20
- if ( $opts['add_to_comment_form'] == 1 ) {
21
  add_action( 'thesis_hook_after_comment_box', array( $this, 'output_checkbox' ), 20 );
22
  add_action( 'comment_form', array( $this, 'output_checkbox' ), 20 );
23
  add_action( 'comment_post', array( $this, 'grab_email_from_comment' ), 20, 2 );
24
  }
25
 
26
- if ( $opts['add_to_registration_form'] == 1 ) {
27
  add_action( 'register_form', array( $this, 'output_checkbox' ), 20 );
28
  add_action( 'register_post', array( $this, 'grab_email_from_wp_signup' ), 50 );
29
  }
30
 
31
- if ( $opts['add_to_buddypress_form'] == 1 ) {
32
  add_action( 'bp_before_registration_submit_buttons', array( $this, 'output_checkbox' ), 20 );
33
  add_action( 'bp_complete_signup', array( $this, 'grab_email_from_wp_signup' ), 20 );
34
  }
35
 
36
- if ( $opts['add_to_multisite_form'] == 1 ) {
37
  add_action( 'signup_extra_fields', array( $this, 'output_checkbox' ), 20 );
38
  add_action( 'signup_blogform', array( $this, 'add_hidden_checkbox' ), 20 );
39
  add_filter( 'add_signup_meta', array( $this, 'add_checkbox_to_usermeta' ) );
@@ -42,7 +39,7 @@ class NSU_Checkbox {
42
  }
43
 
44
  /* bbPress actions */
45
- if ( $opts['add_to_bbpress_forms'] ) {
46
  add_action( 'bbp_theme_after_topic_form_subscriptions', array( $this, 'output_checkbox' ), 10 );
47
  add_action( 'bbp_theme_after_reply_form_subscription', array( $this, 'output_checkbox' ), 10 );
48
  add_action( 'bbp_theme_anonymous_form_extras_bottom', array( $this, 'output_checkbox' ), 10 );
@@ -73,11 +70,11 @@ class NSU_Checkbox {
73
  }
74
 
75
  ?>
76
- <!-- Checkbox by Newsletter Sign-Up Checkbox v<?php echo NSU_VERSION_NUMBER; ?> - https://wordpress.org/plugins/newsletter-sign-up/ -->
77
  <p id="nsu-checkbox">
78
  <label for="nsu-checkbox-input" id="nsu-checkbox-label">
79
  <input value="1" id="nsu-checkbox-input" type="checkbox" name="newsletter-sign-up-do" <?php checked( $opts['precheck'], 1 ); ?> />
80
- <?php _e( $opts['text'], 'newsletter-sign-up' ); ?>
81
  </label>
82
  </p>
83
  <!-- / Newsletter Sign-Up -->
@@ -95,7 +92,7 @@ class NSU_Checkbox {
95
  function add_hidden_checkbox() {
96
  ?>
97
  <input type="hidden" name="newsletter-sign-up-do" value="<?php echo ( isset( $_POST['newsletter-sign-up-do'] ) ) ? 1 : 0; ?>" />
98
- <?php
99
  }
100
 
101
  /**
@@ -242,4 +239,4 @@ class NSU_Checkbox {
242
  return $this->subscribe_from_bbpress( $anonymous_data, $reply_author );
243
  }
244
 
245
- }
1
  <?php
2
 
3
  class NSU_Checkbox {
 
4
  /**
5
  * @var bool
6
  */
10
  private $options;
11
 
12
  public function __construct() {
 
13
  $options = NSU::instance()->get_options();
14
+ $this->options = $options['checkbox'];
15
 
16
  // add hooks
17
+ if ( $this->options['add_to_comment_form'] == 1 ) {
 
18
  add_action( 'thesis_hook_after_comment_box', array( $this, 'output_checkbox' ), 20 );
19
  add_action( 'comment_form', array( $this, 'output_checkbox' ), 20 );
20
  add_action( 'comment_post', array( $this, 'grab_email_from_comment' ), 20, 2 );
21
  }
22
 
23
+ if ( $this->options['add_to_registration_form'] == 1 ) {
24
  add_action( 'register_form', array( $this, 'output_checkbox' ), 20 );
25
  add_action( 'register_post', array( $this, 'grab_email_from_wp_signup' ), 50 );
26
  }
27
 
28
+ if ( $this->options['add_to_buddypress_form'] == 1 ) {
29
  add_action( 'bp_before_registration_submit_buttons', array( $this, 'output_checkbox' ), 20 );
30
  add_action( 'bp_complete_signup', array( $this, 'grab_email_from_wp_signup' ), 20 );
31
  }
32
 
33
+ if ( $this->options['add_to_multisite_form'] == 1 ) {
34
  add_action( 'signup_extra_fields', array( $this, 'output_checkbox' ), 20 );
35
  add_action( 'signup_blogform', array( $this, 'add_hidden_checkbox' ), 20 );
36
  add_filter( 'add_signup_meta', array( $this, 'add_checkbox_to_usermeta' ) );
39
  }
40
 
41
  /* bbPress actions */
42
+ if ( $this->options['add_to_bbpress_forms'] ) {
43
  add_action( 'bbp_theme_after_topic_form_subscriptions', array( $this, 'output_checkbox' ), 10 );
44
  add_action( 'bbp_theme_after_reply_form_subscription', array( $this, 'output_checkbox' ), 10 );
45
  add_action( 'bbp_theme_anonymous_form_extras_bottom', array( $this, 'output_checkbox' ), 10 );
70
  }
71
 
72
  ?>
73
+ <!-- Checkbox by Newsletter Sign-Up Checkbox v<?php echo NSU_VERSION; ?> - https://wordpress.org/plugins/newsletter-sign-up/ -->
74
  <p id="nsu-checkbox">
75
  <label for="nsu-checkbox-input" id="nsu-checkbox-label">
76
  <input value="1" id="nsu-checkbox-input" type="checkbox" name="newsletter-sign-up-do" <?php checked( $opts['precheck'], 1 ); ?> />
77
+ <?php echo $opts['text']; ?>
78
  </label>
79
  </p>
80
  <!-- / Newsletter Sign-Up -->
92
  function add_hidden_checkbox() {
93
  ?>
94
  <input type="hidden" name="newsletter-sign-up-do" value="<?php echo ( isset( $_POST['newsletter-sign-up-do'] ) ) ? 1 : 0; ?>" />
95
+ <?php
96
  }
97
 
98
  /**
239
  return $this->subscribe_from_bbpress( $anonymous_data, $reply_author );
240
  }
241
 
242
+ }
includes/{NSU_Form.php → class-nsu-form.php} RENAMED
@@ -58,7 +58,6 @@ class NSU_Form {
58
  return true;
59
  }
60
 
61
-
62
  return false;
63
  }
64
 
@@ -87,7 +86,7 @@ class NSU_Form {
87
  $opts = NSU::instance()->get_options();
88
 
89
  $additional_fields = '';
90
- $output = "\n<!-- Form by Newsletter Sign-Up v" . NSU_VERSION_NUMBER . " - https://wordpress.org/plugins/newsletter-sign-up/ -->\n";
91
 
92
  $formno = $this->number_of_forms ++;
93
 
@@ -108,7 +107,6 @@ class NSU_Form {
108
  if ( ! empty( $opts['mailinglist']['name_id'] ) ) {
109
  $name_id = $opts['mailinglist']['name_id'];
110
  }
111
-
112
  }
113
 
114
  /* Set up additional fields */
@@ -120,13 +118,13 @@ class NSU_Form {
120
  continue;
121
  }
122
 
123
- $ed['value'] = str_replace( "%%IP%%", $_SERVER['REMOTE_ADDR'], $ed['value'] );
124
  $additional_fields .= sprintf( '<input type="hidden" name="%s" value="%s" />', esc_attr( $ed['name'] ), esc_attr( $ed['value'] ) );
125
  }
126
  }
127
 
128
- $email_label = __( $opts['form']['email_label'], 'nsu' );
129
- $name_label = __( $opts['form']['name_label'], 'nsu' );
130
 
131
  $email_type = 'email';
132
  $email_atts = 'placeholder="' . esc_attr( $opts['form']['email_default_value'] ) . '" required';
@@ -140,38 +138,38 @@ class NSU_Form {
140
 
141
  $text_after_signup = $opts['form']['text_after_signup'];
142
  $text_after_signup = ( $opts['form']['wpautop'] == 1 ) ? wpautop( wptexturize( $text_after_signup ) ) : $text_after_signup;
143
-
144
  // check if form was not submitted or contains error
145
  if ( ! isset( $_POST['nsu_submit'] ) || count( $errors ) > 0 ) {
146
 
147
- $output .= '<form class="nsu-form" id="nsu-form-' . esc_attr( $formno ) .'" action="' . esc_attr( $form_action ) . '" method="post">';
148
 
149
  if ( $opts['mailinglist']['subscribe_with_name'] == 1 ) {
150
- $output .= '<p><label for="nsu-name-'. esc_attr( $formno ) . '">'. esc_html( $name_label ) . '</label>';
151
- $output .= '<input class="nsu-field" id="nsu-name-"' . $formno .'" type="text" name="'. esc_attr( $name_id ) .'" ' . $name_atts;
152
 
153
- $output .= "/>";
154
 
155
  if ( isset( $errors['name-field'] ) ) {
156
  $output .= '<span class="nsu-error error notice">' . $errors['name-field'] . '</span>';
157
  }
158
- $output .= "</p>";
159
  }
160
 
161
  $output .= "<p><label for=\"nsu-email-$formno\">$email_label</label><input class=\"nsu-field\" id=\"nsu-email-$formno\" type=\"$email_type\" name=\"$email_id\" $email_atts ";
162
- $output .= "/>";
163
  if ( isset( $errors['email-field'] ) ) {
164
  $output .= '<span class="nsu-error error notice">' . $errors['email-field'] . '</span>';
165
  }
166
- $output .= "</p>";
167
  $output .= $additional_fields;
168
  $output .= '<textarea name="nsu_robocop" style="display: none;"></textarea>';
169
  $output .= sprintf( '<p><input type="submit" id="nsu-submit-%s" class="nsu-submit" name="nsu_submit" value="%s" /></p>', $formno, esc_attr( $submit_button ) );
170
- $output .= "</form>";
171
 
172
  } else { // form has been submitted
173
 
174
- $output .= "<p id=\"nsu-signed-up-$formno\" class=\"nsu-signed-up\">" . ( $text_after_signup ) . "</p>";
175
 
176
  }
177
 
@@ -185,4 +183,4 @@ class NSU_Form {
185
 
186
  }
187
 
188
- }
58
  return true;
59
  }
60
 
 
61
  return false;
62
  }
63
 
86
  $opts = NSU::instance()->get_options();
87
 
88
  $additional_fields = '';
89
+ $output = "\n<!-- Form by Newsletter Sign-Up v" . NSU_VERSION . " - https://wordpress.org/plugins/newsletter-sign-up/ -->\n";
90
 
91
  $formno = $this->number_of_forms ++;
92
 
107
  if ( ! empty( $opts['mailinglist']['name_id'] ) ) {
108
  $name_id = $opts['mailinglist']['name_id'];
109
  }
 
110
  }
111
 
112
  /* Set up additional fields */
118
  continue;
119
  }
120
 
121
+ $ed['value'] = str_replace( '%%IP%%', $_SERVER['REMOTE_ADDR'], $ed['value'] );
122
  $additional_fields .= sprintf( '<input type="hidden" name="%s" value="%s" />', esc_attr( $ed['name'] ), esc_attr( $ed['value'] ) );
123
  }
124
  }
125
 
126
+ $email_label = $opts['form']['email_label'];
127
+ $name_label = $opts['form']['name_label'];
128
 
129
  $email_type = 'email';
130
  $email_atts = 'placeholder="' . esc_attr( $opts['form']['email_default_value'] ) . '" required';
138
 
139
  $text_after_signup = $opts['form']['text_after_signup'];
140
  $text_after_signup = ( $opts['form']['wpautop'] == 1 ) ? wpautop( wptexturize( $text_after_signup ) ) : $text_after_signup;
141
+
142
  // check if form was not submitted or contains error
143
  if ( ! isset( $_POST['nsu_submit'] ) || count( $errors ) > 0 ) {
144
 
145
+ $output .= '<form class="nsu-form" id="nsu-form-' . esc_attr( $formno ) . '" action="' . esc_attr( $form_action ) . '" method="post">';
146
 
147
  if ( $opts['mailinglist']['subscribe_with_name'] == 1 ) {
148
+ $output .= '<p><label for="nsu-name-' . esc_attr( $formno ) . '">' . esc_html( $name_label ) . '</label>';
149
+ $output .= '<input class="nsu-field" id="nsu-name-"' . $formno . '" type="text" name="' . esc_attr( $name_id ) . '" ' . $name_atts;
150
 
151
+ $output .= '/>';
152
 
153
  if ( isset( $errors['name-field'] ) ) {
154
  $output .= '<span class="nsu-error error notice">' . $errors['name-field'] . '</span>';
155
  }
156
+ $output .= '</p>';
157
  }
158
 
159
  $output .= "<p><label for=\"nsu-email-$formno\">$email_label</label><input class=\"nsu-field\" id=\"nsu-email-$formno\" type=\"$email_type\" name=\"$email_id\" $email_atts ";
160
+ $output .= '/>';
161
  if ( isset( $errors['email-field'] ) ) {
162
  $output .= '<span class="nsu-error error notice">' . $errors['email-field'] . '</span>';
163
  }
164
+ $output .= '</p>';
165
  $output .= $additional_fields;
166
  $output .= '<textarea name="nsu_robocop" style="display: none;"></textarea>';
167
  $output .= sprintf( '<p><input type="submit" id="nsu-submit-%s" class="nsu-submit" name="nsu_submit" value="%s" /></p>', $formno, esc_attr( $submit_button ) );
168
+ $output .= '</form>';
169
 
170
  } else { // form has been submitted
171
 
172
+ $output .= "<p id=\"nsu-signed-up-$formno\" class=\"nsu-signed-up\">" . ( $text_after_signup ) . '</p>';
173
 
174
  }
175
 
183
 
184
  }
185
 
186
+ }
includes/class-nsu-widget.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class NSU_Widget extends WP_Widget {
4
+
5
+ function __construct() {
6
+ $widget_ops = array(
7
+ 'classname' => 'nsu_widget',
8
+ 'description' => __( 'Displays a newsletter sign-up form.', 'newsletter-sign-up' ),
9
+ );
10
+ $control_ops = array(
11
+ 'width' => 400,
12
+ 'height' => 350,
13
+ );
14
+ parent::__construct( false, 'Newsletter Sign-Up', $widget_ops, $control_ops );
15
+ }
16
+
17
+ function widget( $args, $instance ) {
18
+ /* Provide some defaults */
19
+ $defaults = array(
20
+ 'title' => 'Sign up for our newsletter!',
21
+ 'text_before_form' => '',
22
+ 'text_after_form' => '',
23
+ );
24
+ $instance = array_merge( $defaults, (array) $instance );
25
+
26
+ $title = apply_filters( 'widget_title', $instance['title'] );
27
+
28
+ echo $args['before_widget'];
29
+ echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
30
+
31
+ if ( ! empty( $instance['text_before_form'] ) ) {
32
+ echo '<div class="nsu-text-before-form">';
33
+ echo $instance['filter'] ? wpautop( $instance['text_before_form'] ) : $instance['text_before_form'];
34
+ echo '</div>';
35
+ }
36
+
37
+ NSU::form()->output_form( true );
38
+
39
+ if ( ! empty( $instance['text_after_form'] ) ) {
40
+ echo '<div class="nsu-text-after-form">';
41
+ echo $instance['filter'] ? wpautop( $instance['text_after_form'] ) : $instance['text_after_form'];
42
+ echo '</div>';
43
+ }
44
+
45
+ echo $args['after_widget'];
46
+ }
47
+
48
+ function update( $new_instance, $old_instance ) {
49
+ $instance = $old_instance;
50
+ $instance['title'] = strip_tags( $new_instance['title'] );
51
+
52
+ if ( current_user_can( 'unfiltered_html' ) ) {
53
+ $instance['text_before_form'] = $new_instance['text_before_form'];
54
+ $instance['text_after_form'] = $new_instance['text_after_form'];
55
+ } else {
56
+ $instance['text_before_form'] = stripslashes( wp_filter_post_kses( addslashes( $new_instance['text_before_form'] ) ) );
57
+ $instance['text_after_form'] = stripslashes( wp_filter_post_kses( addslashes( $new_instance['text_after_form'] ) ) );
58
+ }
59
+ $instance['filter'] = isset( $new_instance['filter'] );
60
+
61
+ return $instance;
62
+ }
63
+
64
+ function form( $instance = array() ) {
65
+ $defaults = array(
66
+ 'title' => 'Sign up for our newsletter!',
67
+ 'text_before_form' => '',
68
+ 'text_after_form' => '',
69
+ );
70
+ $instance = array_merge( $defaults, (array) $instance );
71
+ ?>
72
+ <p>
73
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'newsletter-sign-up' ); ?></label>
74
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
75
+ </p>
76
+
77
+ <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', 'newsletter-sign-up' ); ?></label>
78
+ <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 esc_attr( $instance['text_before_form'] ); ?></textarea>
79
+ <br />
80
+ <label for="<?php echo $this->get_field_id( 'text_after_form' ); ?>"><?php _e( 'Text to show after the form', 'newsletter-sign-up' ); ?></label>
81
+ <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 esc_attr( $instance['text_after_form'] ); ?></textarea>
82
+
83
+ <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', 'newsletter-sign-up' ); ?></label></p>
84
+
85
+ <p>
86
+ Configure the sign-up form at the <a href="<?php admin_url( 'admin.php?page=newsletter-sign-up-form-settings' ); ?>">Newsletter Sign-Up configuration page</a>.
87
+ </p>
88
+ <?php
89
+ }
90
+
91
+ }
includes/class-nsu.php ADDED
@@ -0,0 +1,371 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class NSU {
4
+
5
+ /**
6
+ * @var array
7
+ */
8
+ private $options = array();
9
+
10
+ /**
11
+ * @var NSU|null
12
+ */
13
+ private static $instance = null;
14
+
15
+ /**
16
+ * @var NSU_Checkbox|null
17
+ */
18
+ private static $checkbox = null;
19
+
20
+ /**
21
+ * @var NSU_Form|null
22
+ */
23
+ private static $form = null;
24
+
25
+ public function __construct() {
26
+ self::$instance = $this;
27
+
28
+ self::checkbox();
29
+ self::form();
30
+
31
+ // widget hooks
32
+ add_action( 'widgets_init', array( $this, 'register_widget' ) );
33
+
34
+ // check if this is an AJAX request
35
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
36
+
37
+ if ( is_admin() ) {
38
+
39
+ // backend only
40
+ require_once NSU_PLUGIN_DIR . '/includes/class-nsu-admin.php';
41
+ new NSU_Admin();
42
+
43
+ } else {
44
+
45
+ // frontend only
46
+ require_once NSU_PLUGIN_DIR . '/includes/functions.php';
47
+
48
+ add_action( 'wp_enqueue_scripts', array( $this, 'load_stylesheets' ) );
49
+ add_action( 'login_enqueue_scripts', array( $this, 'load_stylesheets' ) );
50
+
51
+ }
52
+ }
53
+ }
54
+
55
+ public static function checkbox() {
56
+ if ( ! self::$checkbox ) {
57
+ require_once NSU_PLUGIN_DIR . '/includes/class-nsu-checkbox.php';
58
+ self::$checkbox = new NSU_Checkbox;
59
+ }
60
+
61
+ return self::$checkbox;
62
+ }
63
+
64
+ public static function form() {
65
+ if ( ! self::$form ) {
66
+ require_once NSU_PLUGIN_DIR . '/includes/class-nsu-form.php';
67
+ self::$form = new NSU_Form;
68
+ }
69
+
70
+ return self::$form;
71
+ }
72
+
73
+
74
+ /**
75
+ * Initalize options
76
+ *
77
+ * @return array $options
78
+ */
79
+ public function get_options() {
80
+ if ( ! empty( $this->options ) ) {
81
+ return $this->options;
82
+ }
83
+
84
+ $defaults = array(
85
+ 'form' => array(
86
+ 'load_form_css' => 0,
87
+ 'submit_button' => 'Sign up',
88
+ 'name_label' => 'Name',
89
+ 'email_label' => 'Email',
90
+ 'email_default_value' => 'Your email address',
91
+ 'name_required' => 0,
92
+ 'name_default_value' => 'Your name',
93
+ 'wpautop' => 0,
94
+ 'text_after_signup' => 'Thanks for signing up to our newsletter. Please check your inbox to confirm your email address.',
95
+ 'redirect_to' => '',
96
+ 'text_empty_name' => 'Please fill in the name field.',
97
+ 'text_empty_email' => 'Please fill in the email field.',
98
+ 'text_invalid_email' => 'Please enter a valid email address.',
99
+ ),
100
+ 'mailinglist' => array(
101
+ 'provider' => '',
102
+ 'use_api' => 0,
103
+ 'subscribe_with_name' => 0,
104
+ 'email_id' => '',
105
+ 'name_id' => '',
106
+ 'form_action' => '',
107
+ ),
108
+ 'checkbox' => array(
109
+ 'text' => 'Sign me up for the newsletter',
110
+ 'redirect_to' => '',
111
+ 'precheck' => 0,
112
+ 'cookie_hide' => 0,
113
+ 'css_reset' => 0,
114
+ 'add_to_registration_form' => 0,
115
+ 'add_to_comment_form' => 1,
116
+ 'add_to_buddypress_form' => 0,
117
+ 'add_to_multisite_form' => 0,
118
+ 'add_to_bbpress_forms' => 0,
119
+ ),
120
+ );
121
+
122
+ foreach ( $defaults as $key => $value ) {
123
+ $option = get_option( 'nsu_' . $key, array() );
124
+ if ( $option === array() ) {
125
+ add_option( 'nsu_' . $key, $value );
126
+ }
127
+
128
+ $this->options[ $key ] = array_merge( $value, (array) $option );
129
+ }
130
+
131
+ return $this->options;
132
+ }
133
+
134
+ /**
135
+ * Registers the Newsletter Sign-Up Widget
136
+ */
137
+ public function register_widget() {
138
+ require_once NSU_PLUGIN_DIR . '/includes/class-nsu-widget.php';
139
+ register_widget( 'NSU_Widget' );
140
+ }
141
+
142
+ /**
143
+ * Factory method for NewsletterSignUp class. Only instantiate once.
144
+ *
145
+ * @return NSU Instance of Newsletter Sign-Up class
146
+ */
147
+ public static function instance() {
148
+ if ( null === self::$instance ) {
149
+ self::$instance = new NSU();
150
+ }
151
+
152
+ return self::$instance;
153
+ }
154
+
155
+ public function load_stylesheets() {
156
+ $opts = $this->get_options();
157
+
158
+ $stylesheets = array();
159
+ if ( (int) $opts['checkbox']['css_reset'] === 1 ) {
160
+ $stylesheets['checkbox'] = 1;
161
+ }
162
+
163
+ if ( (int) $opts['form']['load_form_css'] === 1 ) {
164
+ $stylesheets['form'] = 1;
165
+ }
166
+
167
+ if ( ! empty( $stylesheets ) ) {
168
+ $stylesheet_url = add_query_arg( $stylesheets, plugins_url( '/assets/css/css.php', dirname( __FILE__ ) ) );
169
+ wp_enqueue_style( 'newsletter-sign-up', $stylesheet_url );
170
+ }
171
+
172
+ }
173
+
174
+ /**
175
+ * Send the post data to the newsletter service, mimic form request
176
+ * @param string $email
177
+ * @param string $name
178
+ * @param string $type
179
+ * @return void
180
+ */
181
+ function send_post_data( $email, $name = '', $type = 'checkbox' ) {
182
+ $opts = $this->options['mailinglist'];
183
+
184
+ // when not using api and no form action has been given, abandon.
185
+ if ( empty( $opts['use_api'] ) && empty( $opts['form_action'] ) ) {
186
+ return;
187
+ }
188
+
189
+ /* Are we using API? */
190
+ if ( $opts['use_api'] == 1 ) {
191
+
192
+ switch ( $opts['provider'] ) {
193
+
194
+ /* Send data using the YMLP API */
195
+ case 'ymlp':
196
+ $data = array(
197
+ 'key' => $opts['ymlp_api_key'],
198
+ 'username' => $opts['ymlp_username'],
199
+ 'Email' => $email,
200
+ 'GroupId' => $opts['ymlp_groupid'],
201
+ 'output' => 'JSON',
202
+ );
203
+
204
+ $data = array_merge( $data, $this->add_additional_data( array( 'api' => 'ymlp' ) ) );
205
+ $data = http_build_query( $data );
206
+ $url = 'https://www.ymlp.com/api/Contacts.Add?' . $data;
207
+
208
+ $result = wp_remote_post( $url );
209
+
210
+ break;
211
+
212
+ /* Send data using the Mailchimp API */
213
+ case 'mailchimp':
214
+ $request = array(
215
+ 'apikey' => $opts['mc_api_key'],
216
+ 'id' => $opts['mc_list_id'],
217
+ 'email_address' => $email,
218
+ 'double_optin' => ( isset( $opts['mc_no_double_optin'] ) && $opts['mc_no_double_optin'] == 1 ) ? false : true,
219
+ 'merge_vars' => array(
220
+ 'OPTIN_TIME' => gmdate( 'Y-M-D H:i:s' ),
221
+ ),
222
+ );
223
+
224
+ if ( isset( $opts['mc_use_groupings'] ) && $opts['mc_use_groupings'] == 1 && ! empty( $opts['mc_groupings_name'] ) ) {
225
+ $request['merge_vars']['GROUPINGS'] = array(
226
+ array(
227
+ 'name' => $opts['mc_groupings_name'],
228
+ 'groups' => $opts['mc_groupings_groups'],
229
+ ),
230
+ );
231
+ }
232
+
233
+ /* Subscribe with name? If so, add name to merge_vars array */
234
+ if ( isset( $opts['subscribe_with_name'] ) && $opts['subscribe_with_name'] == 1 ) {
235
+ // Try to provide values for First and Lastname fields
236
+ // These can be overridden, of just ignored by mailchimp.
237
+ $strpos = strpos( $name, ' ' );
238
+
239
+ $request['merge_vars']['FNAME'] = $name;
240
+
241
+ if ( $strpos ) {
242
+ $request['merge_vars']['FNAME'] = substr( $name, 0, $strpos );
243
+ $request['merge_vars']['LNAME'] = substr( $name, $strpos );
244
+ } else {
245
+ $request['merge_vars']['FNAME'] = $name;
246
+ }
247
+
248
+ $request['merge_vars'][ $opts['name_id'] ] = $name;
249
+ }
250
+
251
+ // Add any set additional data to merge_vars array
252
+ $request['merge_vars'] = array_merge(
253
+ $request['merge_vars'],
254
+ $this->add_additional_data(
255
+ array(
256
+ 'email' => $email,
257
+ 'name' => $name,
258
+ )
259
+ )
260
+ );
261
+
262
+ wp_remote_post(
263
+ 'https://' . substr( $opts['mc_api_key'], -3 ) . '.api.mailchimp.com/1.3/?output=php&method=listSubscribe',
264
+ array( 'body' => json_encode( $request ) )
265
+ );
266
+
267
+ break;
268
+
269
+ }
270
+ } else {
271
+ /* We are not using API, mimic a normal form request */
272
+
273
+ $post_data = array(
274
+ $opts['email_id'] => $email,
275
+ );
276
+
277
+ // Subscribe with name? Add to $post_data array.
278
+ if ( $opts['subscribe_with_name'] == 1 ) {
279
+ $post_data[ $opts['name_id'] ] = $name;
280
+ }
281
+
282
+ // Add list specific data
283
+ switch ( $opts['provider'] ) {
284
+
285
+ case 'aweber':
286
+ $post_data['listname'] = $opts['aweber_list_name'];
287
+ $post_data['redirect'] = get_bloginfo( 'wpurl' );
288
+ $post_data['meta_message'] = '1';
289
+ $post_data['meta_required'] = 'email';
290
+ break;
291
+
292
+ case 'phplist':
293
+ $post_data[ 'list[' . $opts['phplist_list_id'] . ']' ] = 'signup';
294
+ $post_data['subscribe'] = 'Subscribe';
295
+ $post_data['htmlemail'] = '1';
296
+ $post_data['emailconfirm'] = $email;
297
+ $post_data['makeconfirmed'] = '0';
298
+ break;
299
+
300
+ }
301
+
302
+ $post_data = array_merge(
303
+ $post_data,
304
+ $this->add_additional_data(
305
+ array_merge(
306
+ array(
307
+ 'email' => $email,
308
+ 'name' => $name,
309
+ ),
310
+ $post_data
311
+ )
312
+ )
313
+ );
314
+
315
+ wp_remote_post(
316
+ $opts['form_action'],
317
+ array( 'body' => $post_data )
318
+ );
319
+
320
+ }
321
+
322
+ // store a cookie, if preferred by site owner
323
+ if ( $type === 'checkbox' && $this->options['checkbox']['cookie_hide'] == 1 ) {
324
+ setcookie( 'ns_subscriber', true, time() + ( HOUR_IN_SECONDS * 24 * 90 ) );
325
+ }
326
+
327
+ // Check if we should redirect to a given page
328
+ if ( $type === 'form' && strlen( $this->options['form']['redirect_to'] ) > 6 ) {
329
+ wp_redirect( $this->options['form']['redirect_to'] );
330
+ exit;
331
+ } elseif ( $type === 'checkbox' && strlen( $this->options['checkbox']['redirect_to'] ) > 6 ) {
332
+ wp_redirect( $this->options['checkbox']['redirect_to'] );
333
+ exit;
334
+ }
335
+
336
+ return true;
337
+ }
338
+
339
+
340
+ /**
341
+ * Returns array with additional data names as key, values as value.
342
+ *
343
+ * @param array $args, the normal form data (name, email, list variables)
344
+ * @return array
345
+ */
346
+ function add_additional_data( $args = array() ) {
347
+ $opts = $this->options['mailinglist'];
348
+ $defaults = array(
349
+ 'format' => 'array',
350
+ 'api' => null,
351
+ );
352
+
353
+ $args = wp_parse_args( $args, $defaults );
354
+
355
+ $add_data = array();
356
+ if ( isset( $opts['extra_data'] ) && is_array( $opts['extra_data'] ) ) {
357
+ foreach ( $opts['extra_data'] as $key => $value ) {
358
+ if ( $args['api'] == 'ymlp' ) {
359
+ $value['name'] = str_replace( 'YMP', 'Field', $value['name'] );
360
+ }
361
+
362
+ $value['value'] = str_replace( '%%NAME%%', $args['name'], $value['value'] );
363
+ $value['value'] = str_replace( '%%IP%%', $_SERVER['REMOTE_ADDR'], $value['value'] );
364
+ $add_data[ $value['name'] ] = $value['value'];
365
+ }
366
+ }
367
+
368
+ return $add_data;
369
+ }
370
+
371
+ }
includes/functions.php CHANGED
@@ -3,25 +3,21 @@
3
  /**
4
  * Displays the comment checkbox, call this function if your theme does not use the 'comment_form' action in the comments.php template.
5
  */
6
- if(!function_exists('nsu_checkbox')) {
7
- function nsu_checkbox() {
8
- NSU::checkbox()->output_checkbox();
9
- }
10
  }
11
 
 
12
  /**
13
  * Outputs a sign-up form, for usage in your theme files.
14
  */
15
- if(!function_exists('nsu_form')) {
16
- function nsu_form() {
17
- NSU::form()->output_form(true);
18
- }
19
  }
20
 
 
21
  /* Backwards Compatibility */
22
- if(!function_exists('nsu_signup_form')) {
23
- function nsu_signup_form() {
24
- _deprecated_function( __FUNCTION__, '2.0', 'nsu_form' );
25
- nsu_form();
26
- }
27
- }
3
  /**
4
  * Displays the comment checkbox, call this function if your theme does not use the 'comment_form' action in the comments.php template.
5
  */
6
+ function nsu_checkbox() {
7
+ NSU::checkbox()->output_checkbox();
 
 
8
  }
9
 
10
+
11
  /**
12
  * Outputs a sign-up form, for usage in your theme files.
13
  */
14
+ function nsu_form() {
15
+ NSU::form()->output_form( true );
 
 
16
  }
17
 
18
+
19
  /* Backwards Compatibility */
20
+ function nsu_signup_form() {
21
+ _deprecated_function( __FUNCTION__, '2.0', 'nsu_form' );
22
+ nsu_form();
23
+ }
 
 
includes/index.php CHANGED
@@ -1,6 +1,6 @@
1
- <?php
2
- // prevent directory listing
3
-
4
- header( 'Status: 403 Forbidden' );
5
- header( 'HTTP/1.1 403 Forbidden' );
6
- exit;
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header( 'Status: 403 Forbidden' );
5
+ header( 'HTTP/1.1 403 Forbidden' );
6
+ exit;
includes/views/checkbox-settings.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <div class="wrap" id="nsu-admin">
3
+
4
+ <?php include dirname( __FILE__ ) . '/parts/navigation.php'; ?>
5
+
6
+ <h2>Newsletter Sign-Up :: Checkbox Settings</h2>
7
+
8
+ <?php settings_errors(); ?>
9
+
10
+ <div id="nsu-main">
11
+
12
+ <form method="post" action="options.php" id="ns_settings_page">
13
+ <?php settings_fields( 'nsu_checkbox_group' ); ?>
14
+ <table class="form-table">
15
+ <tr valign="top">
16
+ <th scope="row">Text to show after the checkbox</th>
17
+ <td><input class="widefat" type="text" name="nsu_checkbox[text]" value="<?php echo esc_attr( $opts['text'] ); ?>" /></td>
18
+ </tr>
19
+ <tr valign="top">
20
+ <th scope="row">Redirect to this url after signing up <small>(leave empty or enter 0 (zero) for no redirect)</small></th>
21
+ <td>
22
+ <input class="widefat" type="text" name="nsu_checkbox[redirect_to]" value="<?php echo esc_attr( $opts['redirect_to'] ); ?>" />
23
+ <small>In general, I don't recommend setting a redirect url for the sign-up checkbox. This will cause some serious confusion, since
24
+ users expect to be redirected to the post they commented on.</small>
25
+ </td>
26
+ </tr>
27
+ <tr valign="top">
28
+ <th scope="row">
29
+ <label for="ns_precheck_checkbox">Pre-check the checkbox?</label></th>
30
+ <td><input type="checkbox" id="ns_precheck_checkbox" name="nsu_checkbox[precheck]" value="1" <?php checked( $opts['precheck'], 1 ); ?> /></td>
31
+ </tr>
32
+ <tr valign="top">
33
+ <th scope="row"><label for="do_css_reset">Do a CSS 'reset' on the checkbox.</label> </th>
34
+ <td>
35
+ <label>
36
+ <input type="checkbox" id="do_css_reset" name="nsu_checkbox[css_reset]" value="1" <?php checked( $opts['css_reset'], 1 ); ?> />
37
+ <small>(check this if checkbox appears in a weird place)</small>
38
+ </label>
39
+ </td>
40
+ </tr>
41
+ <tr valign="top"><th scope="row">Where to show the sign-up checkbox?</th>
42
+ <td>
43
+ <?php foreach ( $this->get_checkbox_compatible_plugins() as $code => $name ) { ?>
44
+ <input type="checkbox" id="add_to_<?php echo $code; ?>" name="nsu_checkbox[add_to_<?php echo esc_attr( $code ); ?>]" value="1" <?php checked( $opts[ 'add_to_' . $code ], '1' ); ?> /> <label for="add_to_<?php echo $code; ?>"><?php echo $name; ?></label> &nbsp;
45
+ <?php } ?>
46
+ </td>
47
+ </tr>
48
+ <tr valign="top">
49
+ <th scope="row"><label for="ns_cookie_hide">Hide the checkbox for users who used it to subscribe before?</label><small>(uses a cookie)</small></th>
50
+ <td><input type="checkbox" id="ns_cookie_hide" name="nsu_checkbox[cookie_hide]" value="1" <?php checked( $opts['cookie_hide'], 1 ); ?> /></td>
51
+ </tr>
52
+
53
+ </table>
54
+
55
+ <?php submit_button(); ?>
56
+
57
+ </form>
58
+ </div>
59
+
60
+ <?php include dirname( __FILE__ ) . '/parts/sidebar.php'; ?>
61
+
62
+ </div>
includes/views/checkbox_settings.php DELETED
@@ -1,62 +0,0 @@
1
- <?php defined( 'ABSPATH' ) or exit; ?>
2
- <div class="wrap" id="nsu-admin">
3
-
4
- <?php include dirname( __FILE__ ) . '/parts/navigation.php'; ?>
5
-
6
- <h2>Newsletter Sign-Up :: Checkbox Settings</h2>
7
-
8
- <?php settings_errors(); ?>
9
-
10
- <div id="nsu-main">
11
-
12
- <form method="post" action="options.php" id="ns_settings_page">
13
- <?php settings_fields('nsu_checkbox_group'); ?>
14
- <table class="form-table">
15
- <tr valign="top">
16
- <th scope="row">Text to show after the checkbox</th>
17
- <td><input class="widefat" type="text" name="nsu_checkbox[text]" value="<?php echo esc_attr($opts['text']); ?>" /></td>
18
- </tr>
19
- <tr valign="top">
20
- <th scope="row">Redirect to this url after signing up <small>(leave empty or enter 0 (zero) for no redirect)</small></th>
21
- <td>
22
- <input class="widefat" type="text" name="nsu_checkbox[redirect_to]" value="<?php echo esc_attr($opts['redirect_to']); ?>" />
23
- <small>In general, I don't recommend setting a redirect url for the sign-up checkbox. This will cause some serious confusion, since
24
- users expect to be redirected to the post they commented on.</small>
25
- </td>
26
- </tr>
27
- <tr valign="top">
28
- <th scope="row">
29
- <label for="ns_precheck_checkbox">Pre-check the checkbox?</label></th>
30
- <td><input type="checkbox" id="ns_precheck_checkbox" name="nsu_checkbox[precheck]" value="1" <?php checked($opts['precheck'], 1); ?> /></td>
31
- </tr>
32
- <tr valign="top">
33
- <th scope="row"><label for="do_css_reset">Do a CSS 'reset' on the checkbox.</label> </th>
34
- <td>
35
- <label>
36
- <input type="checkbox" id="do_css_reset" name="nsu_checkbox[css_reset]" value="1" <?php checked($opts['css_reset'], 1); ?> />
37
- <small>(check this if checkbox appears in a weird place)</small>
38
- </label>
39
- </td>
40
- </tr>
41
- <tr valign="top"><th scope="row">Where to show the sign-up checkbox?</th>
42
- <td>
43
- <?php foreach($this->get_checkbox_compatible_plugins() as $code => $name) { ?>
44
- <input type="checkbox" id="add_to_<?php echo $code; ?>" name="nsu_checkbox[add_to_<?php echo esc_attr( $code ); ?>]" value="1" <?php checked($opts['add_to_'.$code], '1'); ?> /> <label for="add_to_<?php echo $code; ?>"><?php echo $name; ?></label> &nbsp;
45
- <?php } ?>
46
- </td>
47
- </tr>
48
- <tr valign="top">
49
- <th scope="row"><label for="ns_cookie_hide">Hide the checkbox for users who used it to subscribe before?</label><small>(uses a cookie)</small></th>
50
- <td><input type="checkbox" id="ns_cookie_hide" name="nsu_checkbox[cookie_hide]" value="1" <?php checked($opts['cookie_hide'], 1); ?> /></td>
51
- </tr>
52
-
53
- </table>
54
-
55
- <?php submit_button(); ?>
56
-
57
- </form>
58
- </div>
59
-
60
- <?php include dirname( __FILE__ ) . '/parts/sidebar.php'; ?>
61
-
62
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/views/config-helper.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <div class="wrap" id="nsu-admin">
3
+
4
+
5
+ <?php include dirname( __FILE__ ) . '/parts/navigation.php'; ?>
6
+
7
+ <h2>Newsletter Sign-Up :: Config Extractor</h2>
8
+
9
+
10
+ <div id="nsu-main">
11
+
12
+ <?php if ( isset( $result ) && ! is_array( $result ) ) { ?>
13
+ <div id="message" class="notice updated"><p>Oops, I couldn't make any sense of that. Are you sure you submitted a form snippet?</p></div>
14
+ <?php } ?>
15
+
16
+
17
+
18
+
19
+
20
+ <?php if ( isset( $result ) && is_array( $result ) ) { ?>
21
+ <table class="form-table">
22
+ <tr valign="top">
23
+ <th scope="row" style="font-weight:bold;">Form action:</th>
24
+ <td><?php echo $result['form_action']; ?></td>
25
+ </tr>
26
+ <tr valign="top">
27
+ <th scope="row" style="font-weight:bold;">Email identifier:</th>
28
+ <td><?php echo $result['email_name']; ?></td>
29
+ </tr>
30
+ <tr valign="top">
31
+ <th scope="row" style="font-weight:bold;">Name identifier:</th>
32
+ <td><?php echo $result['name_name']; ?></td>
33
+ </tr>
34
+ <?php if ( count( $result['additional_data'] ) > 0 ) { ?>
35
+ <tr valign="top">
36
+ <th scope="row" colspan="2" style="font-weight:bold;">Additional data ( name / value):</th>
37
+ </tr>
38
+ <?php foreach ( $result['additional_data'] as $data ) { ?>
39
+ <tr valign="top">
40
+ <td><?php echo esc_html( $data[0] ); ?></td>
41
+ <td><?php echo esc_html( $data[1] ); ?></td>
42
+ </tr>
43
+ <?php } ?>
44
+ <?php } ?>
45
+
46
+ </table>
47
+
48
+ <p>The above settings are there to help you, though they may not be right. Check out <a href="https://dannyvankooten.com/571/configuring-newsletter-sign-up-the-definitive-guide/">this post on my blog</a> for more information on how to manually
49
+ configure Newsletter Sign-up.</p>
50
+
51
+ <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>
52
+ <textarea class="widefat" rows="10"><?php echo esc_textarea( $result['simpler_form'] ); ?></textarea>
53
+
54
+ <?php } else { ?>
55
+
56
+ <p>This tool was designed to help you extract the right configuration settings to make Newsletter Sign-Up work properly.</p>
57
+ <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>
58
+ <form method="post" action="" id="ns_settings_page">
59
+ <textarea name="form" class="widefat" rows="10" placeholder="Copy paste your form code here." required></textarea>
60
+
61
+ <p class="submit">
62
+ <input type="submit" class="button-primary" style="margin:5px;" value="<?php _e( 'Extract', 'newsletter-sign-up' ); ?>" />
63
+ </p>
64
+
65
+
66
+ </form>
67
+ <?Php } ?>
68
+
69
+ </div>
70
+
71
+ <?php include dirname( __FILE__ ) . '/parts/sidebar.php'; ?>
72
+
73
+ </div>
includes/views/config_helper.php DELETED
@@ -1,73 +0,0 @@
1
- <?php defined( 'ABSPATH' ) or exit; ?>
2
- <div class="wrap" id="nsu-admin">
3
-
4
-
5
- <?php include dirname( __FILE__ ) . '/parts/navigation.php'; ?>
6
-
7
- <h2>Newsletter Sign-Up :: Config Extractor</h2>
8
-
9
-
10
- <div id="nsu-main">
11
-
12
- <?php if( isset( $result ) && ! is_array( $result ) ) { ?>
13
- <div id="message" class="notice updated"><p>Oops, I couldn't make any sense of that. Are you sure you submitted a form snippet?</p></div>
14
- <?php } ?>
15
-
16
-
17
-
18
-
19
-
20
- <?php if(isset($result) && is_array($result)) { ?>
21
- <table class="form-table">
22
- <tr valign="top">
23
- <th scope="row" style="font-weight:bold;">Form action:</th>
24
- <td><?php echo $result['form_action']; ?></td>
25
- </tr>
26
- <tr valign="top">
27
- <th scope="row" style="font-weight:bold;">Email identifier:</th>
28
- <td><?php echo $result['email_name']; ?></td>
29
- </tr>
30
- <tr valign="top">
31
- <th scope="row" style="font-weight:bold;">Name identifier:</th>
32
- <td><?php echo $result['name_name']; ?></td>
33
- </tr>
34
- <?php if(count($result['additional_data']) > 0) { ?>
35
- <tr valign="top">
36
- <th scope="row" colspan="2" style="font-weight:bold;">Additional data ( name / value):</th>
37
- </tr>
38
- <?php foreach($result['additional_data'] as $data) { ?>
39
- <tr valign="top">
40
- <td><?php echo esc_html( $data[0] ); ?></td>
41
- <td><?php echo esc_html( $data[1] ); ?></td>
42
- </tr>
43
- <?php } ?>
44
- <?php } ?>
45
-
46
- </table>
47
-
48
- <p>The above settings are there to help you, though they may not be right. Check out <a href="https://dannyvankooten.com/571/configuring-newsletter-sign-up-the-definitive-guide/">this post on my blog</a> for more information on how to manually
49
- configure Newsletter Sign-up.</p>
50
-
51
- <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>
52
- <textarea class="widefat" rows="10"><?php echo esc_textarea( $result['simpler_form'] ); ?></textarea>
53
-
54
- <?php } else { ?>
55
-
56
- <p>This tool was designed to help you extract the right configuration settings to make Newsletter Sign-Up work properly.</p>
57
- <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>
58
- <form method="post" action="" id="ns_settings_page">
59
- <textarea name="form" class="widefat" rows="10" placeholder="Copy paste your form code here." required></textarea>
60
-
61
- <p class="submit">
62
- <input type="submit" class="button-primary" style="margin:5px;" value="<?php _e('Extract') ?>" />
63
- </p>
64
-
65
-
66
- </form>
67
- <?Php } ?>
68
-
69
- </div>
70
-
71
- <?php include dirname( __FILE__ ) . '/parts/sidebar.php'; ?>
72
-
73
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/views/dashboard.php CHANGED
@@ -1,113 +1,149 @@
1
- <?php defined( 'ABSPATH' ) or exit; ?>
2
- <div class="wrap" id="nsu-admin">
3
-
4
- <?php include dirname( __FILE__ ) . '/parts/navigation.php'; ?>
5
-
6
- <h2>Newsletter Sign-Up :: Mailinglist Settings</h2>
7
- <?php settings_errors(); ?>
8
-
9
- <div id="nsu-main">
10
-
11
- <form method="post" action="options.php">
12
- <?php settings_fields('nsu_mailinglist_group'); ?>
13
-
14
- <p>These settings are the most important, without them Newsletter Sign-Up can't do its job. Having trouble finding the right configuration settings? Have a look at <a href="https://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>
15
-
16
- <table class="form-table">
17
- <tr valign="top">
18
- <th scope="row">Select your mailinglist provider: </th>
19
- <td>
20
- <select class="widefat" name="nsu_mailinglist[provider]" id="ns_mp_provider" onchange="document.location.href = 'admin.php?page=<?php echo $this->hook; ?>&mp=' + this.value">
21
- <option value="other"<?php if ($viewed_mp == NULL || $viewed_mp == 'other')
22
- echo ' SELECTED'; ?>>-- other / advanced</option>
23
- <option value="mailchimp"<?php if ($viewed_mp == 'mailchimp')
24
- echo ' SELECTED'; ?> >MailChimp</option>
25
- <option value="ymlp"<?php if ($viewed_mp == 'ymlp')
26
- echo ' SELECTED'; ?> >YMLP</option>
27
- <option value="icontact"<?php if ($viewed_mp == 'icontact')
28
- echo ' SELECTED'; ?> >iContact</option>
29
- <option value="aweber"<?php if ($viewed_mp == 'aweber')
30
- echo ' SELECTED'; ?> >Aweber</option>
31
- <option value="phplist"<?php if ($viewed_mp == 'phplist')
32
- echo ' SELECTED'; ?> >PHPList</option>
33
- </select>
34
- </td>
35
- </tr>
36
-
37
- <?php if(isset($viewed_mp) && file_exists(dirname(__FILE__) . '/parts/rows-' . $viewed_mp . '.php')) require 'parts/rows-' . $viewed_mp . '.php'; ?>
38
-
39
- <tbody class="form_rows"<?php if (isset($viewed_mp) && in_array($viewed_mp, array('mailchimp', 'ymlp')) && isset($opts['use_api']) && $opts['use_api'] == 1)
40
- echo ' style="display:none" '; ?>>
41
- <tr valign="top">
42
- <th scope="row">Newsletter form action</th>
43
- <td><input class="widefat" type="text" id="ns_form_action" name="nsu_mailinglist[form_action]" placeholder="Example: http://newsletter-service.com?action=subscribe&id=123" value="<?php echo esc_attr($opts['form_action']); ?>" /></td>
44
- </tr>
45
- <tr valign="top">
46
- <th scope="row">
47
- E-mail identifier
48
- <small class="help">name attribute of input field for the emailadress</small>
49
- </th>
50
- <td><input class="widefat" type="text" name="nsu_mailinglist[email_id]" placeholder="Example: EMAIL" value="<?php echo esc_attr($opts['email_id']); ?>"/></td>
51
- </tr>
52
- </tbody>
53
- <tbody>
54
- <tr valign="top">
55
- <th scope="row"><label for="subscribe_with_name">Subscribe with name?</label></th>
56
- <td><input type="checkbox" id="subscribe_with_name" name="nsu_mailinglist[subscribe_with_name]" value="1" <?php checked($opts['subscribe_with_name'], 1); ?> /></td>
57
- </tr>
58
- <tr class="name_dependent" valign="top" <?php if($opts['subscribe_with_name'] != 1) echo 'style="display:none;"'; ?>>
59
- <th scope="row">
60
- Name identifier
61
- <small class="help">name attribute of input field that holds the name</small>
62
- </th>
63
- <td><input class="widefat" id="ns_name_id" type="text" name="nsu_mailinglist[name_id]" placeholder="Example: NAME" value="<?php echo esc_attr($opts['name_id']); ?>" /></td>
64
- </tr>
65
- </tbody>
66
- </table>
67
- <p>
68
- For some newsletter services you need to specify some additional fields, like a list ID or your account name. These fields are usually found as hidden fields in the HTML code of your sign-up forms.
69
- You can specify these additional fields here using name / value pairs, they will be included in all sign-up requests made by the plugin.
70
- </p>
71
- <table class="form-table">
72
- <tr valign="top" style="font-weight:bold;">
73
- <th scope="column">Name</th>
74
- <th scope="column">Value</th>
75
- </tr>
76
- <?php
77
- $last_key = 0;
78
-
79
- if (isset($opts['extra_data']) && is_array($opts['extra_data'])) :
80
- foreach ($opts['extra_data'] as $key => $value) :
81
- ?>
82
- <tr valign="top">
83
- <td><input class="widefat" type="text" name="nsu_mailinglist[extra_data][<?php echo esc_attr( $key ); ?>][name]" value="<?php echo esc_attr( $value['name'] ); ?>" /></td>
84
- <td><input class="widefat" type="text" name="nsu_mailinglist[extra_data][<?php echo esc_attr( $key ); ?>][value]" value="<?php echo esc_attr( $value['value'] ); ?>" /></td>
85
- </tr>
86
- <?php
87
- $last_key = $key + 1;
88
- endforeach;
89
- endif;
90
- ?>
91
- <tr valign="top">
92
- <td><input class="widefat" type="text" name="nsu_mailinglist[extra_data][<?php echo esc_attr( $last_key ); ?>][name]" placeholder="Hidden field name" value="" /></td>
93
- <td><input class="widefat" type="text" name="nsu_mailinglist[extra_data][<?php echo esc_attr( $last_key ); ?>][value]" placeholder="Hidden field value" value="" /></td>
94
- </tr>
95
- </table>
96
-
97
- <p class="help"><strong>Dynamic values:</strong> <code>{name}</code> and <code>{ip}</code> will be replaced by the name or IP address of the subscriber.</p>
98
-
99
-
100
- <?php submit_button(); ?>
101
-
102
- </form>
103
- <p>
104
- <em>Having trouble finding the right configuration settings? Try the <a href="<?php echo admin_url( 'admin.php?page=newsletter-sign-up-config-helper'); ?>">configuration extractor</a>.</em>
105
- </p>
106
-
107
- </div>
108
-
109
-
110
- <?php include dirname( __FILE__ ) . '/parts/sidebar.php'; ?>
111
-
112
- </div>
113
- <br style="clear:both;" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <div class="wrap" id="nsu-admin">
3
+
4
+ <?php include dirname( __FILE__ ) . '/parts/navigation.php'; ?>
5
+
6
+ <h2>Newsletter Sign-Up :: Mailinglist Settings</h2>
7
+ <?php settings_errors(); ?>
8
+
9
+ <div id="nsu-main">
10
+
11
+ <form method="post" action="options.php">
12
+ <?php settings_fields( 'nsu_mailinglist_group' ); ?>
13
+
14
+ <p>These settings are the most important, without them Newsletter Sign-Up can't do its job. Having trouble finding the right configuration settings? Have a look at <a href="https://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>
15
+
16
+ <table class="form-table">
17
+ <tr valign="top">
18
+ <th scope="row">Select your mailinglist provider: </th>
19
+ <td>
20
+ <select class="widefat" name="nsu_mailinglist[provider]" id="ns_mp_provider" onchange="document.location.href = 'admin.php?page=<?php echo $this->hook; ?>&mp=' + this.value">
21
+ <option value="other"
22
+ <?php
23
+ if ( $viewed_mp == null || $viewed_mp == 'other' ) {
24
+ echo ' SELECTED';}
25
+ ?>
26
+ >-- other / advanced</option>
27
+ <option value="mailchimp"
28
+ <?php
29
+ if ( $viewed_mp == 'mailchimp' ) {
30
+ echo ' SELECTED';}
31
+ ?>
32
+ >Mailchimp</option>
33
+ <option value="ymlp"
34
+ <?php
35
+ if ( $viewed_mp == 'ymlp' ) {
36
+ echo ' SELECTED';}
37
+ ?>
38
+ >YMLP</option>
39
+ <option value="icontact"
40
+ <?php
41
+ if ( $viewed_mp == 'icontact' ) {
42
+ echo ' SELECTED';}
43
+ ?>
44
+ >iContact</option>
45
+ <option value="aweber"
46
+ <?php
47
+ if ( $viewed_mp == 'aweber' ) {
48
+ echo ' SELECTED';}
49
+ ?>
50
+ >Aweber</option>
51
+ <option value="phplist"
52
+ <?php
53
+ if ( $viewed_mp == 'phplist' ) {
54
+ echo ' SELECTED';}
55
+ ?>
56
+ >PHPList</option>
57
+ </select>
58
+ </td>
59
+ </tr>
60
+
61
+ <?php
62
+ if ( isset( $viewed_mp ) && file_exists( dirname( __FILE__ ) . '/parts/rows-' . $viewed_mp . '.php' ) ) {
63
+ require 'parts/rows-' . $viewed_mp . '.php';}
64
+ ?>
65
+
66
+ <tbody class="form_rows"
67
+ <?php
68
+ if ( isset( $viewed_mp ) && in_array( $viewed_mp, array( 'mailchimp', 'ymlp' ) ) && isset( $opts['use_api'] ) && $opts['use_api'] == 1 ) {
69
+ echo ' style="display:none" ';}
70
+ ?>
71
+ >
72
+ <tr valign="top">
73
+ <th scope="row">Newsletter form action</th>
74
+ <td><input class="widefat" type="text" id="ns_form_action" name="nsu_mailinglist[form_action]" placeholder="Example: http://newsletter-service.com?action=subscribe&id=123" value="<?php echo esc_attr( $opts['form_action'] ); ?>" /></td>
75
+ </tr>
76
+ <tr valign="top">
77
+ <th scope="row">
78
+ E-mail identifier
79
+ <small class="help">name attribute of input field for the emailadress</small>
80
+ </th>
81
+ <td><input class="widefat" type="text" name="nsu_mailinglist[email_id]" placeholder="Example: EMAIL" value="<?php echo esc_attr( $opts['email_id'] ); ?>"/></td>
82
+ </tr>
83
+ </tbody>
84
+ <tbody>
85
+ <tr valign="top">
86
+ <th scope="row"><label for="subscribe_with_name">Subscribe with name?</label></th>
87
+ <td><input type="checkbox" id="subscribe_with_name" name="nsu_mailinglist[subscribe_with_name]" value="1" <?php checked( $opts['subscribe_with_name'], 1 ); ?> /></td>
88
+ </tr>
89
+ <tr class="name_dependent" valign="top"
90
+ <?php
91
+ if ( $opts['subscribe_with_name'] != 1 ) {
92
+ echo 'style="display:none;"';}
93
+ ?>
94
+ >
95
+ <th scope="row">
96
+ Name identifier
97
+ <small class="help">name attribute of input field that holds the name</small>
98
+ </th>
99
+ <td><input class="widefat" id="ns_name_id" type="text" name="nsu_mailinglist[name_id]" placeholder="Example: NAME" value="<?php echo esc_attr( $opts['name_id'] ); ?>" /></td>
100
+ </tr>
101
+ </tbody>
102
+ </table>
103
+ <p>
104
+ For some newsletter services you need to specify some additional fields, like a list ID or your account name. These fields are usually found as hidden fields in the HTML code of your sign-up forms.
105
+ You can specify these additional fields here using name / value pairs, they will be included in all sign-up requests made by the plugin.
106
+ </p>
107
+ <table class="form-table">
108
+ <tr valign="top" style="font-weight:bold;">
109
+ <th scope="column">Name</th>
110
+ <th scope="column">Value</th>
111
+ </tr>
112
+ <?php
113
+ $last_key = 0;
114
+
115
+ if ( isset( $opts['extra_data'] ) && is_array( $opts['extra_data'] ) ) :
116
+ foreach ( $opts['extra_data'] as $key => $value ) :
117
+ ?>
118
+ <tr valign="top">
119
+ <td><input class="widefat" type="text" name="nsu_mailinglist[extra_data][<?php echo esc_attr( $key ); ?>][name]" value="<?php echo esc_attr( $value['name'] ); ?>" /></td>
120
+ <td><input class="widefat" type="text" name="nsu_mailinglist[extra_data][<?php echo esc_attr( $key ); ?>][value]" value="<?php echo esc_attr( $value['value'] ); ?>" /></td>
121
+ </tr>
122
+ <?php
123
+ $last_key = $key + 1;
124
+ endforeach;
125
+ endif;
126
+ ?>
127
+ <tr valign="top">
128
+ <td><input class="widefat" type="text" name="nsu_mailinglist[extra_data][<?php echo esc_attr( $last_key ); ?>][name]" placeholder="Hidden field name" value="" /></td>
129
+ <td><input class="widefat" type="text" name="nsu_mailinglist[extra_data][<?php echo esc_attr( $last_key ); ?>][value]" placeholder="Hidden field value" value="" /></td>
130
+ </tr>
131
+ </table>
132
+
133
+ <p class="help"><strong>Dynamic values:</strong> <code>{name}</code> and <code>{ip}</code> will be replaced by the name or IP address of the subscriber.</p>
134
+
135
+
136
+ <?php submit_button(); ?>
137
+
138
+ </form>
139
+ <p>
140
+ <em>Having trouble finding the right configuration settings? Try the <a href="<?php echo admin_url( 'admin.php?page=newsletter-sign-up-config-helper' ); ?>">configuration extractor</a>.</em>
141
+ </p>
142
+
143
+ </div>
144
+
145
+
146
+ <?php include dirname( __FILE__ ) . '/parts/sidebar.php'; ?>
147
+
148
+ </div>
149
+ <br style="clear:both;" />
includes/views/form-settings.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <div class="wrap" id="nsu-admin">
3
+
4
+ <?php include dirname( __FILE__ ) . '/parts/navigation.php'; ?>
5
+
6
+ <div id="nsu-main">
7
+
8
+ <h2>Newsletter Sign-Up :: Form Settings</h2>
9
+ <?php settings_errors(); ?>
10
+
11
+ <p>Customize your newsletter sign-up form by customizing the labels, input fields, buttons and validation texts using the settings below. Use <code>[nsu_form]</code> to render a sign-up form in your posts or pages or use the <em>Newsletter Sign-Up</em> widget to display a sign-up form in your widget areas.</p>
12
+
13
+ <form method="post" action="options.php">
14
+ <?php settings_fields( 'nsu_form_group' ); ?>
15
+ <table class="form-table">
16
+ <tr valign="top">
17
+ <th scope="row">E-mail label</th>
18
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[email_label]" value="<?php echo esc_attr( $opts['email_label'] ); ?>" placeholder="Eg: Your email:" required /></td>
19
+ </tr>
20
+ <tr valign="top">
21
+ <th scope="row">E-mail default value</th>
22
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[email_default_value]" value="<?php echo esc_attr( $opts['email_default_value'] ); ?>" /></td>
23
+ </tr>
24
+ <tr valign="top" class="name_dependent"
25
+ <?php
26
+ if ( $opts['mailinglist']['subscribe_with_name'] != 1 ) {
27
+ echo 'style="display:none;"';}
28
+ ?>
29
+ >
30
+ <th scope="row">Name label</th>
31
+ <td colspan="2">
32
+ <input class="widefat" type="text" name="nsu_form[name_label]" value="<?php echo esc_attr( $opts['name_label'] ); ?>" /><br />
33
+ <p><input type="checkbox" id="name_required" name="nsu_form[name_required]" value="1" <?php checked( $opts['name_required'], 1 ); ?> />
34
+ <label for="name_required">Name is a required field?</label></p>
35
+ </td>
36
+ </tr>
37
+ <tr valign="top" class="name_dependent"
38
+ <?php
39
+ if ( $opts['mailinglist']['subscribe_with_name'] != 1 ) {
40
+ echo 'style="display:none;"';}
41
+ ?>
42
+ >
43
+ <th scope="row">Name default value</th>
44
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[name_default_value]" value="<?php echo esc_attr( $opts['name_default_value'] ); ?>" /></td>
45
+
46
+ </tr>
47
+ <tr valign="top">
48
+ <th scope="row">Submit button text</th>
49
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[submit_button]" value="<?php echo esc_attr( $opts['submit_button'] ); ?>" placeholder="Eg: Subscribe" required /></td>
50
+ </tr>
51
+ <tr valign="top">
52
+ <th scope="row">Text to replace the form with after a successful sign-up</th>
53
+ <td colspan="2">
54
+ <textarea class="widefat" rows="5" cols="50" name="nsu_form[text_after_signup]"><?php echo esc_textarea( $opts['text_after_signup'] ); ?></textarea>
55
+ <p><label><input id="nsu_form_wpautop" name="nsu_form[wpautop]" type="checkbox" value="1" <?php checked( $opts['wpautop'], 1 ); ?> /> <?php _e( 'Automatically add paragraphs', 'newsletter-sign-up' ); ?></label></p>
56
+ </td>
57
+ </tr>
58
+
59
+ <?php if ( $opts['mailinglist']['use_api'] == 1 ) { ?>
60
+ <tr valign="top">
61
+ <th scope="row">Redirect to this url after signing up <small>(leave empty for no redirect)</small></th>
62
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[redirect_to]" value="<?php echo $opts['redirect_to']; ?>" /></td>
63
+ </tr>
64
+ <?php } ?>
65
+
66
+ <tr valign="top">
67
+ <th scope="row"><label for="ns_load_form_styles">Load CSS</label></th>
68
+ <td>
69
+ <label><input type="checkbox" id="ns_load_form_styles" name="nsu_form[load_form_css]" value="1"
70
+ <?php
71
+ if ( $opts['load_form_css'] == 1 ) {
72
+ echo 'checked';}
73
+ ?>
74
+ />
75
+ Check this to load some default form styles.</label></td>
76
+ </tr>
77
+ </table>
78
+
79
+ <?php submit_button(); ?>
80
+
81
+ <?php if ( $this->options['mailinglist']['use_api'] == 1 ) { ?>
82
+ <h3>Form text messages</h3>
83
+ <table class="form-table">
84
+ <?php if ( $opts['mailinglist']['subscribe_with_name'] ) { ?>
85
+ <tr valign="top">
86
+ <th scope="row">Empty name field message</th>
87
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[text_empty_name]" value="<?php echo esc_attr( $opts['text_empty_name'] ); ?>" /></td>
88
+ </tr>
89
+ <?php } ?>
90
+ <tr valign="top">
91
+ <th scope="row">Empty email address field message</th>
92
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[text_empty_email]" value="<?php echo esc_attr( $opts['text_empty_email'] ); ?>" /></td>
93
+ </tr>
94
+ <tr valign="top">
95
+ <th scope="row">Invalid email address message</th>
96
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[text_invalid_email]" value="<?php echo esc_attr( $opts['text_invalid_email'] ); ?>" /></td>
97
+ </tr>
98
+ </table>
99
+ <?php } ?>
100
+ </form>
101
+ </div>
102
+
103
+ <?php include dirname( __FILE__ ) . '/parts/sidebar.php'; ?>
104
+
105
+ </div>
includes/views/form_settings.php DELETED
@@ -1,90 +0,0 @@
1
- <?php defined( 'ABSPATH' ) or exit; ?>
2
- <div class="wrap" id="nsu-admin">
3
-
4
- <?php include dirname( __FILE__ ) . '/parts/navigation.php'; ?>
5
-
6
- <div id="nsu-main">
7
-
8
- <h2>Newsletter Sign-Up :: Form Settings</h2>
9
- <?php settings_errors(); ?>
10
-
11
- <p>Customize your newsletter sign-up form by customizing the labels, input fields, buttons and validation texts using the settings below. Use <code>[nsu_form]</code> to render a sign-up form in your posts or pages or use the <em>Newsletter Sign-Up</em> widget to display a sign-up form in your widget areas.</p>
12
-
13
- <form method="post" action="options.php">
14
- <?php settings_fields('nsu_form_group'); ?>
15
- <table class="form-table">
16
- <tr valign="top">
17
- <th scope="row">E-mail label</th>
18
- <td colspan="2"><input class="widefat" type="text" name="nsu_form[email_label]" value="<?php echo esc_attr($opts['email_label']); ?>" placeholder="Eg: Your email:" required /></td>
19
- </tr>
20
- <tr valign="top">
21
- <th scope="row">E-mail default value</th>
22
- <td colspan="2"><input class="widefat" type="text" name="nsu_form[email_default_value]" value="<?php echo esc_attr($opts['email_default_value']); ?>" /></td>
23
- </tr>
24
- <tr valign="top" class="name_dependent" <?php if($opts['mailinglist']['subscribe_with_name'] != 1) echo 'style="display:none;"'; ?>>
25
- <th scope="row">Name label</th>
26
- <td colspan="2">
27
- <input class="widefat" type="text" name="nsu_form[name_label]" value="<?php echo esc_attr($opts['name_label']); ?>" /><br />
28
- <p><input type="checkbox" id="name_required" name="nsu_form[name_required]" value="1" <?php checked($opts['name_required'], 1); ?> />
29
- <label for="name_required">Name is a required field?</label></p>
30
- </td>
31
- </tr>
32
- <tr valign="top" class="name_dependent" <?php if($opts['mailinglist']['subscribe_with_name'] != 1) echo 'style="display:none;"'; ?>>
33
- <th scope="row">Name default value</th>
34
- <td colspan="2"><input class="widefat" type="text" name="nsu_form[name_default_value]" value="<?php echo esc_attr($opts['name_default_value']); ?>" /></td>
35
-
36
- </tr>
37
- <tr valign="top">
38
- <th scope="row">Submit button text</th>
39
- <td colspan="2"><input class="widefat" type="text" name="nsu_form[submit_button]" value="<?php echo esc_attr($opts['submit_button']); ?>" placeholder="Eg: Subscribe" required /></td>
40
- </tr>
41
- <tr valign="top">
42
- <th scope="row">Text to replace the form with after a successful sign-up</th>
43
- <td colspan="2">
44
- <textarea class="widefat" rows="5" cols="50" name="nsu_form[text_after_signup]"><?php echo esc_textarea($opts['text_after_signup']); ?></textarea>
45
- <p><label><input id="nsu_form_wpautop" name="nsu_form[wpautop]" type="checkbox" value="1" <?php checked($opts['wpautop'], 1) ?> /> <?php _e('Automatically add paragraphs'); ?></label></p>
46
- </td>
47
- </tr>
48
-
49
- <?php if($opts['mailinglist']['use_api'] == 1) { ?>
50
- <tr valign="top">
51
- <th scope="row">Redirect to this url after signing up <small>(leave empty for no redirect)</small></th>
52
- <td colspan="2"><input class="widefat" type="text" name="nsu_form[redirect_to]" value="<?php echo $opts['redirect_to']; ?>" /></td>
53
- </tr>
54
- <?php } ?>
55
-
56
- <tr valign="top">
57
- <th scope="row"><label for="ns_load_form_styles">Load CSS</label></th>
58
- <td>
59
- <label><input type="checkbox" id="ns_load_form_styles" name="nsu_form[load_form_css]" value="1" <?php if($opts['load_form_css'] == 1) echo 'checked'; ?> />
60
- Check this to load some default form styles.</label></td>
61
- </tr>
62
- </table>
63
-
64
- <?php submit_button(); ?>
65
-
66
- <?php if($this->options['mailinglist']['use_api'] == 1) { ?>
67
- <h3>Form text messages</h3>
68
- <table class="form-table">
69
- <?php if($opts['mailinglist']['subscribe_with_name']) { ?>
70
- <tr valign="top">
71
- <th scope="row">Empty name field message</th>
72
- <td colspan="2"><input class="widefat" type="text" name="nsu_form[text_empty_name]" value="<?php echo esc_attr($opts['text_empty_name']); ?>" /></td>
73
- </tr>
74
- <?php } ?>
75
- <tr valign="top">
76
- <th scope="row">Empty email address field message</th>
77
- <td colspan="2"><input class="widefat" type="text" name="nsu_form[text_empty_email]" value="<?php echo esc_attr($opts['text_empty_email']); ?>" /></td>
78
- </tr>
79
- <tr valign="top">
80
- <th scope="row">Invalid email address message</th>
81
- <td colspan="2"><input class="widefat" type="text" name="nsu_form[text_invalid_email]" value="<?php echo esc_attr($opts['text_invalid_email']); ?>" /></td>
82
- </tr>
83
- </table>
84
- <?php } ?>
85
- </form>
86
- </div>
87
-
88
- <?php include dirname( __FILE__ ) . '/parts/sidebar.php'; ?>
89
-
90
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/views/index.php CHANGED
@@ -1,6 +1,6 @@
1
- <?php
2
- // prevent directory listing
3
-
4
- header( 'Status: 403 Forbidden' );
5
- header( 'HTTP/1.1 403 Forbidden' );
6
- exit;
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header( 'Status: 403 Forbidden' );
5
+ header( 'HTTP/1.1 403 Forbidden' );
6
+ exit;
includes/views/parts/index.php CHANGED
@@ -1,6 +1,6 @@
1
- <?php
2
- // prevent directory listing
3
-
4
- header( 'Status: 403 Forbidden' );
5
- header( 'HTTP/1.1 403 Forbidden' );
6
- exit;
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header( 'Status: 403 Forbidden' );
5
+ header( 'HTTP/1.1 403 Forbidden' );
6
+ exit;
includes/views/parts/navigation.php CHANGED
@@ -1,8 +1,7 @@
1
-
2
  <?php defined( 'ABSPATH' ) or exit; ?>
3
  <h2 class="nav-tab-wrapper">
4
- <a href="?page=newsletter-sign-up" class="nav-tab <?php echo ($tab == 'mailinglist-settings') ? 'nav-tab-active' : ''; ?>">Mailinglist Settings</a>
5
- <a href="?page=newsletter-sign-up-checkbox-settings" class="nav-tab <?php echo ($tab === 'checkbox-settings') ? 'nav-tab-active' : ''; ?>">Checkbox Settings</a>
6
- <a href="?page=newsletter-sign-up-form-settings" class="nav-tab <?php echo ($tab === 'form-settings') ? 'nav-tab-active' : ''; ?>">Form Settings</a>
7
- <a href="?page=newsletter-sign-up-config-helper" class="nav-tab <?php echo ($tab === 'config-helper') ? 'nav-tab-active' : ''; ?>">Config Helper</a>
8
- </h2>
 
1
  <?php defined( 'ABSPATH' ) or exit; ?>
2
  <h2 class="nav-tab-wrapper">
3
+ <a href="?page=newsletter-sign-up" class="nav-tab <?php echo ( $tab == 'mailinglist-settings' ) ? 'nav-tab-active' : ''; ?>">Mailinglist Settings</a>
4
+ <a href="?page=newsletter-sign-up-checkbox-settings" class="nav-tab <?php echo ( $tab === 'checkbox-settings' ) ? 'nav-tab-active' : ''; ?>">Checkbox Settings</a>
5
+ <a href="?page=newsletter-sign-up-form-settings" class="nav-tab <?php echo ( $tab === 'form-settings' ) ? 'nav-tab-active' : ''; ?>">Form Settings</a>
6
+ <a href="?page=newsletter-sign-up-config-helper" class="nav-tab <?php echo ( $tab === 'config-helper' ) ? 'nav-tab-active' : ''; ?>">Config Helper</a>
7
+ </h2>
includes/views/parts/rows-aweber.php CHANGED
@@ -2,7 +2,11 @@
2
  <tr valign="top">
3
  <th scope="row"><label for="aweber_list_name" Aweber list name</th>
4
  <td>
5
- <input id="aweber_list_name" class="widefat" type="text" name="nsu_mailinglist[aweber_list_name]" value="<?php if ( isset( $opts['aweber_list_name'] ) ) {
 
 
6
  echo esc_attr( $opts['aweber_list_name'] );
7
- } ?>" /></td>
8
- </tr>
 
 
2
  <tr valign="top">
3
  <th scope="row"><label for="aweber_list_name" Aweber list name</th>
4
  <td>
5
+ <input id="aweber_list_name" class="widefat" type="text" name="nsu_mailinglist[aweber_list_name]" value="
6
+ <?php
7
+ if ( isset( $opts['aweber_list_name'] ) ) {
8
  echo esc_attr( $opts['aweber_list_name'] );
9
+ }
10
+ ?>
11
+ " /></td>
12
+ </tr>
includes/views/parts/rows-mailchimp.php CHANGED
@@ -1,39 +1,55 @@
1
  <?php defined( 'ABSPATH' ) or exit; ?>
2
  <tr valign="top">
3
  <th colspan="2" style="background: white; border-left: 10px solid lightskyblue; padding: 20px;">
4
- As you're using MailChimp, I highly recommend switching to our improved <a href="https://wordpress.org/plugins/mailchimp-for-wp/">MailChimp for WordPress</a> plugin.
5
  You'll be up and running (again) in just a few minutes.
6
  </th>
7
  </tr>
8
 
9
  <tr valign="top">
10
  <th scope="row">
11
- <label for="use_api">Use MailChimp API?</label>
12
  <small class="help">(recommended)</small>
13
  </th>
14
  <td>
15
- <input type="checkbox" id="use_api" name="nsu_mailinglist[use_api]" value="1"<?php if ( isset( $opts['use_api'] ) && $opts['use_api'] == '1' ) {
 
 
16
  echo ' checked="checked"';
17
- } ?> /></td>
 
 
18
  </tr>
19
 
20
- <tbody class="api_rows" <?php if ( ! isset( $opts['use_api'] ) || $opts['use_api'] != 1 ) {
 
 
21
  echo ' style="display:none" ';
22
- } ?>>
 
 
23
  <tr valign="top">
24
- <th scope="row">MailChimp API Key <a target="_blank" href="https://admin.mailchimp.com/account/api">(?)</a></th>
25
  <td>
26
- <input class="widefat" type="text" id="mc_api_key" name="nsu_mailinglist[mc_api_key]" value="<?php if ( isset( $opts['mc_api_key'] ) ) {
 
 
27
  echo esc_attr( $opts['mc_api_key'] );
28
- } ?>" /></td>
 
 
29
  </tr>
30
  <tr valign="top">
31
- <th scope="row">MailChimp List ID
32
  <a href="http://www.mailchimp.com/kb/article/how-can-i-find-my-list-id" target="_blank">(?)</a></th>
33
  <td>
34
- <input class="widefat" type="text" name="nsu_mailinglist[mc_list_id]" value="<?php if ( isset( $opts['mc_list_id'] ) ) {
 
 
35
  echo esc_attr( $opts['mc_list_id'] );
36
- } ?>"; />
 
 
37
  </td>
38
  </tr>
39
  <tr valign="top">
@@ -41,26 +57,42 @@
41
  <label title="Prevents your users from having to confirm their emailaddress. Make sure you comply with the CAN SPAM act." for="mc_prevent_double_optin">Prevent double opt-in?</label>
42
  </th>
43
  <td>
44
- <input type="checkbox" id="mc_prevent_double_optin" name="nsu_mailinglist[mc_no_double_optin]" value="1" <?php if ( isset( $opts['mc_no_double_optin'] ) ) {
 
 
45
  checked( $opts['mc_no_double_optin'], 1 );
46
- } ?> /></td>
 
 
47
  </tr>
48
  <tr valign="top">
49
  <th scope="row"><label for="mc_use_groupings">Add to group(s)? </label></th>
50
  <td>
51
- <input type="checkbox" id="mc_use_groupings" name="nsu_mailinglist[mc_use_groupings]" value="1" <?php if ( isset( $opts['mc_use_groupings'] ) ) {
 
 
52
  checked( $opts['mc_use_groupings'], 1 );
53
- } ?> /></td>
 
 
54
  </tr>
55
- <tbody class="mc_groupings_rows" <?php if ( ! isset( $opts['mc_use_groupings'] ) || $opts['mc_use_groupings'] != 1 ) {
 
 
56
  echo ' style="display:none" ';
57
- } ?>>
 
 
58
  <tr valign="top">
59
  <th scope="row">Grouping name</th>
60
  <td>
61
- <input class="widefat" type="text" id="mc_groupings_name" name="nsu_mailinglist[mc_groupings_name]" value="<?php if ( isset( $opts['mc_groupings_name'] ) ) {
 
 
62
  echo esc_attr( $opts['mc_groupings_name'] );
63
- } ?>" /></td>
 
 
64
  </tr>
65
  <tr valign="top">
66
  <th scope="row">
@@ -68,10 +100,14 @@
68
  <small class="help">(comma delimited list of interest groups to add to)</small>
69
  </th>
70
  <td>
71
- <input class="widefat" type="text" name="nsu_mailinglist[mc_groupings_groups]" placeholder="Example: Group 1,Group 2,Group 3" value="<?php if ( isset( $opts['mc_groupings_groups'] ) ) {
 
 
72
  echo esc_attr( $opts['mc_groupings_groups'] );
73
- } ?>"; />
 
 
74
  </td>
75
  </tr>
76
  </tbody>
77
- </tbody>
1
  <?php defined( 'ABSPATH' ) or exit; ?>
2
  <tr valign="top">
3
  <th colspan="2" style="background: white; border-left: 10px solid lightskyblue; padding: 20px;">
4
+ As you're using Mailchimp, I highly recommend switching to our improved <a href="https://wordpress.org/plugins/mailchimp-for-wp/">Mailchimp for WordPress</a> plugin.
5
  You'll be up and running (again) in just a few minutes.
6
  </th>
7
  </tr>
8
 
9
  <tr valign="top">
10
  <th scope="row">
11
+ <label for="use_api">Use Mailchimp API?</label>
12
  <small class="help">(recommended)</small>
13
  </th>
14
  <td>
15
+ <input type="checkbox" id="use_api" name="nsu_mailinglist[use_api]" value="1"
16
+ <?php
17
+ if ( isset( $opts['use_api'] ) && $opts['use_api'] == '1' ) {
18
  echo ' checked="checked"';
19
+ }
20
+ ?>
21
+ /></td>
22
  </tr>
23
 
24
+ <tbody class="api_rows"
25
+ <?php
26
+ if ( ! isset( $opts['use_api'] ) || $opts['use_api'] != 1 ) {
27
  echo ' style="display:none" ';
28
+ }
29
+ ?>
30
+ >
31
  <tr valign="top">
32
+ <th scope="row">Mailchimp API Key <a target="_blank" href="https://admin.mailchimp.com/account/api">(?)</a></th>
33
  <td>
34
+ <input class="widefat" type="text" id="mc_api_key" name="nsu_mailinglist[mc_api_key]" value="
35
+ <?php
36
+ if ( isset( $opts['mc_api_key'] ) ) {
37
  echo esc_attr( $opts['mc_api_key'] );
38
+ }
39
+ ?>
40
+ " /></td>
41
  </tr>
42
  <tr valign="top">
43
+ <th scope="row">Mailchimp List ID
44
  <a href="http://www.mailchimp.com/kb/article/how-can-i-find-my-list-id" target="_blank">(?)</a></th>
45
  <td>
46
+ <input class="widefat" type="text" name="nsu_mailinglist[mc_list_id]" value="
47
+ <?php
48
+ if ( isset( $opts['mc_list_id'] ) ) {
49
  echo esc_attr( $opts['mc_list_id'] );
50
+ }
51
+ ?>
52
+ "; />
53
  </td>
54
  </tr>
55
  <tr valign="top">
57
  <label title="Prevents your users from having to confirm their emailaddress. Make sure you comply with the CAN SPAM act." for="mc_prevent_double_optin">Prevent double opt-in?</label>
58
  </th>
59
  <td>
60
+ <input type="checkbox" id="mc_prevent_double_optin" name="nsu_mailinglist[mc_no_double_optin]" value="1"
61
+ <?php
62
+ if ( isset( $opts['mc_no_double_optin'] ) ) {
63
  checked( $opts['mc_no_double_optin'], 1 );
64
+ }
65
+ ?>
66
+ /></td>
67
  </tr>
68
  <tr valign="top">
69
  <th scope="row"><label for="mc_use_groupings">Add to group(s)? </label></th>
70
  <td>
71
+ <input type="checkbox" id="mc_use_groupings" name="nsu_mailinglist[mc_use_groupings]" value="1"
72
+ <?php
73
+ if ( isset( $opts['mc_use_groupings'] ) ) {
74
  checked( $opts['mc_use_groupings'], 1 );
75
+ }
76
+ ?>
77
+ /></td>
78
  </tr>
79
+ <tbody class="mc_groupings_rows"
80
+ <?php
81
+ if ( ! isset( $opts['mc_use_groupings'] ) || $opts['mc_use_groupings'] != 1 ) {
82
  echo ' style="display:none" ';
83
+ }
84
+ ?>
85
+ >
86
  <tr valign="top">
87
  <th scope="row">Grouping name</th>
88
  <td>
89
+ <input class="widefat" type="text" id="mc_groupings_name" name="nsu_mailinglist[mc_groupings_name]" value="
90
+ <?php
91
+ if ( isset( $opts['mc_groupings_name'] ) ) {
92
  echo esc_attr( $opts['mc_groupings_name'] );
93
+ }
94
+ ?>
95
+ " /></td>
96
  </tr>
97
  <tr valign="top">
98
  <th scope="row">
100
  <small class="help">(comma delimited list of interest groups to add to)</small>
101
  </th>
102
  <td>
103
+ <input class="widefat" type="text" name="nsu_mailinglist[mc_groupings_groups]" placeholder="Example: Group 1,Group 2,Group 3" value="
104
+ <?php
105
+ if ( isset( $opts['mc_groupings_groups'] ) ) {
106
  echo esc_attr( $opts['mc_groupings_groups'] );
107
+ }
108
+ ?>
109
+ "; />
110
  </td>
111
  </tr>
112
  </tbody>
113
+ </tbody>
includes/views/parts/rows-phplist.php CHANGED
@@ -1,10 +1,12 @@
1
  <?php defined( 'ABSPATH' ) or exit; ?>
2
- <?php if ( ! isset( $opts['phplist_list_id'] ) ) {
 
3
  $opts['phplist_list_id'] = 1;
4
- } ?>
 
5
  <tr valign="top">
6
  <th scope="row">PHPList list ID</th>
7
  <td>
8
  <input type="text" class="widefat" name="nsu_mailinglist[phplist_list_id]" value="<?php echo esc_attr( $opts['phplist_list_id'] ); ?>" />
9
  </td>
10
- </tr>
1
  <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <?php
3
+ if ( ! isset( $opts['phplist_list_id'] ) ) {
4
  $opts['phplist_list_id'] = 1;
5
+ }
6
+ ?>
7
  <tr valign="top">
8
  <th scope="row">PHPList list ID</th>
9
  <td>
10
  <input type="text" class="widefat" name="nsu_mailinglist[phplist_list_id]" value="<?php echo esc_attr( $opts['phplist_list_id'] ); ?>" />
11
  </td>
12
+ </tr>
includes/views/parts/rows-ymlp.php CHANGED
@@ -4,34 +4,54 @@
4
  <small>(recommended)</small>
5
  </label></th>
6
  <td>
7
- <input type="checkbox" id="use_api" name="nsu_mailinglist[use_api]" value="1" <?php if ( isset( $opts['use_api'] ) ) {
 
 
8
  checked( $opts['use_api'], 1 );
9
- } ?> /></td>
 
 
10
  </tr>
11
- <tbody class="api_rows"<?php if ( ! isset( $opts['use_api'] ) || $opts['use_api'] != 1 ) {
 
 
12
  echo ' style="display:none" ';
13
- } ?>>
 
 
14
  <tr valign="top">
15
  <th scope="row">YMLP API Key <a target="_blank" href="http://www.ymlp.com/app/api.php">(?)</a></th>
16
  <td>
17
- <input class="widefat" type="text" id="ymlp_api_key" name="nsu_mailinglist[ymlp_api_key]" value="<?php if ( isset( $opts['ymlp_api_key'] ) ) {
 
 
18
  echo esc_attr( $opts['ymlp_api_key'] );
19
- } ?>" /></td>
 
 
20
  </tr>
21
  <tr valign="top">
22
  <th scope="row">YMLP Username</th>
23
  <td>
24
- <input class="widefat" type="text" id="ymlp_username" name="nsu_mailinglist[ymlp_username]" value="<?php if ( isset( $opts['ymlp_username'] ) ) {
 
 
25
  echo esc_attr( $opts['ymlp_username'] );
26
- } ?>" /></td>
 
 
27
  </tr>
28
  <tr valign="top">
29
  <th scope="row">YMLP GroupID<br />
30
  <small class="help">(starts at 1, check URL when 'viewing all contacts' in certain group)</small>
31
  </th>
32
  <td>
33
- <input class="widefat" type="text" id="ymlp_groupid" name="nsu_mailinglist[ymlp_groupid]" value="<?php if ( isset( $opts['ymlp_groupid'] ) ) {
 
 
34
  echo esc_attr( $opts['ymlp_groupid'] );
35
- } ?>" /></td>
 
 
36
  </tr>
37
- </tbody>
4
  <small>(recommended)</small>
5
  </label></th>
6
  <td>
7
+ <input type="checkbox" id="use_api" name="nsu_mailinglist[use_api]" value="1"
8
+ <?php
9
+ if ( isset( $opts['use_api'] ) ) {
10
  checked( $opts['use_api'], 1 );
11
+ }
12
+ ?>
13
+ /></td>
14
  </tr>
15
+ <tbody class="api_rows"
16
+ <?php
17
+ if ( ! isset( $opts['use_api'] ) || $opts['use_api'] != 1 ) {
18
  echo ' style="display:none" ';
19
+ }
20
+ ?>
21
+ >
22
  <tr valign="top">
23
  <th scope="row">YMLP API Key <a target="_blank" href="http://www.ymlp.com/app/api.php">(?)</a></th>
24
  <td>
25
+ <input class="widefat" type="text" id="ymlp_api_key" name="nsu_mailinglist[ymlp_api_key]" value="
26
+ <?php
27
+ if ( isset( $opts['ymlp_api_key'] ) ) {
28
  echo esc_attr( $opts['ymlp_api_key'] );
29
+ }
30
+ ?>
31
+ " /></td>
32
  </tr>
33
  <tr valign="top">
34
  <th scope="row">YMLP Username</th>
35
  <td>
36
+ <input class="widefat" type="text" id="ymlp_username" name="nsu_mailinglist[ymlp_username]" value="
37
+ <?php
38
+ if ( isset( $opts['ymlp_username'] ) ) {
39
  echo esc_attr( $opts['ymlp_username'] );
40
+ }
41
+ ?>
42
+ " /></td>
43
  </tr>
44
  <tr valign="top">
45
  <th scope="row">YMLP GroupID<br />
46
  <small class="help">(starts at 1, check URL when 'viewing all contacts' in certain group)</small>
47
  </th>
48
  <td>
49
+ <input class="widefat" type="text" id="ymlp_groupid" name="nsu_mailinglist[ymlp_groupid]" value="
50
+ <?php
51
+ if ( isset( $opts['ymlp_groupid'] ) ) {
52
  echo esc_attr( $opts['ymlp_groupid'] );
53
+ }
54
+ ?>
55
+ " /></td>
56
  </tr>
57
+ </tbody>
includes/views/parts/sidebar.php CHANGED
@@ -1,25 +1,31 @@
1
  <div id="nsu-sidebar">
2
 
3
  <div id="nsu-donate-box">
4
- <h3>Help us, help you</h3>
5
- <p>If you like Newsletter Sign-Up, consider showing a token of your appreciation:</p>
6
  <ul class="ul-square">
7
- <li><a href="https://wordpress.org/support/view/plugin-reviews/newsletter-sign-up?rate=5#postform" target="_blank">Give a &#9733;&#9733;&#9733;&#9733;&#9733; rating on WordPress.org</a></li>
8
- <li><a href="https://wordpress.org/plugins/newsletter-sign-up/#compatibility">Vote "works" on the Wordpress.org plugin page</a>
9
- </ul>
10
  </div>
11
 
12
- <div>
13
- <h3>Other plugins by the same author</h3>
14
- <ul class="ul-square">
15
- <li class="has-icon mc4wp"><a href="https://wordpress.org/plugins/mailchimp-for-wp/">MailChimp for WordPress</a></li>
16
- <li><a href="https://wordpress.org/plugins/boxzilla/">Boxzilla (pop-ups)</a></li>
17
- <li><a href="https://wordpress.org/plugins/html-forms/">HTML Forms</a></li>
18
- <li><a href="https://wordpress.org/plugins/dvk-social-sharing/">Social Sharing</a></li>
19
- <li class="has-icon rfb"><a href="https://wordpress.org/plugins/recent-facebook-posts/">Recent Facebook Posts</a></li>
20
 
21
- </ul>
22
- </div>
 
 
 
 
 
 
 
 
23
 
24
  <div>
25
  <h3>Need support?</h3>
1
  <div id="nsu-sidebar">
2
 
3
  <div id="nsu-donate-box">
4
+ <h3>Help us help you</h3>
5
+ <p>If you like Newsletter Sign-Up, consider showing a token of your appreciation:</p>
6
  <ul class="ul-square">
7
+ <li><a href="https://wordpress.org/support/view/plugin-reviews/newsletter-sign-up?rate=5#postform" target="_blank">Give a &#9733;&#9733;&#9733;&#9733;&#9733; rating on WordPress.org</a></li>
8
+ <li><a href="https://wordpress.org/plugins/newsletter-sign-up/#compatibility">Vote "works" on the Wordpress.org plugin page</a>
9
+ </ul>
10
  </div>
11
 
12
+ <div>
13
+ <h3>Our other plugins</h3>
14
+ <div style="margin: 12px 0;">
15
+ <div><strong><a href="https://wordpress.org/plugins/mailchimp-for-wp/">MC4WP: Mailchimp for WordPress</a></strong></div>
16
+ <div>The #1 Mailchimp plugin for WordPress.</div>
17
+ </div>
 
 
18
 
19
+ <div style="margin: 12px 0;">
20
+ <div><strong><a href="https://wordpress.org/plugins/koko-analytics/">Koko Analytics</a></strong></div>
21
+ <div>Privacy-friendly analytics plugin that does not use any external services.</div>
22
+ </div>
23
+
24
+ <div style="margin: 12px 0;">
25
+ <div><strong><a href="https://wordpress.org/plugins/boxzilla/">Boxzilla Pop-ups</a></strong></div>
26
+ <div>Pop-up or slide-in boxes that can be configured to show up at just the right time.</div>
27
+ </div>
28
+ </div>
29
 
30
  <div>
31
  <h3>Need support?</h3>
newsletter-sign-up.php CHANGED
@@ -1,36 +1,36 @@
1
- <?php
2
- /*
3
- Plugin Name: Newsletter Sign-Up
4
- Plugin URI: https://dannyvankooten.com/wordpress-plugins/newsletter-sign-up/
5
- Description: Adds various ways for your visitors to sign-up to your mailing list (checkbox, widget, form)
6
- Version: 2.0.8
7
- Author: Danny van Kooten
8
- Author URI: https://dannyvankooten.com
9
- License: GPL2
10
- */
11
-
12
- /* Copyright 2010-2019 Danny van Kooten (email: hi@dannyvankooten.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
- if( ! defined( 'ABSPATH' ) ) {
29
- exit;
30
- }
31
-
32
- define('NSU_VERSION_NUMBER', '2.0.8');
33
- define("NSU_PLUGIN_DIR", dirname( __FILE__ ) );
34
-
35
- require_once NSU_PLUGIN_DIR . '/includes/NSU.php';
36
- new NSU();
1
+ <?php
2
+ /*
3
+ Plugin Name: Newsletter Sign-Up
4
+ Plugin URI: https://dannyvankooten.com/wordpress-plugins/newsletter-sign-up/
5
+ Description: Adds various ways for your visitors to sign-up to your mailing list (checkbox, widget, form)
6
+ Version: 2.0.9
7
+ Author: Danny van Kooten
8
+ Author URI: https://dannyvankooten.com
9
+ License: GPL2
10
+ */
11
+
12
+ /* Copyright 2010-2019 Danny van Kooten (email: hi@dannyvankooten.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
+ if ( ! defined( 'ABSPATH' ) ) {
29
+ exit;
30
+ }
31
+
32
+ define( 'NSU_VERSION', '2.0.9' );
33
+ define( 'NSU_PLUGIN_DIR', dirname( __FILE__ ) );
34
+
35
+ require_once NSU_PLUGIN_DIR . '/includes/class-nsu.php';
36
+ new NSU();
phpcs.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <ruleset name="rules">
3
+ <description>rules</description>
4
+ <file>includes/</file>
5
+ <file>newsletter-sign-up.php</file>
6
+
7
+ <rule ref="WordPress-Core">
8
+ <exclude name="WordPress.PHP.YodaConditions" />
9
+ <exclude name="WordPress.WP.DeprecatedFunctions.get_settingsFound" />
10
+ <exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned" />
11
+ <exclude name="WordPress.Arrays.ArrayIndentation.ItemNotAligned" />
12
+ <exclude name="WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase" />
13
+ <exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning" />
14
+ </rule>
15
+
16
+ <rule ref="WordPress.WP.I18n">
17
+ <properties>
18
+ <property name="text_domain" type="array">
19
+ <element value="newsletter-sign-up" />
20
+ </property>
21
+ </properties>
22
+ </rule>
23
+
24
+ <rule ref="WordPress.WP.DeprecatedFunctions">
25
+ <properties>
26
+ <property name="minimum_supported_version" value="4.6"/>
27
+ </properties>
28
+ </rule>
29
+
30
+ <rule ref="WordPress.Files.FileName">
31
+ <properties>
32
+ <property name="strict_class_file_names" value="false"/>
33
+ </properties>
34
+ </rule>
35
+
36
+ <rule ref="WordPress.NamingConventions.ValidHookName">
37
+ <properties>
38
+ <property name="additionalWordDelimiters" value="-"/>
39
+ </properties>
40
+ </rule>
41
+
42
+ <rule ref="WordPress.WP.CronInterval">
43
+ <properties>
44
+ <property name="min_interval" value="60"/>
45
+ </properties>
46
+ </rule>
47
+
48
+ <arg name="colors" />
49
+ </ruleset>
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: DvanKooten, Ibericode
3
  Donate link: https://dannyvankooten.com/donate/
4
  Tags: newsletter, sign-up, mailchimp, aweber, ymlp, phplist, icontact, newsletter widget, subscribe widget
5
  Requires at least: 4.1
6
- Tested up to: 5.0
7
- Stable tag: 2.0.7
8
  License: GPL2
9
  Requires PHP: 5.3
10
 
@@ -18,11 +18,11 @@ Integrate your WordPress site with 3rd-party newsletter services like Aweber and
18
 
19
  This plugin adds various sign-up methods to your WordPress website, like sign-up checkboxes in your comment form and a sign-up form to show in posts, pages or widget areas.
20
 
21
- > **MailChimp user?**
22
  >
23
- > Use [MailChimp for WordPress](https://wordpress.org/plugins/mailchimp-for-wp/) instead. It's free & so much better.
24
 
25
- This plugin works with *almost all* third-party email marketing services including MailChimp, CampaignMonitor, ConstantContact, YMLP, Aweber, iContact, PHPList and Feedblitz. With the right configuration settings, you can make this plugin work with *any* newsletter service around.
26
 
27
  **Features:**
28
 
@@ -30,13 +30,13 @@ This plugin works with *almost all* third-party email marketing services includi
30
  * Easy customizable Newsletter Sign-Up Form Widget
31
  * Embed a sign-up form in your posts with a simple shortcode `[nsu_form]`.
32
  * Embed a sign-up form in your template files by calling `nsu_form();`
33
- * Use the MailChimp or YMLP API or any other third-party newsletter service.
34
  * Works with most major mailinglist services like Aweber, Constant Contact, iContact, etc.
35
  * Compatible with BuddyPress, MultiSite and bbPress.
36
 
37
  **More information**
38
 
39
- * [MailChimp for WordPress plugin](https://mc4wp.com/)
40
  * More [WordPress plugins](https://dannyvankooten.com/wordpress-plugins/) by ibericode
41
 
42
  = Sign-up checkboxes =
@@ -84,9 +84,9 @@ Yes, use the following code snippet in your theme files to display a sign-up for
84
 
85
  `if(function_exists('nsu_form')) nsu_form();`
86
 
87
- = Can I use this with MailChimp? =
88
 
89
- You can, but we recommend using [MailChimp for WordPress](https://wordpress.org/plugins/mailchimp-for-wp/) instead.
90
 
91
 
92
  == Screenshots ==
@@ -97,6 +97,13 @@ You can, but we recommend using [MailChimp for WordPress](https://wordpress.org/
97
 
98
  == Changelog ==
99
 
 
 
 
 
 
 
 
100
  = 2.0.8 - February 14, 2019 =
101
 
102
  Maintenance & updated compatibility test with WordPress 5.0.
@@ -170,7 +177,7 @@ Minor maintenance round. Removed obsolete HTML5 option, as 99.9% of browsers sup
170
 
171
  = 1.8 =
172
  * Fixed W3C error because of empty "action" attribute on form tag.
173
- * Added notice for MailChimp users to switch to my newer plugin, [MailChimp for WordPress](https://mc4wp.com/).
174
  * Further improved the CSS reset for the comment form checkbox
175
 
176
  = 1.7.9 =
@@ -195,7 +202,7 @@ Minor maintenance round. Removed obsolete HTML5 option, as 99.9% of browsers sup
195
  * Fixed: Hidden inputs are now wrapped by a block element too, so the form output validates as XHTML 1.0 STRICT.
196
 
197
  = 1.7.4 =
198
- * Added: Ability to turn off double opt-in (MailChimp API users only).
199
  * Improved: Various CSS improvements
200
 
201
  = 1.7.3 =
@@ -208,12 +215,12 @@ Minor maintenance round. Removed obsolete HTML5 option, as 99.9% of browsers sup
208
  * Fixed: Bug where you coudln't configure mailinglist specific settings (like MC API).
209
 
210
  = 1.7 =
211
- * Added: add subscribers to certain interest group(s) (limited to 1 grouping at the moment). (MailChimp API users only)
212
  * Improvement: Slightly better code readability
213
 
214
  = 1.6.1 =
215
  * Fixed notice on frontend when e-mail field not filled in
216
- * Fixed provided values for First and Lastname field for MailChimp when using both.
217
 
218
  = 1.6 =
219
  * Improvement: Huge backend changes. Everything is split up for increased maintainability.
3
  Donate link: https://dannyvankooten.com/donate/
4
  Tags: newsletter, sign-up, mailchimp, aweber, ymlp, phplist, icontact, newsletter widget, subscribe widget
5
  Requires at least: 4.1
6
+ Tested up to: 5.3
7
+ Stable tag: 2.0.9
8
  License: GPL2
9
  Requires PHP: 5.3
10
 
18
 
19
  This plugin adds various sign-up methods to your WordPress website, like sign-up checkboxes in your comment form and a sign-up form to show in posts, pages or widget areas.
20
 
21
+ > **Mailchimp user?**
22
  >
23
+ > Use [Mailchimp for WordPress](https://wordpress.org/plugins/mailchimp-for-wp/) instead. It's free & so much better.
24
 
25
+ This plugin works with *almost all* third-party email marketing services including Mailchimp, CampaignMonitor, ConstantContact, YMLP, Aweber, iContact, PHPList and Feedblitz. With the right configuration settings, you can make this plugin work with *any* newsletter service around.
26
 
27
  **Features:**
28
 
30
  * Easy customizable Newsletter Sign-Up Form Widget
31
  * Embed a sign-up form in your posts with a simple shortcode `[nsu_form]`.
32
  * Embed a sign-up form in your template files by calling `nsu_form();`
33
+ * Use the Mailchimp or YMLP API or any other third-party newsletter service.
34
  * Works with most major mailinglist services like Aweber, Constant Contact, iContact, etc.
35
  * Compatible with BuddyPress, MultiSite and bbPress.
36
 
37
  **More information**
38
 
39
+ * [Mailchimp for WordPress plugin](https://mc4wp.com/)
40
  * More [WordPress plugins](https://dannyvankooten.com/wordpress-plugins/) by ibericode
41
 
42
  = Sign-up checkboxes =
84
 
85
  `if(function_exists('nsu_form')) nsu_form();`
86
 
87
+ = Can I use this with Mailchimp? =
88
 
89
+ You can, but we recommend using [Mailchimp for WordPress](https://wordpress.org/plugins/mailchimp-for-wp/) instead.
90
 
91
 
92
  == Screenshots ==
97
 
98
  == Changelog ==
99
 
100
+ = 2.0.9 - Dec 5, 2019 =
101
+
102
+ - Fix code styling to adhere to WordPress' coding standards
103
+ - Add the plugin to GitHub: [ibericode/newsletter-sign-up](https://github.com/ibericode/newsletter-sign-up)
104
+ - Update tested WordPress version
105
+
106
+
107
  = 2.0.8 - February 14, 2019 =
108
 
109
  Maintenance & updated compatibility test with WordPress 5.0.
177
 
178
  = 1.8 =
179
  * Fixed W3C error because of empty "action" attribute on form tag.
180
+ * Added notice for Mailchimp users to switch to my newer plugin, [Mailchimp for WordPress](https://mc4wp.com/).
181
  * Further improved the CSS reset for the comment form checkbox
182
 
183
  = 1.7.9 =
202
  * Fixed: Hidden inputs are now wrapped by a block element too, so the form output validates as XHTML 1.0 STRICT.
203
 
204
  = 1.7.4 =
205
+ * Added: Ability to turn off double opt-in (Mailchimp API users only).
206
  * Improved: Various CSS improvements
207
 
208
  = 1.7.3 =
215
  * Fixed: Bug where you coudln't configure mailinglist specific settings (like MC API).
216
 
217
  = 1.7 =
218
+ * Added: add subscribers to certain interest group(s) (limited to 1 grouping at the moment). (Mailchimp API users only)
219
  * Improvement: Slightly better code readability
220
 
221
  = 1.6.1 =
222
  * Fixed notice on frontend when e-mail field not filled in
223
+ * Fixed provided values for First and Lastname field for Mailchimp when using both.
224
 
225
  = 1.6 =
226
  * Improvement: Huge backend changes. Everything is split up for increased maintainability.
trunk/LICENSE ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ {description}
294
+ Copyright (C) {year} {fullname}
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ {signature of Ty Coon}, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
trunk/assets/css/admin.css ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #nsu-admin { }
2
+ #nsu-main { width:65%; float:left; }
3
+ #nsu-sidebar{ width:30%; float:right; }
4
+
5
+ #nsu-sidebar > div{ margin-bottom:40px; }
6
+ #nsu-sidebar > div h3 {
7
+ padding-bottom: 10px;
8
+ border-bottom: 1px solid #ccc;
9
+ }
10
+
11
+ #nsu-admin li.has-icon { list-style:none; padding-left:25px; margin-left:-25px; background-position:left center; background-repeat: no-repeat; }
12
+ #nsu-admin li.dvk-email{ background-image:url("../img/email-icon.png"); }
13
+ #nsu-admin li.dvk-twitter{ background-image:url("../img/twitter-icon.png")}
14
+ #nsu-admin li.mc4wp{ background-image:url("../img/mailchimp-for-wp-icon.png"); }
15
+ #nsu-admin li.rfb{ background-image:url("../img/recent-facebook-posts-icon.png"); }
16
+
17
+ #nsu-admin .help {
18
+ display: block;
19
+ font-style: italic;
20
+ font-weight: normal;
21
+ }
trunk/assets/css/checkbox.css ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+
2
+ /* Newsletter Sign-Up - Checkbox */
3
+ #nsu-checkbox { clear:both; display:block; }
4
+ #nsu-checkbox-input { position:relative; margin:0 5px 0 0; padding:0; height:13px; width:13px; display:inline-block !important; -webkit-appearance: checkbox; }
5
+ #nsu-checkbox-label { cursor:pointer; line-height:normal; }
6
+ #registerform #nsu-checkbox{ margin-bottom:10px; }
trunk/assets/css/css.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Set headers to serve CSS and encourage browser caching
3
+ $expires = 60 * 60 * 34 * 3; // cache time: 3 days
4
+ header('Content-Type: text/css; charset: UTF-8');
5
+ header("Cache-Control: public, max-age=" . $expires);
6
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
7
+
8
+ if( isset( $_GET['checkbox'] ) ) {
9
+ readfile( dirname( __FILE__ ) . '/checkbox.css' );
10
+ }
11
+
12
+ if( isset( $_GET['form'] ) ) {
13
+ readfile( dirname( __FILE__ ) . '/form.css' );
14
+ }
15
+
16
+ exit;
trunk/assets/css/form.css ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .nsu-form { margin:1em 0; }
2
+ .nsu-form > :first-child{ margin-top: 0; }
3
+ .nsu-form > :last-child{ margin-bottom:0; }
4
+
5
+ .nsu-form p { text-align:left; margin:1em 0; }
6
+
7
+ .nsu-form label{ display:block; font-weight:bold; margin-bottom:3px; text-align:left; }
8
+ .nsu-form input[type="text"],
9
+ .nsu-form input[type="email"],
10
+ .nsu-form input[type="tel"],
11
+ .nsu-form input[type="url"] { display:block; width:100%; height:auto; box-sizing:border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; }
12
+ .nsu-form input[type="submit"], .nsu-form button { display:block; }
13
+
14
+ .nsu-error { color: red; font-style:italic; }
trunk/assets/css/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header( 'Status: 403 Forbidden' );
5
+ header( 'HTTP/1.1 403 Forbidden' );
6
+ exit;
trunk/assets/img/close.png ADDED
Binary file
trunk/assets/img/email-icon.png ADDED
Binary file
trunk/assets/img/icon.png ADDED
Binary file
trunk/assets/img/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header( 'Status: 403 Forbidden' );
5
+ header( 'HTTP/1.1 403 Forbidden' );
6
+ exit;
trunk/assets/img/mailchimp-for-wp-icon.png ADDED
Binary file
trunk/assets/img/overlay.png ADDED
Binary file
trunk/assets/img/recent-facebook-posts-icon.png ADDED
Binary file
trunk/assets/img/rss-icon.png ADDED
Binary file
trunk/assets/img/twitter-icon.png ADDED
Binary file
trunk/assets/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header( 'Status: 403 Forbidden' );
5
+ header( 'HTTP/1.1 403 Forbidden' );
6
+ exit;
trunk/assets/js/admin.js ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function(){
2
+
3
+ var api_rows = jQuery("tbody.api_rows");
4
+ var form_rows = jQuery("tbody.form_rows");
5
+ var mc_groupings_rows = jQuery("tbody.mc_groupings_rows");
6
+ var name_dependent_rows = jQuery('tr.name_dependent');
7
+
8
+ jQuery("#use_api").change(function(){
9
+ if(jQuery(this).attr('checked')) {
10
+ api_rows.show();
11
+ form_rows.hide();
12
+ } else {
13
+ api_rows.hide();
14
+ form_rows.show();
15
+ }
16
+ });
17
+
18
+ jQuery("#mc_use_groupings").change(function(){
19
+ if(jQuery(this).attr('checked')) {
20
+ mc_groupings_rows.show();
21
+ } else {
22
+ mc_groupings_rows.hide();
23
+ }
24
+ });
25
+
26
+ jQuery("#subscribe_with_name").change(function(){
27
+ if(jQuery(this).attr('checked')) {
28
+ name_dependent_rows.show();
29
+ } else {
30
+ name_dependent_rows.hide();
31
+ }
32
+ });
33
+
34
+ });
trunk/assets/js/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header( 'Status: 403 Forbidden' );
5
+ header( 'HTTP/1.1 403 Forbidden' );
6
+ exit;
trunk/includes/class-nsu-admin.php ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class NSU_Admin {
4
+
5
+ private $hook = 'newsletter-sign-up';
6
+ private $longname = 'Newsletter Sign-Up';
7
+ private $filename = 'newsletter-sign-up/newsletter-sign-up.php';
8
+ private $accesslvl = 'manage_options';
9
+ private $bp_active = false;
10
+ private $options = array();
11
+
12
+ public function __construct() {
13
+ $this->options = NSU::instance()->get_options();
14
+
15
+ add_filter( "plugin_action_links_{$this->filename}", array( $this, 'add_settings_link' ) );
16
+ add_action( 'admin_menu', array( $this, 'add_option_page' ) );
17
+ add_action( 'admin_init', array( $this, 'settings_init' ) );
18
+ add_action( 'admin_enqueue_scripts', array( $this, 'load_css_and_js' ) );
19
+ add_action( 'bp_include', array( $this, 'set_bp_active' ) );
20
+
21
+ if ( isset( $_GET['nsu-hide-mc4wp-notice'] ) ) {
22
+ add_option( 'nsu_hide_mc4wp_notice', true, false );
23
+ } elseif ( $this->options['mailinglist']['provider'] == 'mailchimp' && get_option( 'nsu_hide_mc4wp_notice' ) == false ) {
24
+ add_action( 'admin_notices', array( $this, 'notice_mailchimp_for_wp' ) );
25
+ }
26
+
27
+ }
28
+
29
+ public function get_checkbox_compatible_plugins() {
30
+ $checkbox_plugins = array(
31
+ 'comment_form' => 'Comment form',
32
+ 'registration_form' => 'Registration form',
33
+ );
34
+ if ( is_multisite() ) {
35
+ $checkbox_plugins['ms_form'] = 'MultiSite forms'; }
36
+ if ( class_exists( 'BuddyPress' ) ) {
37
+ $checkbox_plugins['bp_form'] = 'BuddyPress registration';
38
+ }
39
+ if ( class_exists( 'bbPress' ) ) {
40
+ $checkbox_plugins['bbpress_forms'] = 'bbPress';
41
+ }
42
+ return $checkbox_plugins;
43
+ }
44
+
45
+ public function notice_mailchimp_for_wp() { ?>
46
+ <div class="updated">
47
+ <p><strong>Newsletter Sign-Up Notice:</strong> You are using Mailchimp, great! Please consider switching to our improved <a href="https://mc4wp.com/">Mailchimp for WordPress</a> plugin.
48
+ It can be downloaded from the WordPress repository <a href="https://wordpress.org/plugins/mailchimp-for-wp/">here</a>. | <a href="?nsu-hide-mc4wp-notice=1">Hide Notice</a></p>
49
+ </div>
50
+ <?php
51
+ }
52
+
53
+ public function load_css_and_js( $hook ) {
54
+ if ( ! stripos( $hook, $this->hook ) ) {
55
+ return false; }
56
+
57
+ wp_enqueue_style( $this->hook, plugins_url( 'newsletter-sign-up/assets/css/admin.css' ) );
58
+ wp_enqueue_script( $this->hook, plugins_url( 'newsletter-sign-up/assets/js/admin.js' ), array( 'jquery' ) );
59
+ }
60
+
61
+ /**
62
+ * If buddypress is loaded, set buddypress_active to TRUE
63
+ */
64
+ public function set_bp_active() {
65
+ $this->bp_active = true;
66
+ }
67
+
68
+ /**
69
+ * The default settings page
70
+ */
71
+ public function options_page_default() {
72
+ $tab = 'mailinglist-settings';
73
+ $opts = $this->options['mailinglist'];
74
+
75
+ $viewed_mp = null;
76
+ if ( ! empty( $_GET['mp'] ) ) {
77
+ $viewed_mp = $_GET['mp'];
78
+ } elseif ( empty( $_GET['mp'] ) && isset( $opts['provider'] ) ) {
79
+ $viewed_mp = $opts['provider'];
80
+ }
81
+ if ( ! in_array( $viewed_mp, array( 'mailchimp', 'icontact', 'aweber', 'phplist', 'ymlp', 'other' ) ) ) {
82
+ $viewed_mp = null;
83
+ }
84
+
85
+ // Fill in some predefined values if options not set or set for other newsletter service
86
+ if ( $opts['provider'] != $viewed_mp ) {
87
+ switch ( $viewed_mp ) {
88
+
89
+ case 'mailchimp':
90
+ if ( empty( $opts['email_id'] ) ) {
91
+ $opts['email_id'] = 'EMAIL';
92
+ }
93
+ if ( empty( $opts['name_id'] ) ) {
94
+ $opts['name_id'] = 'NAME';
95
+ }
96
+ break;
97
+
98
+ case 'ymlp':
99
+ if ( empty( $opts['email_id'] ) ) {
100
+ $opts['email_id'] = 'YMP0';
101
+ }
102
+ break;
103
+
104
+ case 'aweber':
105
+ if ( empty( $opts['form_action'] ) ) {
106
+ $opts['form_action'] = 'http://www.aweber.com/scripts/addlead.pl';
107
+ }
108
+ if ( empty( $opts['email_id'] ) ) {
109
+ $opts['email_id'] = 'email';
110
+ }
111
+ if ( empty( $opts['name_id'] ) ) {
112
+ $opts['name_id'] = 'name';
113
+ }
114
+ break;
115
+
116
+ case 'icontact':
117
+ if ( empty( $opts['email_id'] ) ) {
118
+ $opts['email_id'] = 'fields_email';
119
+ }
120
+ break;
121
+ }
122
+ }
123
+
124
+ require_once NSU_PLUGIN_DIR . '/includes/views/dashboard.php';
125
+ }
126
+
127
+ /**
128
+ * The admin page for managing checkbox settings
129
+ */
130
+ public function options_page_checkbox_settings() {
131
+ $tab = 'checkbox-settings';
132
+ $opts = $this->options['checkbox'];
133
+ require_once NSU_PLUGIN_DIR . '/includes/views/checkbox-settings.php';
134
+ }
135
+
136
+ /**
137
+ * The admin page for managing form settings
138
+ */
139
+ public function options_page_form_settings() {
140
+ $tab = 'form-settings';
141
+ $opts = $this->options['form'];
142
+ $opts['mailinglist'] = $this->options['mailinglist'];
143
+ require_once NSU_PLUGIN_DIR . '/includes/views/form-settings.php';
144
+ }
145
+
146
+ /**
147
+ * The page for the configuration extractor
148
+ */
149
+ public function options_page_config_helper() {
150
+ $tab = 'config-helper';
151
+
152
+ if ( isset( $_POST['form'] ) && ! empty( $_POST['form'] ) ) {
153
+
154
+ $result = $this->extract_form_config( $_POST['form'] );
155
+
156
+ }
157
+
158
+ require_once NSU_PLUGIN_DIR . '/includes/views/config-helper.php';
159
+ }
160
+
161
+ private function extract_form_config( $form_html ) {
162
+
163
+ // strip unneccessary tags
164
+ $form = stripslashes( strip_tags( $form_html, '<form><label><input><select><textarea><button>' ) );
165
+
166
+ // set defaults
167
+ $form_action = '';
168
+ $email_name = 'Sorry, can\'t help you with this one.';
169
+ $name_name = 'Sorry, can\'t help you with this one.';
170
+ $additional_data = array();
171
+
172
+ preg_match_all( "'<(.*?)>'si", $form, $matches );
173
+
174
+ if ( is_array( $matches ) && isset( $matches[0] ) ) {
175
+ $matches = $matches[0];
176
+ $html = join( '', $matches );
177
+ } else {
178
+ $html = $form;
179
+ }
180
+
181
+ // fake wrap in html and body tags
182
+ $html = '<html><body>' . $html . '</body></html>';
183
+
184
+ $doc = new DOMDocument();
185
+ $doc->strictErrorChecking = false;
186
+ $doc->loadHTML( $html );
187
+
188
+ if ( $doc->firstChild === null || $doc->firstChild->firstChild === null ) {
189
+ return;
190
+ }
191
+
192
+ $xml = simplexml_import_dom( $doc );
193
+
194
+ if ( is_object( $xml ) ) {
195
+ $form = $xml->body->form;
196
+
197
+ if ( $form ) {
198
+
199
+ $form_action = ( isset( $form['action'] ) ) ? $form['action'] : 'Can\'t help you on this one..';
200
+
201
+ if ( $form->input ) {
202
+
203
+ /* Loop trough input fields */
204
+ foreach ( $form->input as $input ) {
205
+
206
+ // Check if this is a hidden field
207
+ if ( $input['type'] == 'hidden' ) {
208
+ $additional_data[] = array( $input['name'], $input['value'] );
209
+ // Check if this is the input field that is supposed to hold the EMAIL data
210
+ } elseif ( stripos( $input['id'], 'email' ) !== false || stripos( $input['name'], 'email' ) !== false ) {
211
+ $email_name = $input['name'];
212
+
213
+ // Check if this is the input field that is supposed to hold the NAME data
214
+ } elseif ( stripos( $input['id'], 'name' ) !== false || stripos( $input['name'], 'name' ) !== false ) {
215
+ $name_name = $input['name'];
216
+ }
217
+
218
+ // remove input attributes
219
+ unset( $input['id'] );
220
+ unset( $input['class'] );
221
+ unset( $input['style'] );
222
+ unset( $input['onfocus'] );
223
+ unset( $input['onblur'] );
224
+ unset( $input['size'] );
225
+ }
226
+ }
227
+
228
+ // remove form attributes
229
+ unset( $form['target'] );
230
+ unset( $form['id'] );
231
+ unset( $form['name'] );
232
+ unset( $form['class'] );
233
+ unset( $form['onsubmit'] );
234
+ unset( $form['enctype'] );
235
+ }
236
+ }
237
+
238
+ $doc->removeChild( $doc->firstChild );
239
+ $doc->replaceChild( $doc->firstChild->firstChild->firstChild, $doc->firstChild );
240
+
241
+ $simpler_form = $doc->saveHTML();
242
+
243
+ // add tabs for improved readability
244
+ $simpler_form = str_replace( array( '><', '<input' ), array( ">\n<", "\t<input" ), $simpler_form );
245
+
246
+ return array(
247
+ 'simpler_form' => $simpler_form,
248
+ 'form_action' => $form_action,
249
+ 'email_name' => $email_name,
250
+ 'name_name' => $name_name,
251
+ 'additional_data' => $additional_data,
252
+ );
253
+ }
254
+
255
+
256
+ /**
257
+ * Adds the different menu pages
258
+ */
259
+ public function add_option_page() {
260
+ add_menu_page( $this->longname, 'Newsl. Sign-up', $this->accesslvl, $this->hook, array( $this, 'options_page_default' ), plugins_url( 'newsletter-sign-up/assets/img/icon.png' ) );
261
+ add_submenu_page( $this->hook, 'Newsletter Sign-Up :: Mailinglist Settings', 'List Settings', $this->accesslvl, $this->hook, array( $this, 'options_page_default' ) );
262
+ add_submenu_page( $this->hook, 'Newsletter Sign-Up :: Checkbox Settings', 'Checkbox Settings', $this->accesslvl, $this->hook . '-checkbox-settings', array( $this, 'options_page_checkbox_settings' ) );
263
+ add_submenu_page( $this->hook, 'Newsletter Sign-Up :: Form Settings', 'Form Settings', $this->accesslvl, $this->hook . '-form-settings', array( $this, 'options_page_form_settings' ) );
264
+ add_submenu_page( $this->hook, 'Newsletter Sign-Up :: Configuration Extractor', 'Config Extractor', $this->accesslvl, $this->hook . '-config-helper', array( $this, 'options_page_config_helper' ) );
265
+ }
266
+
267
+ /**
268
+ * Adds the settings link on the plugin's overview page
269
+ * @param array $links Array containing all the settings links for the various plugins.
270
+ * @return array The new array containing all the settings links
271
+ */
272
+ public function add_settings_link( $links ) {
273
+ $url = admin_url( 'admin.php?page=' . $this->hook );
274
+ $settings_link = '<a href="' . $url . '">Settings</a>';
275
+ array_unshift( $links, $settings_link );
276
+ return $links;
277
+ }
278
+
279
+ /**
280
+ * Registers the settings using WP Settings API.
281
+ */
282
+ public function settings_init() {
283
+ register_setting( 'nsu_form_group', 'nsu_form', array( $this, 'validate_form_options' ) );
284
+ register_setting( 'nsu_mailinglist_group', 'nsu_mailinglist', array( $this, 'validate_mailinglist_options' ) );
285
+ register_setting( 'nsu_checkbox_group', 'nsu_checkbox', array( $this, 'validate_checkbox_options' ) );
286
+ }
287
+
288
+ /**
289
+ * Validate the submitted options
290
+ * @param array $options The submitted options
291
+ * @return array
292
+ */
293
+ public function validate_options( $options ) {
294
+ return $options;
295
+ }
296
+
297
+ public function validate_form_options( $options ) {
298
+
299
+ $options['text_after_signup'] = strip_tags( $options['text_after_signup'], '<a><b><strong><i><img><em><br><p><ul><li><ol>' );
300
+
301
+ // redirect to url should start with http
302
+ if ( isset( $options['redirect_to'] ) && substr( $options['redirect_to'], 0, 4 ) != 'http' ) {
303
+ $options['redirect_to'] = '';
304
+ }
305
+
306
+ $options['name_required'] = ( isset( $options['name_required'] ) ) ? 1 : 0;
307
+ $options['wpautop'] = ( isset( $options['wpautop'] ) ) ? 1 : 0;
308
+ $options['load_form_css'] = ( isset( $options['load_form_css'] ) ) ? 1 : 0;
309
+
310
+ return $options;
311
+ }
312
+
313
+ public function validate_mailinglist_options( $options ) {
314
+ if ( is_array( $options['extra_data'] ) ) {
315
+ foreach ( $options['extra_data'] as $key => $value ) {
316
+ if ( empty( $value['name'] ) ) {
317
+ unset( $options['extra_data'][ $key ] );
318
+ }
319
+ }
320
+ }
321
+
322
+ return $options;
323
+ }
324
+
325
+ public function validate_checkbox_options( $options ) {
326
+ $options['add_to_comment_form'] = ( isset( $options['add_to_comment_form'] ) ) ? 1 : 0;
327
+ return $options;
328
+ }
329
+
330
+ }
trunk/includes/class-nsu-checkbox.php ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class NSU_Checkbox {
4
+ /**
5
+ * @var bool
6
+ */
7
+ private $showed_checkbox = false;
8
+
9
+ /** @var array */
10
+ private $options;
11
+
12
+ public function __construct() {
13
+ $options = NSU::instance()->get_options();
14
+ $this->options = $options['checkbox'];
15
+
16
+ // add hooks
17
+ if ( $this->options['add_to_comment_form'] == 1 ) {
18
+ add_action( 'thesis_hook_after_comment_box', array( $this, 'output_checkbox' ), 20 );
19
+ add_action( 'comment_form', array( $this, 'output_checkbox' ), 20 );
20
+ add_action( 'comment_post', array( $this, 'grab_email_from_comment' ), 20, 2 );
21
+ }
22
+
23
+ if ( $this->options['add_to_registration_form'] == 1 ) {
24
+ add_action( 'register_form', array( $this, 'output_checkbox' ), 20 );
25
+ add_action( 'register_post', array( $this, 'grab_email_from_wp_signup' ), 50 );
26
+ }
27
+
28
+ if ( $this->options['add_to_buddypress_form'] == 1 ) {
29
+ add_action( 'bp_before_registration_submit_buttons', array( $this, 'output_checkbox' ), 20 );
30
+ add_action( 'bp_complete_signup', array( $this, 'grab_email_from_wp_signup' ), 20 );
31
+ }
32
+
33
+ if ( $this->options['add_to_multisite_form'] == 1 ) {
34
+ add_action( 'signup_extra_fields', array( $this, 'output_checkbox' ), 20 );
35
+ add_action( 'signup_blogform', array( $this, 'add_hidden_checkbox' ), 20 );
36
+ add_filter( 'add_signup_meta', array( $this, 'add_checkbox_to_usermeta' ) );
37
+ add_action( 'wpmu_activate_blog', array( $this, 'grab_email_from_ms_blog_signup' ), 20, 5 );
38
+ add_action( 'wpmu_activate_user', array( $this, 'grab_email_from_ms_user_signup' ), 20, 3 );
39
+ }
40
+
41
+ /* bbPress actions */
42
+ if ( $this->options['add_to_bbpress_forms'] ) {
43
+ add_action( 'bbp_theme_after_topic_form_subscriptions', array( $this, 'output_checkbox' ), 10 );
44
+ add_action( 'bbp_theme_after_reply_form_subscription', array( $this, 'output_checkbox' ), 10 );
45
+ add_action( 'bbp_theme_anonymous_form_extras_bottom', array( $this, 'output_checkbox' ), 10 );
46
+ add_action( 'bbp_new_topic', array( $this, 'subscribe_from_bbpress_new_topic' ), 10, 4 );
47
+ add_action( 'bbp_new_reply', array( $this, 'subscribe_from_bbpress_new_reply' ), 10, 5 );
48
+ }
49
+
50
+ }
51
+
52
+
53
+ /**
54
+ * Outputs the sign-up checkbox, will only run once.
55
+ *
56
+ * @return bool
57
+ */
58
+ public function output_checkbox() {
59
+ $opts = $this->options;
60
+
61
+ // If using option to hide checkbox for subscribers and cookie is set, set instance variable showed_checkbox to true so checkbox won't show.
62
+ if ( $opts['cookie_hide'] == 1 && isset( $_COOKIE['ns_subscriber'] ) ) {
63
+ $this->showed_checkbox = true;
64
+ }
65
+
66
+ // User could have rendered the checkbox by manually adding 'the hook 'ns_comment_checkbox()' to their comment form
67
+ // If so, abandon function.
68
+ if ( $this->showed_checkbox ) {
69
+ return false;
70
+ }
71
+
72
+ ?>
73
+ <!-- Checkbox by Newsletter Sign-Up Checkbox v<?php echo NSU_VERSION; ?> - https://wordpress.org/plugins/newsletter-sign-up/ -->
74
+ <p id="nsu-checkbox">
75
+ <label for="nsu-checkbox-input" id="nsu-checkbox-label">
76
+ <input value="1" id="nsu-checkbox-input" type="checkbox" name="newsletter-sign-up-do" <?php checked( $opts['precheck'], 1 ); ?> />
77
+ <?php echo $opts['text']; ?>
78
+ </label>
79
+ </p>
80
+ <!-- / Newsletter Sign-Up -->
81
+ <?php
82
+
83
+ // make sure checkbox doesn't show again
84
+ $this->showed_checkbox = true;
85
+
86
+ return true;
87
+ }
88
+
89
+ /**
90
+ * 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
91
+ */
92
+ function add_hidden_checkbox() {
93
+ ?>
94
+ <input type="hidden" name="newsletter-sign-up-do" value="<?php echo ( isset( $_POST['newsletter-sign-up-do'] ) ) ? 1 : 0; ?>" />
95
+ <?php
96
+ }
97
+
98
+ /**
99
+ * Save the value of the checkbox to MultiSite sign-ups table
100
+ */
101
+ function add_checkbox_to_usermeta( $meta ) {
102
+ $meta['newsletter-sign-up-do'] = ( isset( $_POST['newsletter-sign-up-do'] ) ) ? 1 : 0;
103
+
104
+ return $meta;
105
+ }
106
+
107
+ /**
108
+ * Perform the sign-up for users that registered trough a MultiSite register form
109
+ * This function differs because of the need to grab the emailadress from the user using get_userdata
110
+ *
111
+ * @param int $user_id : the ID of the new user
112
+ * @param string $password : the password, we don't actually use this
113
+ * @param array $meta : the meta values that belong to this user, holds the value of our 'newsletter-sign-up' checkbox.
114
+ */
115
+ public function grab_email_from_ms_user_signup( $user_id, $password = null, $meta = null ) {
116
+
117
+ // only add meta if sign-up checkbox was checked
118
+ if ( ! isset( $meta['newsletter-sign-up-do'] ) || $meta['newsletter-sign-up-do'] != 1 ) {
119
+ return;
120
+ }
121
+ $user_info = get_userdata( $user_id );
122
+
123
+ $email = $user_info->user_email;
124
+ $name = $user_info->first_name;
125
+
126
+ NSU::instance()->send_post_data( $email, $name );
127
+ }
128
+
129
+ /**
130
+ * Perform the sign-up for users that registered trough a MultiSite register form
131
+ * This function differs because of the need to grab the emailadress from the user using get_userdata
132
+ *
133
+ * @param int $blog_id The id of the new blow
134
+ * @param int $user_id The ID of the new user
135
+ * @param mixed $a No idea, seriously.
136
+ * @param mixed $b No idea, seriously.
137
+ * @param array $meta The meta values that belong to this user, holds the value of our 'newsletter-sign-up' checkbox.
138
+ */
139
+ public function grab_email_from_ms_blog_signup( $blog_id, $user_id, $a, $b, $meta ) {
140
+
141
+ // only subscribe this user if he checked the sign-up checkbox
142
+ if ( ! isset( $meta['newsletter-sign-up-do'] ) || $meta['newsletter-sign-up-do'] != 1 ) {
143
+ return;
144
+ }
145
+
146
+ $user_info = get_userdata( $user_id );
147
+
148
+ $email = $user_info->user_email;
149
+ $name = $user_info->first_name;
150
+
151
+ NSU::instance()->send_post_data( $email, $name );
152
+ }
153
+
154
+ /**
155
+ * Grab the emailadress (and name) from a regular WP or BuddyPress sign-up and then send this to mailinglist.
156
+ */
157
+ function grab_email_from_wp_signup() {
158
+
159
+ // only act if checkbox was checked
160
+ if ( $_POST['newsletter-sign-up-do'] != 1 ) {
161
+ return;
162
+ }
163
+
164
+ if ( isset( $_POST['user_email'] ) ) {
165
+
166
+ // gather emailadress from user who WordPress registered
167
+ $email = sanitize_text_field( $_POST['user_email'] );
168
+ $name = sanitize_text_field( $_POST['user_login'] );
169
+
170
+ } elseif ( isset( $_POST['signup_email'] ) ) {
171
+
172
+ // gather emailadress from user who BuddyPress registered
173
+ $email = sanitize_text_field( $_POST['signup_email'] );
174
+ $name = sanitize_text_field( $_POST['signup_username'] );
175
+
176
+ } else {
177
+ return false;
178
+ }
179
+
180
+ NSU::instance()->send_post_data( $email, $name );
181
+ }
182
+
183
+ /**
184
+ * Grab the emailadress and name from comment and then send it to mailinglist.
185
+ *
186
+ * @param int $cid the ID of the comment
187
+ * @param string $comment_approved the comment object, optionally
188
+ *
189
+ * @return bool
190
+ */
191
+ public function grab_email_from_comment( $cid, $comment_approved = '' ) {
192
+
193
+ if ( ! isset( $_POST['newsletter-sign-up-do'] ) || $_POST['newsletter-sign-up-do'] != 1 ) {
194
+ return false;
195
+ }
196
+
197
+ if ( $comment_approved === 'spam' ) {
198
+ return false;
199
+ }
200
+
201
+ // get comment data
202
+ $comment = get_comment( $cid );
203
+
204
+ $email = $comment->comment_author_email;
205
+ $name = $comment->comment_author;
206
+
207
+ return NSU::instance()->send_post_data( $email, $name );
208
+ }
209
+
210
+ public function subscribe_from_bbpress( $anonymous_data, $user_id ) {
211
+ // only act if sign-up checkbox was checked
212
+ if ( ! isset( $_POST['newsletter-sign-up-do'] ) || $_POST['newsletter-sign-up-do'] != 1 ) {
213
+ return false;
214
+ }
215
+
216
+ if ( $anonymous_data ) {
217
+
218
+ $email = $anonymous_data['bbp_anonymous_email'];
219
+ $name = $anonymous_data['bbp_anonymous_name'];
220
+
221
+ } elseif ( $user_id ) {
222
+
223
+ $user_info = get_userdata( $user_id );
224
+ $email = $user_info->user_email;
225
+ $name = $user_info->first_name . ' ' . $user_info->last_name;
226
+
227
+ } else {
228
+ return false;
229
+ }
230
+
231
+ return NSU::instance()->send_post_data( $email, $name );
232
+ }
233
+
234
+ public function subscribe_from_bbpress_new_topic( $topic_id, $forum_id, $anonymous_data, $topic_author ) {
235
+ return $this->subscribe_from_bbpress( $anonymous_data, $topic_author );
236
+ }
237
+
238
+ public function subscribe_from_bbpress_new_reply( $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author ) {
239
+ return $this->subscribe_from_bbpress( $anonymous_data, $reply_author );
240
+ }
241
+
242
+ }
trunk/includes/class-nsu-form.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class NSU_Form {
4
+
5
+ private $validation_errors = array();
6
+ private $number_of_forms = 0;
7
+ private $options = array();
8
+
9
+ public function __construct() {
10
+ // add hooks
11
+ $options = NSU::instance()->get_options();
12
+ $this->options = $options;
13
+
14
+ // register the shortcode which can be used to output sign-up form
15
+ add_shortcode( 'newsletter-sign-up-form', array( $this, 'form_shortcode' ) );
16
+ add_shortcode( 'nsu-form', array( $this, 'form_shortcode' ) );
17
+ add_shortcode( 'nsu_form', array( $this, 'form_shortcode' ) );
18
+
19
+ if ( isset( $_POST['nsu_submit'] ) ) {
20
+ add_action( 'init', array( $this, 'submit' ) );
21
+ }
22
+ }
23
+
24
+ /**
25
+ * Check if ANY Newsletter Sign-Up form has been submitted.
26
+ */
27
+ public function submit() {
28
+
29
+ $opts = $this->options['form'];
30
+ $errors = array();
31
+
32
+ $email = ( isset( $_POST['nsu_email'] ) ) ? sanitize_text_field( $_POST['nsu_email'] ) : '';
33
+ $name = ( isset( $_POST['nsu_name'] ) ) ? sanitize_text_field( $_POST['nsu_name'] ) : '';
34
+
35
+ // has the honeypot been filled?
36
+ if ( ! empty( $_POST['nsu_robocop'] ) ) {
37
+ return false;
38
+ }
39
+
40
+ // if name is required, check it it was given
41
+ if ( $this->options['mailinglist']['subscribe_with_name'] == 1 && $opts['name_required'] == 1 && empty( $name ) ) {
42
+ $errors['name-field'] = $opts['text_empty_name'];
43
+ }
44
+
45
+ // validate email
46
+ if ( empty( $email ) ) {
47
+ $errors['email-field'] = $opts['text_empty_email'];
48
+ } elseif ( ! is_string( $email ) || ! is_email( $email ) ) {
49
+ $errors['email-field'] = $opts['text_invalid_email'];
50
+ }
51
+
52
+ // store errors as property
53
+ $this->validation_errors = $errors;
54
+
55
+ // send request to service if no errors occured
56
+ if ( count( $this->validation_errors ) == 0 ) {
57
+ NSU::instance()->send_post_data( $email, $name, 'form' );
58
+ return true;
59
+ }
60
+
61
+ return false;
62
+ }
63
+
64
+ /**
65
+ * The NSU form shortcode function. Calls the output_form method
66
+ *
67
+ * @param array $atts Not used
68
+ * @param string $content Not used
69
+ *
70
+ * @return string Form HTML-code
71
+ */
72
+ public function form_shortcode( $atts = null, $content = '' ) {
73
+ return $this->output_form( false );
74
+ }
75
+
76
+ /**
77
+ * Generate the HTML for a form
78
+ *
79
+ * @param boolean $echo Should HTML be echo'ed?
80
+ *
81
+ * @return string The generated HTML
82
+ */
83
+ public function output_form( $echo = true ) {
84
+
85
+ $errors = $this->validation_errors;
86
+ $opts = NSU::instance()->get_options();
87
+
88
+ $additional_fields = '';
89
+ $output = "\n<!-- Form by Newsletter Sign-Up v" . NSU_VERSION . " - https://wordpress.org/plugins/newsletter-sign-up/ -->\n";
90
+
91
+ $formno = $this->number_of_forms ++;
92
+
93
+ /* Set up form variables for API usage or normal form */
94
+ if ( $opts['mailinglist']['use_api'] == 1 ) {
95
+
96
+ /* Using API, send form request to ANY page */
97
+ $form_action = '';
98
+ $email_id = 'nsu_email';
99
+ $name_id = 'nsu_name';
100
+
101
+ } else {
102
+
103
+ /* Using normal form request, set-up using configuration settings */
104
+ $form_action = $opts['mailinglist']['form_action'];
105
+ $email_id = $opts['mailinglist']['email_id'];
106
+
107
+ if ( ! empty( $opts['mailinglist']['name_id'] ) ) {
108
+ $name_id = $opts['mailinglist']['name_id'];
109
+ }
110
+ }
111
+
112
+ /* Set up additional fields */
113
+ if ( isset( $opts['mailinglist']['extra_data'] ) && is_array( $opts['mailinglist']['extra_data'] ) ) {
114
+
115
+ foreach ( $opts['mailinglist']['extra_data'] as $ed ) {
116
+
117
+ if ( $ed['value'] === '%%NAME%%' ) {
118
+ continue;
119
+ }
120
+
121
+ $ed['value'] = str_replace( '%%IP%%', $_SERVER['REMOTE_ADDR'], $ed['value'] );
122
+ $additional_fields .= sprintf( '<input type="hidden" name="%s" value="%s" />', esc_attr( $ed['name'] ), esc_attr( $ed['value'] ) );
123
+ }
124
+ }
125
+
126
+ $email_label = $opts['form']['email_label'];
127
+ $name_label = $opts['form']['name_label'];
128
+
129
+ $email_type = 'email';
130
+ $email_atts = 'placeholder="' . esc_attr( $opts['form']['email_default_value'] ) . '" required';
131
+ $name_atts = 'placeholder="' . esc_attr( $opts['form']['name_default_value'] ) . '" ';
132
+
133
+ if ( $opts['form']['name_required'] ) {
134
+ $name_atts .= 'required ';
135
+ }
136
+
137
+ $submit_button = $opts['form']['submit_button'];
138
+
139
+ $text_after_signup = $opts['form']['text_after_signup'];
140
+ $text_after_signup = ( $opts['form']['wpautop'] == 1 ) ? wpautop( wptexturize( $text_after_signup ) ) : $text_after_signup;
141
+
142
+ // check if form was not submitted or contains error
143
+ if ( ! isset( $_POST['nsu_submit'] ) || count( $errors ) > 0 ) {
144
+
145
+ $output .= '<form class="nsu-form" id="nsu-form-' . esc_attr( $formno ) . '" action="' . esc_attr( $form_action ) . '" method="post">';
146
+
147
+ if ( $opts['mailinglist']['subscribe_with_name'] == 1 ) {
148
+ $output .= '<p><label for="nsu-name-' . esc_attr( $formno ) . '">' . esc_html( $name_label ) . '</label>';
149
+ $output .= '<input class="nsu-field" id="nsu-name-"' . $formno . '" type="text" name="' . esc_attr( $name_id ) . '" ' . $name_atts;
150
+
151
+ $output .= '/>';
152
+
153
+ if ( isset( $errors['name-field'] ) ) {
154
+ $output .= '<span class="nsu-error error notice">' . $errors['name-field'] . '</span>';
155
+ }
156
+ $output .= '</p>';
157
+ }
158
+
159
+ $output .= "<p><label for=\"nsu-email-$formno\">$email_label</label><input class=\"nsu-field\" id=\"nsu-email-$formno\" type=\"$email_type\" name=\"$email_id\" $email_atts ";
160
+ $output .= '/>';
161
+ if ( isset( $errors['email-field'] ) ) {
162
+ $output .= '<span class="nsu-error error notice">' . $errors['email-field'] . '</span>';
163
+ }
164
+ $output .= '</p>';
165
+ $output .= $additional_fields;
166
+ $output .= '<textarea name="nsu_robocop" style="display: none;"></textarea>';
167
+ $output .= sprintf( '<p><input type="submit" id="nsu-submit-%s" class="nsu-submit" name="nsu_submit" value="%s" /></p>', $formno, esc_attr( $submit_button ) );
168
+ $output .= '</form>';
169
+
170
+ } else { // form has been submitted
171
+
172
+ $output .= "<p id=\"nsu-signed-up-$formno\" class=\"nsu-signed-up\">" . ( $text_after_signup ) . '</p>';
173
+
174
+ }
175
+
176
+ $output .= "\n<!-- / Newsletter Sign-Up -->\n";
177
+
178
+ if ( $echo ) {
179
+ echo $output;
180
+ }
181
+
182
+ return $output;
183
+
184
+ }
185
+
186
+ }
trunk/includes/class-nsu-widget.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class NSU_Widget extends WP_Widget {
4
+
5
+ function __construct() {
6
+ $widget_ops = array(
7
+ 'classname' => 'nsu_widget',
8
+ 'description' => __( 'Displays a newsletter sign-up form.', 'newsletter-sign-up' ),
9
+ );
10
+ $control_ops = array(
11
+ 'width' => 400,
12
+ 'height' => 350,
13
+ );
14
+ parent::__construct( 'newslettersignupwidget', 'Newsletter Sign-Up', $widget_ops, $control_ops );
15
+ }
16
+
17
+ function widget( $args, $instance ) {
18
+ /* Provide some defaults */
19
+ $defaults = array(
20
+ 'title' => 'Sign up for our newsletter!',
21
+ 'text_before_form' => '',
22
+ 'text_after_form' => '',
23
+ );
24
+ $instance = array_merge( $defaults, (array) $instance );
25
+
26
+ $title = apply_filters( 'widget_title', $instance['title'] );
27
+
28
+ echo $args['before_widget'];
29
+ echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
30
+
31
+ if ( ! empty( $instance['text_before_form'] ) ) {
32
+ echo '<div class="nsu-text-before-form">';
33
+ echo $instance['filter'] ? wpautop( $instance['text_before_form'] ) : $instance['text_before_form'];
34
+ echo '</div>';
35
+ }
36
+
37
+ NSU::form()->output_form( true );
38
+
39
+ if ( ! empty( $instance['text_after_form'] ) ) {
40
+ echo '<div class="nsu-text-after-form">';
41
+ echo $instance['filter'] ? wpautop( $instance['text_after_form'] ) : $instance['text_after_form'];
42
+ echo '</div>';
43
+ }
44
+
45
+ echo $args['after_widget'];
46
+ }
47
+
48
+ function update( $new_instance, $old_instance ) {
49
+ $instance = $old_instance;
50
+ $instance['title'] = strip_tags( $new_instance['title'] );
51
+
52
+ if ( current_user_can( 'unfiltered_html' ) ) {
53
+ $instance['text_before_form'] = $new_instance['text_before_form'];
54
+ $instance['text_after_form'] = $new_instance['text_after_form'];
55
+ } else {
56
+ $instance['text_before_form'] = stripslashes( wp_filter_post_kses( addslashes( $new_instance['text_before_form'] ) ) );
57
+ $instance['text_after_form'] = stripslashes( wp_filter_post_kses( addslashes( $new_instance['text_after_form'] ) ) );
58
+ }
59
+ $instance['filter'] = isset( $new_instance['filter'] );
60
+
61
+ return $instance;
62
+ }
63
+
64
+ function form( $instance = array() ) {
65
+ $defaults = array(
66
+ 'title' => 'Sign up for our newsletter!',
67
+ 'text_before_form' => '',
68
+ 'text_after_form' => '',
69
+ );
70
+ $instance = array_merge( $defaults, (array) $instance );
71
+ ?>
72
+ <p>
73
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'newsletter-sign-up' ); ?></label>
74
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
75
+ </p>
76
+
77
+ <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', 'newsletter-sign-up' ); ?></label>
78
+ <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 esc_attr( $instance['text_before_form'] ); ?></textarea>
79
+ <br />
80
+ <label for="<?php echo $this->get_field_id( 'text_after_form' ); ?>"><?php _e( 'Text to show after the form', 'newsletter-sign-up' ); ?></label>
81
+ <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 esc_attr( $instance['text_after_form'] ); ?></textarea>
82
+
83
+ <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', 'newsletter-sign-up' ); ?></label></p>
84
+
85
+ <p>
86
+ Configure the sign-up form at the <a href="<?php echo admin_url( 'admin.php?page=newsletter-sign-up-form-settings' ); ?>">Newsletter Sign-Up configuration page</a>.
87
+ </p>
88
+ <?php
89
+ }
90
+
91
+ }
92
+
trunk/includes/class-nsu.php ADDED
@@ -0,0 +1,371 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class NSU {
4
+
5
+ /**
6
+ * @var array
7
+ */
8
+ private $options = array();
9
+
10
+ /**
11
+ * @var NSU|null
12
+ */
13
+ private static $instance = null;
14
+
15
+ /**
16
+ * @var NSU_Checkbox|null
17
+ */
18
+ private static $checkbox = null;
19
+
20
+ /**
21
+ * @var NSU_Form|null
22
+ */
23
+ private static $form = null;
24
+
25
+ public function __construct() {
26
+ self::$instance = $this;
27
+
28
+ self::checkbox();
29
+ self::form();
30
+
31
+ // widget hooks
32
+ add_action( 'widgets_init', array( $this, 'register_widget' ) );
33
+
34
+ // check if this is an AJAX request
35
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
36
+
37
+ if ( is_admin() ) {
38
+
39
+ // backend only
40
+ require_once NSU_PLUGIN_DIR . '/includes/class-nsu-admin.php';
41
+ new NSU_Admin();
42
+
43
+ } else {
44
+
45
+ // frontend only
46
+ require_once NSU_PLUGIN_DIR . '/includes/functions.php';
47
+
48
+ add_action( 'wp_enqueue_scripts', array( $this, 'load_stylesheets' ) );
49
+ add_action( 'login_enqueue_scripts', array( $this, 'load_stylesheets' ) );
50
+
51
+ }
52
+ }
53
+ }
54
+
55
+ public static function checkbox() {
56
+ if ( ! self::$checkbox ) {
57
+ require_once NSU_PLUGIN_DIR . '/includes/class-nsu-checkbox.php';
58
+ self::$checkbox = new NSU_Checkbox;
59
+ }
60
+
61
+ return self::$checkbox;
62
+ }
63
+
64
+ public static function form() {
65
+ if ( ! self::$form ) {
66
+ require_once NSU_PLUGIN_DIR . '/includes/class-nsu-form.php';
67
+ self::$form = new NSU_Form;
68
+ }
69
+
70
+ return self::$form;
71
+ }
72
+
73
+
74
+ /**
75
+ * Initalize options
76
+ *
77
+ * @return array $options
78
+ */
79
+ public function get_options() {
80
+ if ( ! empty( $this->options ) ) {
81
+ return $this->options;
82
+ }
83
+
84
+ $defaults = array(
85
+ 'form' => array(
86
+ 'load_form_css' => 0,
87
+ 'submit_button' => 'Sign up',
88
+ 'name_label' => 'Name',
89
+ 'email_label' => 'Email',
90
+ 'email_default_value' => 'Your email address',
91
+ 'name_required' => 0,
92
+ 'name_default_value' => 'Your name',
93
+ 'wpautop' => 0,
94
+ 'text_after_signup' => 'Thanks for signing up to our newsletter. Please check your inbox to confirm your email address.',
95
+ 'redirect_to' => '',
96
+ 'text_empty_name' => 'Please fill in the name field.',
97
+ 'text_empty_email' => 'Please fill in the email field.',
98
+ 'text_invalid_email' => 'Please enter a valid email address.',
99
+ ),
100
+ 'mailinglist' => array(
101
+ 'provider' => '',
102
+ 'use_api' => 0,
103
+ 'subscribe_with_name' => 0,
104
+ 'email_id' => '',
105
+ 'name_id' => '',
106
+ 'form_action' => '',
107
+ ),
108
+ 'checkbox' => array(
109
+ 'text' => 'Sign me up for the newsletter',
110
+ 'redirect_to' => '',
111
+ 'precheck' => 0,
112
+ 'cookie_hide' => 0,
113
+ 'css_reset' => 0,
114
+ 'add_to_registration_form' => 0,
115
+ 'add_to_comment_form' => 1,
116
+ 'add_to_buddypress_form' => 0,
117
+ 'add_to_multisite_form' => 0,
118
+ 'add_to_bbpress_forms' => 0,
119
+ ),
120
+ );
121
+
122
+ foreach ( $defaults as $key => $value ) {
123
+ $option = get_option( 'nsu_' . $key, array() );
124
+ if ( $option === array() ) {
125
+ add_option( 'nsu_' . $key, $value );
126
+ }
127
+
128
+ $this->options[ $key ] = array_merge( $value, (array) $option );
129
+ }
130
+
131
+ return $this->options;
132
+ }
133
+
134
+ /**
135
+ * Registers the Newsletter Sign-Up Widget
136
+ */
137
+ public function register_widget() {
138
+ require_once NSU_PLUGIN_DIR . '/includes/class-nsu-widget.php';
139
+ register_widget( 'NSU_Widget' );
140
+ }
141
+
142
+ /**
143
+ * Factory method for NewsletterSignUp class. Only instantiate once.
144
+ *
145
+ * @return NSU Instance of Newsletter Sign-Up class
146
+ */
147
+ public static function instance() {
148
+ if ( null === self::$instance ) {
149
+ self::$instance = new NSU();
150
+ }
151
+
152
+ return self::$instance;
153
+ }
154
+
155
+ public function load_stylesheets() {
156
+ $opts = $this->get_options();
157
+
158
+ $stylesheets = array();
159
+ if ( (int) $opts['checkbox']['css_reset'] === 1 ) {
160
+ $stylesheets['checkbox'] = 1;
161
+ }
162
+
163
+ if ( (int) $opts['form']['load_form_css'] === 1 ) {
164
+ $stylesheets['form'] = 1;
165
+ }
166
+
167
+ if ( ! empty( $stylesheets ) ) {
168
+ $stylesheet_url = add_query_arg( $stylesheets, plugins_url( '/assets/css/css.php', dirname( __FILE__ ) ) );
169
+ wp_enqueue_style( 'newsletter-sign-up', $stylesheet_url );
170
+ }
171
+
172
+ }
173
+
174
+ /**
175
+ * Send the post data to the newsletter service, mimic form request
176
+ * @param string $email
177
+ * @param string $name
178
+ * @param string $type
179
+ * @return void
180
+ */
181
+ function send_post_data( $email, $name = '', $type = 'checkbox' ) {
182
+ $opts = $this->options['mailinglist'];
183
+
184
+ // when not using api and no form action has been given, abandon.
185
+ if ( empty( $opts['use_api'] ) && empty( $opts['form_action'] ) ) {
186
+ return;
187
+ }
188
+
189
+ /* Are we using API? */
190
+ if ( $opts['use_api'] == 1 ) {
191
+
192
+ switch ( $opts['provider'] ) {
193
+
194
+ /* Send data using the YMLP API */
195
+ case 'ymlp':
196
+ $data = array(
197
+ 'key' => $opts['ymlp_api_key'],
198
+ 'username' => $opts['ymlp_username'],
199
+ 'Email' => $email,
200
+ 'GroupId' => $opts['ymlp_groupid'],
201
+ 'output' => 'JSON',
202
+ );
203
+
204
+ $data = array_merge( $data, $this->add_additional_data( array( 'api' => 'ymlp' ) ) );
205
+ $data = http_build_query( $data );
206
+ $url = 'https://www.ymlp.com/api/Contacts.Add?' . $data;
207
+
208
+ $result = wp_remote_post( $url );
209
+
210
+ break;
211
+
212
+ /* Send data using the Mailchimp API */
213
+ case 'mailchimp':
214
+ $request = array(
215
+ 'apikey' => $opts['mc_api_key'],
216
+ 'id' => $opts['mc_list_id'],
217
+ 'email_address' => $email,
218
+ 'double_optin' => ( isset( $opts['mc_no_double_optin'] ) && $opts['mc_no_double_optin'] == 1 ) ? false : true,
219
+ 'merge_vars' => array(
220
+ 'OPTIN_TIME' => gmdate( 'Y-M-D H:i:s' ),
221
+ ),
222
+ );
223
+
224
+ if ( isset( $opts['mc_use_groupings'] ) && $opts['mc_use_groupings'] == 1 && ! empty( $opts['mc_groupings_name'] ) ) {
225
+ $request['merge_vars']['GROUPINGS'] = array(
226
+ array(
227
+ 'name' => $opts['mc_groupings_name'],
228
+ 'groups' => $opts['mc_groupings_groups'],
229
+ ),
230
+ );
231
+ }
232
+
233
+ /* Subscribe with name? If so, add name to merge_vars array */
234
+ if ( isset( $opts['subscribe_with_name'] ) && $opts['subscribe_with_name'] == 1 ) {
235
+ // Try to provide values for First and Lastname fields
236
+ // These can be overridden, of just ignored by mailchimp.
237
+ $strpos = strpos( $name, ' ' );
238
+
239
+ $request['merge_vars']['FNAME'] = $name;
240
+
241
+ if ( $strpos ) {
242
+ $request['merge_vars']['FNAME'] = substr( $name, 0, $strpos );
243
+ $request['merge_vars']['LNAME'] = substr( $name, $strpos );
244
+ } else {
245
+ $request['merge_vars']['FNAME'] = $name;
246
+ }
247
+
248
+ $request['merge_vars'][ $opts['name_id'] ] = $name;
249
+ }
250
+
251
+ // Add any set additional data to merge_vars array
252
+ $request['merge_vars'] = array_merge(
253
+ $request['merge_vars'],
254
+ $this->add_additional_data(
255
+ array(
256
+ 'email' => $email,
257
+ 'name' => $name,
258
+ )
259
+ )
260
+ );
261
+
262
+ wp_remote_post(
263
+ 'https://' . substr( $opts['mc_api_key'], -3 ) . '.api.mailchimp.com/1.3/?output=php&method=listSubscribe',
264
+ array( 'body' => json_encode( $request ) )
265
+ );
266
+
267
+ break;
268
+
269
+ }
270
+ } else {
271
+ /* We are not using API, mimic a normal form request */
272
+
273
+ $post_data = array(
274
+ $opts['email_id'] => $email,
275
+ );
276
+
277
+ // Subscribe with name? Add to $post_data array.
278
+ if ( $opts['subscribe_with_name'] == 1 ) {
279
+ $post_data[ $opts['name_id'] ] = $name;
280
+ }
281
+
282
+ // Add list specific data
283
+ switch ( $opts['provider'] ) {
284
+
285
+ case 'aweber':
286
+ $post_data['listname'] = $opts['aweber_list_name'];
287
+ $post_data['redirect'] = get_bloginfo( 'wpurl' );
288
+ $post_data['meta_message'] = '1';
289
+ $post_data['meta_required'] = 'email';
290
+ break;
291
+
292
+ case 'phplist':
293
+ $post_data[ 'list[' . $opts['phplist_list_id'] . ']' ] = 'signup';
294
+ $post_data['subscribe'] = 'Subscribe';
295
+ $post_data['htmlemail'] = '1';
296
+ $post_data['emailconfirm'] = $email;
297
+ $post_data['makeconfirmed'] = '0';
298
+ break;
299
+
300
+ }
301
+
302
+ $post_data = array_merge(
303
+ $post_data,
304
+ $this->add_additional_data(
305
+ array_merge(
306
+ array(
307
+ 'email' => $email,
308
+ 'name' => $name,
309
+ ),
310
+ $post_data
311
+ )
312
+ )
313
+ );
314
+
315
+ wp_remote_post(
316
+ $opts['form_action'],
317
+ array( 'body' => $post_data )
318
+ );
319
+
320
+ }
321
+
322
+ // store a cookie, if preferred by site owner
323
+ if ( $type === 'checkbox' && $this->options['checkbox']['cookie_hide'] == 1 ) {
324
+ setcookie( 'ns_subscriber', true, time() + ( HOUR_IN_SECONDS * 24 * 90 ) );
325
+ }
326
+
327
+ // Check if we should redirect to a given page
328
+ if ( $type === 'form' && strlen( $this->options['form']['redirect_to'] ) > 6 ) {
329
+ wp_redirect( $this->options['form']['redirect_to'] );
330
+ exit;
331
+ } elseif ( $type === 'checkbox' && strlen( $this->options['checkbox']['redirect_to'] ) > 6 ) {
332
+ wp_redirect( $this->options['checkbox']['redirect_to'] );
333
+ exit;
334
+ }
335
+
336
+ return true;
337
+ }
338
+
339
+
340
+ /**
341
+ * Returns array with additional data names as key, values as value.
342
+ *
343
+ * @param array $args, the normal form data (name, email, list variables)
344
+ * @return array
345
+ */
346
+ function add_additional_data( $args = array() ) {
347
+ $opts = $this->options['mailinglist'];
348
+ $defaults = array(
349
+ 'format' => 'array',
350
+ 'api' => null,
351
+ );
352
+
353
+ $args = wp_parse_args( $args, $defaults );
354
+
355
+ $add_data = array();
356
+ if ( isset( $opts['extra_data'] ) && is_array( $opts['extra_data'] ) ) {
357
+ foreach ( $opts['extra_data'] as $key => $value ) {
358
+ if ( $args['api'] == 'ymlp' ) {
359
+ $value['name'] = str_replace( 'YMP', 'Field', $value['name'] );
360
+ }
361
+
362
+ $value['value'] = str_replace( '%%NAME%%', $args['name'], $value['value'] );
363
+ $value['value'] = str_replace( '%%IP%%', $_SERVER['REMOTE_ADDR'], $value['value'] );
364
+ $add_data[ $value['name'] ] = $value['value'];
365
+ }
366
+ }
367
+
368
+ return $add_data;
369
+ }
370
+
371
+ }
trunk/includes/functions.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Displays the comment checkbox, call this function if your theme does not use the 'comment_form' action in the comments.php template.
5
+ */
6
+ function nsu_checkbox() {
7
+ NSU::checkbox()->output_checkbox();
8
+ }
9
+
10
+
11
+ /**
12
+ * Outputs a sign-up form, for usage in your theme files.
13
+ */
14
+ function nsu_form() {
15
+ NSU::form()->output_form( true );
16
+ }
17
+
18
+
19
+ /* Backwards Compatibility */
20
+ function nsu_signup_form() {
21
+ _deprecated_function( __FUNCTION__, '2.0', 'nsu_form' );
22
+ nsu_form();
23
+ }
trunk/includes/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header( 'Status: 403 Forbidden' );
5
+ header( 'HTTP/1.1 403 Forbidden' );
6
+ exit;
trunk/includes/views/checkbox-settings.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <div class="wrap" id="nsu-admin">
3
+
4
+ <?php include dirname( __FILE__ ) . '/parts/navigation.php'; ?>
5
+
6
+ <h2>Newsletter Sign-Up :: Checkbox Settings</h2>
7
+
8
+ <?php settings_errors(); ?>
9
+
10
+ <div id="nsu-main">
11
+
12
+ <form method="post" action="options.php" id="ns_settings_page">
13
+ <?php settings_fields( 'nsu_checkbox_group' ); ?>
14
+ <table class="form-table">
15
+ <tr valign="top">
16
+ <th scope="row">Text to show after the checkbox</th>
17
+ <td><input class="widefat" type="text" name="nsu_checkbox[text]" value="<?php echo esc_attr( $opts['text'] ); ?>" /></td>
18
+ </tr>
19
+ <tr valign="top">
20
+ <th scope="row">Redirect to this url after signing up <small>(leave empty or enter 0 (zero) for no redirect)</small></th>
21
+ <td>
22
+ <input class="widefat" type="text" name="nsu_checkbox[redirect_to]" value="<?php echo esc_attr( $opts['redirect_to'] ); ?>" />
23
+ <small>In general, I don't recommend setting a redirect url for the sign-up checkbox. This will cause some serious confusion, since
24
+ users expect to be redirected to the post they commented on.</small>
25
+ </td>
26
+ </tr>
27
+ <tr valign="top">
28
+ <th scope="row">
29
+ <label for="ns_precheck_checkbox">Pre-check the checkbox?</label></th>
30
+ <td><input type="checkbox" id="ns_precheck_checkbox" name="nsu_checkbox[precheck]" value="1" <?php checked( $opts['precheck'], 1 ); ?> /></td>
31
+ </tr>
32
+ <tr valign="top">
33
+ <th scope="row"><label for="do_css_reset">Do a CSS 'reset' on the checkbox.</label> </th>
34
+ <td>
35
+ <label>
36
+ <input type="checkbox" id="do_css_reset" name="nsu_checkbox[css_reset]" value="1" <?php checked( $opts['css_reset'], 1 ); ?> />
37
+ <small>(check this if checkbox appears in a weird place)</small>
38
+ </label>
39
+ </td>
40
+ </tr>
41
+ <tr valign="top"><th scope="row">Where to show the sign-up checkbox?</th>
42
+ <td>
43
+ <?php foreach ( $this->get_checkbox_compatible_plugins() as $code => $name ) { ?>
44
+ <input type="checkbox" id="add_to_<?php echo $code; ?>" name="nsu_checkbox[add_to_<?php echo esc_attr( $code ); ?>]" value="1" <?php checked( $opts[ 'add_to_' . $code ], '1' ); ?> /> <label for="add_to_<?php echo $code; ?>"><?php echo $name; ?></label> &nbsp;
45
+ <?php } ?>
46
+ </td>
47
+ </tr>
48
+ <tr valign="top">
49
+ <th scope="row"><label for="ns_cookie_hide">Hide the checkbox for users who used it to subscribe before?</label><small>(uses a cookie)</small></th>
50
+ <td><input type="checkbox" id="ns_cookie_hide" name="nsu_checkbox[cookie_hide]" value="1" <?php checked( $opts['cookie_hide'], 1 ); ?> /></td>
51
+ </tr>
52
+
53
+ </table>
54
+
55
+ <?php submit_button(); ?>
56
+
57
+ </form>
58
+ </div>
59
+
60
+ <?php include dirname( __FILE__ ) . '/parts/sidebar.php'; ?>
61
+
62
+ </div>
trunk/includes/views/config-helper.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <div class="wrap" id="nsu-admin">
3
+
4
+
5
+ <?php include dirname( __FILE__ ) . '/parts/navigation.php'; ?>
6
+
7
+ <h2>Newsletter Sign-Up :: Config Extractor</h2>
8
+
9
+
10
+ <div id="nsu-main">
11
+
12
+ <?php if ( isset( $result ) && ! is_array( $result ) ) { ?>
13
+ <div id="message" class="notice updated"><p>Oops, I couldn't make any sense of that. Are you sure you submitted a form snippet?</p></div>
14
+ <?php } ?>
15
+
16
+
17
+
18
+
19
+
20
+ <?php if ( isset( $result ) && is_array( $result ) ) { ?>
21
+ <table class="form-table">
22
+ <tr valign="top">
23
+ <th scope="row" style="font-weight:bold;">Form action:</th>
24
+ <td><?php echo $result['form_action']; ?></td>
25
+ </tr>
26
+ <tr valign="top">
27
+ <th scope="row" style="font-weight:bold;">Email identifier:</th>
28
+ <td><?php echo $result['email_name']; ?></td>
29
+ </tr>
30
+ <tr valign="top">
31
+ <th scope="row" style="font-weight:bold;">Name identifier:</th>
32
+ <td><?php echo $result['name_name']; ?></td>
33
+ </tr>
34
+ <?php if ( count( $result['additional_data'] ) > 0 ) { ?>
35
+ <tr valign="top">
36
+ <th scope="row" colspan="2" style="font-weight:bold;">Additional data ( name / value):</th>
37
+ </tr>
38
+ <?php foreach ( $result['additional_data'] as $data ) { ?>
39
+ <tr valign="top">
40
+ <td><?php echo esc_html( $data[0] ); ?></td>
41
+ <td><?php echo esc_html( $data[1] ); ?></td>
42
+ </tr>
43
+ <?php } ?>
44
+ <?php } ?>
45
+
46
+ </table>
47
+
48
+ <p>The above settings are there to help you, though they may not be right. Check out <a href="https://dannyvankooten.com/571/configuring-newsletter-sign-up-the-definitive-guide/">this post on my blog</a> for more information on how to manually
49
+ configure Newsletter Sign-up.</p>
50
+
51
+ <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>
52
+ <textarea class="widefat" rows="10"><?php echo esc_textarea( $result['simpler_form'] ); ?></textarea>
53
+
54
+ <?php } else { ?>
55
+
56
+ <p>This tool was designed to help you extract the right configuration settings to make Newsletter Sign-Up work properly.</p>
57
+ <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>
58
+ <form method="post" action="" id="ns_settings_page">
59
+ <textarea name="form" class="widefat" rows="10" placeholder="Copy paste your form code here." required></textarea>
60
+
61
+ <p class="submit">
62
+ <input type="submit" class="button-primary" style="margin:5px;" value="<?php _e( 'Extract', 'newsletter-sign-up' ); ?>" />
63
+ </p>
64
+
65
+
66
+ </form>
67
+ <?Php } ?>
68
+
69
+ </div>
70
+
71
+ <?php include dirname( __FILE__ ) . '/parts/sidebar.php'; ?>
72
+
73
+ </div>
trunk/includes/views/dashboard.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <div class="wrap" id="nsu-admin">
3
+
4
+ <?php include dirname( __FILE__ ) . '/parts/navigation.php'; ?>
5
+
6
+ <h2>Newsletter Sign-Up :: Mailinglist Settings</h2>
7
+ <?php settings_errors(); ?>
8
+
9
+ <div id="nsu-main">
10
+
11
+ <form method="post" action="options.php">
12
+ <?php settings_fields( 'nsu_mailinglist_group' ); ?>
13
+
14
+ <p>These settings are the most important, without them Newsletter Sign-Up can't do its job. Having trouble finding the right configuration settings? Have a look at <a href="https://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>
15
+
16
+ <table class="form-table">
17
+ <tr valign="top">
18
+ <th scope="row">Select your mailinglist provider: </th>
19
+ <td>
20
+ <select class="widefat" name="nsu_mailinglist[provider]" id="ns_mp_provider" onchange="document.location.href = 'admin.php?page=<?php echo $this->hook; ?>&mp=' + this.value">
21
+ <option value="other"
22
+ <?php
23
+ if ( $viewed_mp == null || $viewed_mp == 'other' ) {
24
+ echo ' SELECTED';}
25
+ ?>
26
+ >-- other / advanced</option>
27
+ <option value="mailchimp"
28
+ <?php
29
+ if ( $viewed_mp == 'mailchimp' ) {
30
+ echo ' SELECTED';}
31
+ ?>
32
+ >Mailchimp</option>
33
+ <option value="ymlp"
34
+ <?php
35
+ if ( $viewed_mp == 'ymlp' ) {
36
+ echo ' SELECTED';}
37
+ ?>
38
+ >YMLP</option>
39
+ <option value="icontact"
40
+ <?php
41
+ if ( $viewed_mp == 'icontact' ) {
42
+ echo ' SELECTED';}
43
+ ?>
44
+ >iContact</option>
45
+ <option value="aweber"
46
+ <?php
47
+ if ( $viewed_mp == 'aweber' ) {
48
+ echo ' SELECTED';}
49
+ ?>
50
+ >Aweber</option>
51
+ <option value="phplist"
52
+ <?php
53
+ if ( $viewed_mp == 'phplist' ) {
54
+ echo ' SELECTED';}
55
+ ?>
56
+ >PHPList</option>
57
+ </select>
58
+ </td>
59
+ </tr>
60
+
61
+ <?php
62
+ if ( isset( $viewed_mp ) && file_exists( dirname( __FILE__ ) . '/parts/rows-' . $viewed_mp . '.php' ) ) {
63
+ require 'parts/rows-' . $viewed_mp . '.php';}
64
+ ?>
65
+
66
+ <tbody class="form_rows"
67
+ <?php
68
+ if ( isset( $viewed_mp ) && in_array( $viewed_mp, array( 'mailchimp', 'ymlp' ) ) && isset( $opts['use_api'] ) && $opts['use_api'] == 1 ) {
69
+ echo ' style="display:none" ';}
70
+ ?>
71
+ >
72
+ <tr valign="top">
73
+ <th scope="row">Newsletter form action</th>
74
+ <td><input class="widefat" type="text" id="ns_form_action" name="nsu_mailinglist[form_action]" placeholder="Example: http://newsletter-service.com?action=subscribe&id=123" value="<?php echo esc_attr( $opts['form_action'] ); ?>" /></td>
75
+ </tr>
76
+ <tr valign="top">
77
+ <th scope="row">
78
+ E-mail identifier
79
+ <small class="help">name attribute of input field for the emailadress</small>
80
+ </th>
81
+ <td><input class="widefat" type="text" name="nsu_mailinglist[email_id]" placeholder="Example: EMAIL" value="<?php echo esc_attr( $opts['email_id'] ); ?>"/></td>
82
+ </tr>
83
+ </tbody>
84
+ <tbody>
85
+ <tr valign="top">
86
+ <th scope="row"><label for="subscribe_with_name">Subscribe with name?</label></th>
87
+ <td><input type="checkbox" id="subscribe_with_name" name="nsu_mailinglist[subscribe_with_name]" value="1" <?php checked( $opts['subscribe_with_name'], 1 ); ?> /></td>
88
+ </tr>
89
+ <tr class="name_dependent" valign="top"
90
+ <?php
91
+ if ( $opts['subscribe_with_name'] != 1 ) {
92
+ echo 'style="display:none;"';}
93
+ ?>
94
+ >
95
+ <th scope="row">
96
+ Name identifier
97
+ <small class="help">name attribute of input field that holds the name</small>
98
+ </th>
99
+ <td><input class="widefat" id="ns_name_id" type="text" name="nsu_mailinglist[name_id]" placeholder="Example: NAME" value="<?php echo esc_attr( $opts['name_id'] ); ?>" /></td>
100
+ </tr>
101
+ </tbody>
102
+ </table>
103
+ <p>
104
+ For some newsletter services you need to specify some additional fields, like a list ID or your account name. These fields are usually found as hidden fields in the HTML code of your sign-up forms.
105
+ You can specify these additional fields here using name / value pairs, they will be included in all sign-up requests made by the plugin.
106
+ </p>
107
+ <table class="form-table">
108
+ <tr valign="top" style="font-weight:bold;">
109
+ <th scope="column">Name</th>
110
+ <th scope="column">Value</th>
111
+ </tr>
112
+ <?php
113
+ $last_key = 0;
114
+
115
+ if ( isset( $opts['extra_data'] ) && is_array( $opts['extra_data'] ) ) :
116
+ foreach ( $opts['extra_data'] as $key => $value ) :
117
+ ?>
118
+ <tr valign="top">
119
+ <td><input class="widefat" type="text" name="nsu_mailinglist[extra_data][<?php echo esc_attr( $key ); ?>][name]" value="<?php echo esc_attr( $value['name'] ); ?>" /></td>
120
+ <td><input class="widefat" type="text" name="nsu_mailinglist[extra_data][<?php echo esc_attr( $key ); ?>][value]" value="<?php echo esc_attr( $value['value'] ); ?>" /></td>
121
+ </tr>
122
+ <?php
123
+ $last_key = $key + 1;
124
+ endforeach;
125
+ endif;
126
+ ?>
127
+ <tr valign="top">
128
+ <td><input class="widefat" type="text" name="nsu_mailinglist[extra_data][<?php echo esc_attr( $last_key ); ?>][name]" placeholder="Hidden field name" value="" /></td>
129
+ <td><input class="widefat" type="text" name="nsu_mailinglist[extra_data][<?php echo esc_attr( $last_key ); ?>][value]" placeholder="Hidden field value" value="" /></td>
130
+ </tr>
131
+ </table>
132
+
133
+ <p class="help"><strong>Dynamic values:</strong> <code>{name}</code> and <code>{ip}</code> will be replaced by the name or IP address of the subscriber.</p>
134
+
135
+
136
+ <?php submit_button(); ?>
137
+
138
+ </form>
139
+ <p>
140
+ <em>Having trouble finding the right configuration settings? Try the <a href="<?php echo admin_url( 'admin.php?page=newsletter-sign-up-config-helper' ); ?>">configuration extractor</a>.</em>
141
+ </p>
142
+
143
+ </div>
144
+
145
+
146
+ <?php include dirname( __FILE__ ) . '/parts/sidebar.php'; ?>
147
+
148
+ </div>
149
+ <br style="clear:both;" />
trunk/includes/views/form-settings.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <div class="wrap" id="nsu-admin">
3
+
4
+ <?php include dirname( __FILE__ ) . '/parts/navigation.php'; ?>
5
+
6
+ <div id="nsu-main">
7
+
8
+ <h2>Newsletter Sign-Up :: Form Settings</h2>
9
+ <?php settings_errors(); ?>
10
+
11
+ <p>Customize your newsletter sign-up form by customizing the labels, input fields, buttons and validation texts using the settings below. Use <code>[nsu_form]</code> to render a sign-up form in your posts or pages or use the <em>Newsletter Sign-Up</em> widget to display a sign-up form in your widget areas.</p>
12
+
13
+ <form method="post" action="options.php">
14
+ <?php settings_fields( 'nsu_form_group' ); ?>
15
+ <table class="form-table">
16
+ <tr valign="top">
17
+ <th scope="row">E-mail label</th>
18
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[email_label]" value="<?php echo esc_attr( $opts['email_label'] ); ?>" placeholder="Eg: Your email:" required /></td>
19
+ </tr>
20
+ <tr valign="top">
21
+ <th scope="row">E-mail default value</th>
22
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[email_default_value]" value="<?php echo esc_attr( $opts['email_default_value'] ); ?>" /></td>
23
+ </tr>
24
+ <tr valign="top" class="name_dependent"
25
+ <?php
26
+ if ( $opts['mailinglist']['subscribe_with_name'] != 1 ) {
27
+ echo 'style="display:none;"';}
28
+ ?>
29
+ >
30
+ <th scope="row">Name label</th>
31
+ <td colspan="2">
32
+ <input class="widefat" type="text" name="nsu_form[name_label]" value="<?php echo esc_attr( $opts['name_label'] ); ?>" /><br />
33
+ <p><input type="checkbox" id="name_required" name="nsu_form[name_required]" value="1" <?php checked( $opts['name_required'], 1 ); ?> />
34
+ <label for="name_required">Name is a required field?</label></p>
35
+ </td>
36
+ </tr>
37
+ <tr valign="top" class="name_dependent"
38
+ <?php
39
+ if ( $opts['mailinglist']['subscribe_with_name'] != 1 ) {
40
+ echo 'style="display:none;"';}
41
+ ?>
42
+ >
43
+ <th scope="row">Name default value</th>
44
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[name_default_value]" value="<?php echo esc_attr( $opts['name_default_value'] ); ?>" /></td>
45
+
46
+ </tr>
47
+ <tr valign="top">
48
+ <th scope="row">Submit button text</th>
49
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[submit_button]" value="<?php echo esc_attr( $opts['submit_button'] ); ?>" placeholder="Eg: Subscribe" required /></td>
50
+ </tr>
51
+ <tr valign="top">
52
+ <th scope="row">Text to replace the form with after a successful sign-up</th>
53
+ <td colspan="2">
54
+ <textarea class="widefat" rows="5" cols="50" name="nsu_form[text_after_signup]"><?php echo esc_textarea( $opts['text_after_signup'] ); ?></textarea>
55
+ <p><label><input id="nsu_form_wpautop" name="nsu_form[wpautop]" type="checkbox" value="1" <?php checked( $opts['wpautop'], 1 ); ?> /> <?php _e( 'Automatically add paragraphs', 'newsletter-sign-up' ); ?></label></p>
56
+ </td>
57
+ </tr>
58
+
59
+ <?php if ( $opts['mailinglist']['use_api'] == 1 ) { ?>
60
+ <tr valign="top">
61
+ <th scope="row">Redirect to this url after signing up <small>(leave empty for no redirect)</small></th>
62
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[redirect_to]" value="<?php echo $opts['redirect_to']; ?>" /></td>
63
+ </tr>
64
+ <?php } ?>
65
+
66
+ <tr valign="top">
67
+ <th scope="row"><label for="ns_load_form_styles">Load CSS</label></th>
68
+ <td>
69
+ <label><input type="checkbox" id="ns_load_form_styles" name="nsu_form[load_form_css]" value="1"
70
+ <?php
71
+ if ( $opts['load_form_css'] == 1 ) {
72
+ echo 'checked';}
73
+ ?>
74
+ />
75
+ Check this to load some default form styles.</label></td>
76
+ </tr>
77
+ </table>
78
+
79
+ <?php submit_button(); ?>
80
+
81
+ <?php if ( $this->options['mailinglist']['use_api'] == 1 ) { ?>
82
+ <h3>Form text messages</h3>
83
+ <table class="form-table">
84
+ <?php if ( $opts['mailinglist']['subscribe_with_name'] ) { ?>
85
+ <tr valign="top">
86
+ <th scope="row">Empty name field message</th>
87
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[text_empty_name]" value="<?php echo esc_attr( $opts['text_empty_name'] ); ?>" /></td>
88
+ </tr>
89
+ <?php } ?>
90
+ <tr valign="top">
91
+ <th scope="row">Empty email address field message</th>
92
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[text_empty_email]" value="<?php echo esc_attr( $opts['text_empty_email'] ); ?>" /></td>
93
+ </tr>
94
+ <tr valign="top">
95
+ <th scope="row">Invalid email address message</th>
96
+ <td colspan="2"><input class="widefat" type="text" name="nsu_form[text_invalid_email]" value="<?php echo esc_attr( $opts['text_invalid_email'] ); ?>" /></td>
97
+ </tr>
98
+ </table>
99
+ <?php } ?>
100
+ </form>
101
+ </div>
102
+
103
+ <?php include dirname( __FILE__ ) . '/parts/sidebar.php'; ?>
104
+
105
+ </div>
trunk/includes/views/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header( 'Status: 403 Forbidden' );
5
+ header( 'HTTP/1.1 403 Forbidden' );
6
+ exit;
trunk/includes/views/parts/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header( 'Status: 403 Forbidden' );
5
+ header( 'HTTP/1.1 403 Forbidden' );
6
+ exit;
trunk/includes/views/parts/navigation.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <h2 class="nav-tab-wrapper">
3
+ <a href="?page=newsletter-sign-up" class="nav-tab <?php echo ( $tab == 'mailinglist-settings' ) ? 'nav-tab-active' : ''; ?>">Mailinglist Settings</a>
4
+ <a href="?page=newsletter-sign-up-checkbox-settings" class="nav-tab <?php echo ( $tab === 'checkbox-settings' ) ? 'nav-tab-active' : ''; ?>">Checkbox Settings</a>
5
+ <a href="?page=newsletter-sign-up-form-settings" class="nav-tab <?php echo ( $tab === 'form-settings' ) ? 'nav-tab-active' : ''; ?>">Form Settings</a>
6
+ <a href="?page=newsletter-sign-up-config-helper" class="nav-tab <?php echo ( $tab === 'config-helper' ) ? 'nav-tab-active' : ''; ?>">Config Helper</a>
7
+ </h2>
trunk/includes/views/parts/rows-aweber.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <tr valign="top">
3
+ <th scope="row"><label for="aweber_list_name" Aweber list name</th>
4
+ <td>
5
+ <input id="aweber_list_name" class="widefat" type="text" name="nsu_mailinglist[aweber_list_name]" value="
6
+ <?php
7
+ if ( isset( $opts['aweber_list_name'] ) ) {
8
+ echo esc_attr( $opts['aweber_list_name'] );
9
+ }
10
+ ?>
11
+ " /></td>
12
+ </tr>
trunk/includes/views/parts/rows-mailchimp.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <tr valign="top">
3
+ <th colspan="2" style="background: white; border-left: 10px solid lightskyblue; padding: 20px;">
4
+ As you're using Mailchimp, I highly recommend switching to our improved <a href="https://wordpress.org/plugins/mailchimp-for-wp/">Mailchimp for WordPress</a> plugin.
5
+ You'll be up and running (again) in just a few minutes.
6
+ </th>
7
+ </tr>
8
+
9
+ <tr valign="top">
10
+ <th scope="row">
11
+ <label for="use_api">Use Mailchimp API?</label>
12
+ <small class="help">(recommended)</small>
13
+ </th>
14
+ <td>
15
+ <input type="checkbox" id="use_api" name="nsu_mailinglist[use_api]" value="1"
16
+ <?php
17
+ if ( isset( $opts['use_api'] ) && $opts['use_api'] == '1' ) {
18
+ echo ' checked="checked"';
19
+ }
20
+ ?>
21
+ /></td>
22
+ </tr>
23
+
24
+ <tbody class="api_rows"
25
+ <?php
26
+ if ( ! isset( $opts['use_api'] ) || $opts['use_api'] != 1 ) {
27
+ echo ' style="display:none" ';
28
+ }
29
+ ?>
30
+ >
31
+ <tr valign="top">
32
+ <th scope="row">Mailchimp API Key <a target="_blank" href="https://admin.mailchimp.com/account/api">(?)</a></th>
33
+ <td>
34
+ <input class="widefat" type="text" id="mc_api_key" name="nsu_mailinglist[mc_api_key]" value="
35
+ <?php
36
+ if ( isset( $opts['mc_api_key'] ) ) {
37
+ echo esc_attr( $opts['mc_api_key'] );
38
+ }
39
+ ?>
40
+ " /></td>
41
+ </tr>
42
+ <tr valign="top">
43
+ <th scope="row">Mailchimp List ID
44
+ <a href="http://www.mailchimp.com/kb/article/how-can-i-find-my-list-id" target="_blank">(?)</a></th>
45
+ <td>
46
+ <input class="widefat" type="text" name="nsu_mailinglist[mc_list_id]" value="
47
+ <?php
48
+ if ( isset( $opts['mc_list_id'] ) ) {
49
+ echo esc_attr( $opts['mc_list_id'] );
50
+ }
51
+ ?>
52
+ "; />
53
+ </td>
54
+ </tr>
55
+ <tr valign="top">
56
+ <th scope="row">
57
+ <label title="Prevents your users from having to confirm their emailaddress. Make sure you comply with the CAN SPAM act." for="mc_prevent_double_optin">Prevent double opt-in?</label>
58
+ </th>
59
+ <td>
60
+ <input type="checkbox" id="mc_prevent_double_optin" name="nsu_mailinglist[mc_no_double_optin]" value="1"
61
+ <?php
62
+ if ( isset( $opts['mc_no_double_optin'] ) ) {
63
+ checked( $opts['mc_no_double_optin'], 1 );
64
+ }
65
+ ?>
66
+ /></td>
67
+ </tr>
68
+ <tr valign="top">
69
+ <th scope="row"><label for="mc_use_groupings">Add to group(s)? </label></th>
70
+ <td>
71
+ <input type="checkbox" id="mc_use_groupings" name="nsu_mailinglist[mc_use_groupings]" value="1"
72
+ <?php
73
+ if ( isset( $opts['mc_use_groupings'] ) ) {
74
+ checked( $opts['mc_use_groupings'], 1 );
75
+ }
76
+ ?>
77
+ /></td>
78
+ </tr>
79
+ <tbody class="mc_groupings_rows"
80
+ <?php
81
+ if ( ! isset( $opts['mc_use_groupings'] ) || $opts['mc_use_groupings'] != 1 ) {
82
+ echo ' style="display:none" ';
83
+ }
84
+ ?>
85
+ >
86
+ <tr valign="top">
87
+ <th scope="row">Grouping name</th>
88
+ <td>
89
+ <input class="widefat" type="text" id="mc_groupings_name" name="nsu_mailinglist[mc_groupings_name]" value="
90
+ <?php
91
+ if ( isset( $opts['mc_groupings_name'] ) ) {
92
+ echo esc_attr( $opts['mc_groupings_name'] );
93
+ }
94
+ ?>
95
+ " /></td>
96
+ </tr>
97
+ <tr valign="top">
98
+ <th scope="row">
99
+ Groups
100
+ <small class="help">(comma delimited list of interest groups to add to)</small>
101
+ </th>
102
+ <td>
103
+ <input class="widefat" type="text" name="nsu_mailinglist[mc_groupings_groups]" placeholder="Example: Group 1,Group 2,Group 3" value="
104
+ <?php
105
+ if ( isset( $opts['mc_groupings_groups'] ) ) {
106
+ echo esc_attr( $opts['mc_groupings_groups'] );
107
+ }
108
+ ?>
109
+ "; />
110
+ </td>
111
+ </tr>
112
+ </tbody>
113
+ </tbody>
trunk/includes/views/parts/rows-phplist.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <?php
3
+ if ( ! isset( $opts['phplist_list_id'] ) ) {
4
+ $opts['phplist_list_id'] = 1;
5
+ }
6
+ ?>
7
+ <tr valign="top">
8
+ <th scope="row">PHPList list ID</th>
9
+ <td>
10
+ <input type="text" class="widefat" name="nsu_mailinglist[phplist_list_id]" value="<?php echo esc_attr( $opts['phplist_list_id'] ); ?>" />
11
+ </td>
12
+ </tr>
trunk/includes/views/parts/rows-ymlp.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <tr valign="top">
3
+ <th scope="row"><label for="use_api">Use the YMLP API?<br />
4
+ <small>(recommended)</small>
5
+ </label></th>
6
+ <td>
7
+ <input type="checkbox" id="use_api" name="nsu_mailinglist[use_api]" value="1"
8
+ <?php
9
+ if ( isset( $opts['use_api'] ) ) {
10
+ checked( $opts['use_api'], 1 );
11
+ }
12
+ ?>
13
+ /></td>
14
+ </tr>
15
+ <tbody class="api_rows"
16
+ <?php
17
+ if ( ! isset( $opts['use_api'] ) || $opts['use_api'] != 1 ) {
18
+ echo ' style="display:none" ';
19
+ }
20
+ ?>
21
+ >
22
+ <tr valign="top">
23
+ <th scope="row">YMLP API Key <a target="_blank" href="http://www.ymlp.com/app/api.php">(?)</a></th>
24
+ <td>
25
+ <input class="widefat" type="text" id="ymlp_api_key" name="nsu_mailinglist[ymlp_api_key]" value="
26
+ <?php
27
+ if ( isset( $opts['ymlp_api_key'] ) ) {
28
+ echo esc_attr( $opts['ymlp_api_key'] );
29
+ }
30
+ ?>
31
+ " /></td>
32
+ </tr>
33
+ <tr valign="top">
34
+ <th scope="row">YMLP Username</th>
35
+ <td>
36
+ <input class="widefat" type="text" id="ymlp_username" name="nsu_mailinglist[ymlp_username]" value="
37
+ <?php
38
+ if ( isset( $opts['ymlp_username'] ) ) {
39
+ echo esc_attr( $opts['ymlp_username'] );
40
+ }
41
+ ?>
42
+ " /></td>
43
+ </tr>
44
+ <tr valign="top">
45
+ <th scope="row">YMLP GroupID<br />
46
+ <small class="help">(starts at 1, check URL when 'viewing all contacts' in certain group)</small>
47
+ </th>
48
+ <td>
49
+ <input class="widefat" type="text" id="ymlp_groupid" name="nsu_mailinglist[ymlp_groupid]" value="
50
+ <?php
51
+ if ( isset( $opts['ymlp_groupid'] ) ) {
52
+ echo esc_attr( $opts['ymlp_groupid'] );
53
+ }
54
+ ?>
55
+ " /></td>
56
+ </tr>
57
+ </tbody>
trunk/includes/views/parts/sidebar.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="nsu-sidebar">
2
+
3
+ <div id="nsu-donate-box">
4
+ <h3>Help us help you</h3>
5
+ <p>If you like Newsletter Sign-Up, consider showing a token of your appreciation:</p>
6
+ <ul class="ul-square">
7
+ <li><a href="https://wordpress.org/support/view/plugin-reviews/newsletter-sign-up?rate=5#postform" target="_blank">Give a &#9733;&#9733;&#9733;&#9733;&#9733; rating on WordPress.org</a></li>
8
+ <li><a href="https://wordpress.org/plugins/newsletter-sign-up/#compatibility">Vote "works" on the Wordpress.org plugin page</a>
9
+ </ul>
10
+ </div>
11
+
12
+ <div>
13
+ <h3>Our other plugins</h3>
14
+ <div style="margin: 12px 0;">
15
+ <div><strong><a href="https://wordpress.org/plugins/mailchimp-for-wp/">MC4WP: Mailchimp for WordPress</a></strong></div>
16
+ <div>The #1 Mailchimp plugin for WordPress.</div>
17
+ </div>
18
+
19
+ <div style="margin: 12px 0;">
20
+ <div><strong><a href="https://wordpress.org/plugins/koko-analytics/">Koko Analytics</a></strong></div>
21
+ <div>Privacy-friendly analytics plugin that does not use any external services.</div>
22
+ </div>
23
+
24
+ <div style="margin: 12px 0;">
25
+ <div><strong><a href="https://wordpress.org/plugins/boxzilla/">Boxzilla Pop-ups</a></strong></div>
26
+ <div>Pop-up or slide-in boxes that can be configured to show up at just the right time.</div>
27
+ </div>
28
+ </div>
29
+
30
+ <div>
31
+ <h3>Need support?</h3>
32
+ <p>Please use the <a href="https://wordpress.org/support/plugin/newsletter-sign-up">WordPress.org support forums for Newsletter Sign-Up</a>.</p>
33
+ </div>
34
+
35
+ </div>
trunk/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header( 'Status: 403 Forbidden' );
5
+ header( 'HTTP/1.1 403 Forbidden' );
6
+ exit;
trunk/newsletter-sign-up.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Newsletter Sign-Up
4
+ Plugin URI: https://dannyvankooten.com/wordpress-plugins/newsletter-sign-up/
5
+ Description: Adds various ways for your visitors to sign-up to your mailing list (checkbox, widget, form)
6
+ Version: 2.0.9
7
+ Author: Danny van Kooten
8
+ Author URI: https://dannyvankooten.com
9
+ License: GPL2
10
+ */
11
+
12
+ /* Copyright 2010-2019 Danny van Kooten (email: hi@dannyvankooten.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
+ if ( ! defined( 'ABSPATH' ) ) {
29
+ exit;
30
+ }
31
+
32
+ define( 'NSU_VERSION', '2.0.9' );
33
+ define( 'NSU_PLUGIN_DIR', dirname( __FILE__ ) );
34
+
35
+ require_once NSU_PLUGIN_DIR . '/includes/class-nsu.php';
36
+ new NSU();
trunk/phpcs.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <ruleset name="rules">
3
+ <description>rules</description>
4
+ <file>includes/</file>
5
+ <file>newsletter-sign-up.php</file>
6
+
7
+ <rule ref="WordPress-Core">
8
+ <exclude name="WordPress.PHP.YodaConditions" />
9
+ <exclude name="WordPress.WP.DeprecatedFunctions.get_settingsFound" />
10
+ <exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned" />
11
+ <exclude name="WordPress.Arrays.ArrayIndentation.ItemNotAligned" />
12
+ <exclude name="WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase" />
13
+ <exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning" />
14
+ </rule>
15
+
16
+ <rule ref="WordPress.WP.I18n">
17
+ <properties>
18
+ <property name="text_domain" type="array">
19
+ <element value="newsletter-sign-up" />
20
+ </property>
21
+ </properties>
22
+ </rule>
23
+
24
+ <rule ref="WordPress.WP.DeprecatedFunctions">
25
+ <properties>
26
+ <property name="minimum_supported_version" value="4.6"/>
27
+ </properties>
28
+ </rule>
29
+
30
+ <rule ref="WordPress.Files.FileName">
31
+ <properties>
32
+ <property name="strict_class_file_names" value="false"/>
33
+ </properties>
34
+ </rule>
35
+
36
+ <rule ref="WordPress.NamingConventions.ValidHookName">
37
+ <properties>
38
+ <property name="additionalWordDelimiters" value="-"/>
39
+ </properties>
40
+ </rule>
41
+
42
+ <rule ref="WordPress.WP.CronInterval">
43
+ <properties>
44
+ <property name="min_interval" value="60"/>
45
+ </properties>
46
+ </rule>
47
+
48
+ <arg name="colors" />
49
+ </ruleset>
trunk/readme.txt ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Newsletter Sign-Up ===
2
+ Contributors: DvanKooten, Ibericode
3
+ Donate link: https://dannyvankooten.com/donate/
4
+ Tags: newsletter, sign-up, mailchimp, aweber, ymlp, phplist, icontact, newsletter widget, subscribe widget
5
+ Requires at least: 4.1
6
+ Tested up to: 5.3
7
+ Stable tag: 2.0.9
8
+ License: GPL2
9
+ Requires PHP: 5.3
10
+
11
+ Integrate your WordPress site with 3rd-party newsletter services like Aweber and YMLP. Adds various sign-up methods to your site.
12
+
13
+ == Description ==
14
+
15
+ = Newsletter Sign-Up =
16
+
17
+ > This plugin is in maintenance mode, meaning we no longer develop new features or actively support it. Sorry.
18
+
19
+ This plugin adds various sign-up methods to your WordPress website, like sign-up checkboxes in your comment form and a sign-up form to show in posts, pages or widget areas.
20
+
21
+ > **Mailchimp user?**
22
+ >
23
+ > Use [Mailchimp for WordPress](https://wordpress.org/plugins/mailchimp-for-wp/) instead. It's free & so much better.
24
+
25
+ This plugin works with *almost all* third-party email marketing services including Mailchimp, CampaignMonitor, ConstantContact, YMLP, Aweber, iContact, PHPList and Feedblitz. With the right configuration settings, you can make this plugin work with *any* newsletter service around.
26
+
27
+ **Features:**
28
+
29
+ * Add a "sign-up to our newsletter" checkbox to your comment form or registration form
30
+ * Easy customizable Newsletter Sign-Up Form Widget
31
+ * Embed a sign-up form in your posts with a simple shortcode `[nsu_form]`.
32
+ * Embed a sign-up form in your template files by calling `nsu_form();`
33
+ * Use the Mailchimp or YMLP API or any other third-party newsletter service.
34
+ * Works with most major mailinglist services like Aweber, Constant Contact, iContact, etc.
35
+ * Compatible with BuddyPress, MultiSite and bbPress.
36
+
37
+ **More information**
38
+
39
+ * [Mailchimp for WordPress plugin](https://mc4wp.com/)
40
+ * More [WordPress plugins](https://dannyvankooten.com/wordpress-plugins/) by ibericode
41
+
42
+ = Sign-up checkboxes =
43
+ Most of your commenters will be interested in your newsletter as well. This plugin makes it extremely easie for them to subscribe to your mailinglist. With the sign-up checkbox, all they have to do is check it and the plugin will subscribe them to your mailinglist.
44
+
45
+ You can also add the sign-up checkbox to your WP registration form, your BuddyPress registration form, your MultiSite sign-up forms or your bbPress new topic and new reply forms.
46
+
47
+ = Sign-up forms =
48
+ Easily configure a sign-up form and show it in various places on your website using the sign-up form widget, the `[nsu_form]` shortcode or the `nsu_form()` template function.
49
+
50
+ You can set your own messages and even choose to redirect the visitor to a certain page after signing-up.
51
+
52
+ == Installation ==
53
+
54
+ 1. Upload the contents of `newsletter-sign-up.zip` to your plugins directory.
55
+ 1. Activate the plugin
56
+ 1. Specify your newsletter service settings.
57
+ 1. That's all. You're done!
58
+
59
+ == Frequently Asked Questions ==
60
+
61
+ = What does this plugin do? =
62
+
63
+ This plugin adds various sign-up methods to your WordPress website, like a sign-up checkbox at your comment form and a sign-up form to show in various places like your posts, pages and widget areas.
64
+
65
+ = What is the shortcode to display a sign-up form in my posts or pages? =
66
+
67
+ `[nsu_form]`
68
+
69
+ = Where can I get the form action of my sign-up form? =
70
+
71
+ Look at the source code of your sign-up form and check for `<form action="http://www.yourmailinglist.com/signup?a=asd123"...`. The action attribute is what you need here.
72
+
73
+ = Where can I get the email identifier of my sign-up form? =
74
+
75
+ Take a look at the source code of your sign-up form and look for the input field for the email address. You'll need the `name` attribute of this input field, eg: `<input type="text" name="emailid"....`
76
+
77
+ = Can I let my users subscribe with their name too? =
78
+
79
+ Yes. Just provide your name identifier (finding it is much like the email identifier) and the plugin will add the users' name to the sign-up request.
80
+
81
+ = Can I show a sign-up form by calling a function in my template files? =
82
+
83
+ Yes, use the following code snippet in your theme files to display a sign-up form.
84
+
85
+ `if(function_exists('nsu_form')) nsu_form();`
86
+
87
+ = Can I use this with Mailchimp? =
88
+
89
+ You can, but we recommend using [Mailchimp for WordPress](https://wordpress.org/plugins/mailchimp-for-wp/) instead.
90
+
91
+
92
+ == Screenshots ==
93
+
94
+ 1. The mailinglist configuration page of Newsletter Sign-Up in the WordPress admin panel.
95
+ 2. The form configuration page in the WP Admin panel.
96
+ 3. The sign-up checkbox in the Twenty Eleven theme
97
+
98
+ == Changelog ==
99
+
100
+ = 2.0.9 - Dec 5, 2019 =
101
+
102
+ - Fix code styling to adhere to WordPress' coding standards
103
+ - Add the plugin to GitHub: [ibericode/newsletter-sign-up](https://github.com/ibericode/newsletter-sign-up)
104
+ - Update tested WordPress version
105
+
106
+
107
+ = 2.0.8 - February 14, 2019 =
108
+
109
+ Maintenance & updated compatibility test with WordPress 5.0.
110
+
111
+
112
+ = 2.0.7 - August 30, 2016 =
113
+
114
+ **Fixes**
115
+
116
+ - Fatal error on configuration helper page.
117
+
118
+
119
+ = 2.0.6 - June 20, 2016 =
120
+
121
+ Minor maintenance round. Removed obsolete HTML5 option, as 99.9% of browsers support this now.
122
+
123
+
124
+ = 2.0.5 - February 19, 2015 =
125
+
126
+ **Improvements**
127
+
128
+ - Updated all links to use HTTPS protocol
129
+
130
+
131
+ = 2.0.4 - October 4, 2014 =
132
+
133
+ * Minor code improvements and WP 4.0+ compatibility.
134
+ * Prevent direct file access
135
+
136
+
137
+ = 2.0.3 =
138
+ * Fixed broken link to settings pages after widget form
139
+ * Improved: better stylesheet loading, encouraged browser caching
140
+ * Improved: Some UI improvements
141
+ * Improved: better default checkbox CSS
142
+ * Improved: better default form CSS
143
+
144
+ = 2.0.2 =
145
+ * Improved: UI improvement, added some HTML5 to settings pages
146
+ * Improved: Code improvement
147
+ * Improved: Config extractor
148
+
149
+ = 2.0.1 =
150
+ * Fixed: not being able to uncheck "Use HTML 5" on form settings page
151
+ * Added: compatibility with bbPress, you can now add a sign-up checkbox to the post new topic and post new reply forms.
152
+ * Fixed: not being able to uncheck "add to comment form" in checkbox settings
153
+ * Fixed: compatibility with other plugins who use a 'functions.php' file (like GDE).
154
+
155
+ = 2.0 =
156
+ * Fixed: spam comments not being filtered
157
+ * Added: HTML 5 form fields (option)
158
+ * Added: Validation texts (option)
159
+ * Fixed: last update broke template functions
160
+ * Added: navigation tabs in back-end
161
+
162
+ = 1.9 =
163
+ * Improved: Code refactoring, less memory usage
164
+ * Improved: Admin panel clean-up
165
+ * Fixed: YMLP API
166
+ * Added: Translation filters to form shortcode output
167
+ * Added: Translation filters to checkbox label
168
+ * Added: SPAM Honeypot to sign-up form to prevent bot subscribers
169
+ * Removed: paragraph tags around hidden fields
170
+
171
+ = 1.8.1 =
172
+ * Improved: automatic guessing of first and last names.
173
+ * Removed backwards compatibility for v1.6 and below
174
+ * Removed unnecessary code, options, etc..
175
+ * Improved: Code clean-up
176
+ * Changed links to show your appreciation for this plugin.
177
+
178
+ = 1.8 =
179
+ * Fixed W3C error because of empty "action" attribute on form tag.
180
+ * Added notice for Mailchimp users to switch to my newer plugin, [Mailchimp for WordPress](https://mc4wp.com/).
181
+ * Further improved the CSS reset for the comment form checkbox
182
+
183
+ = 1.7.9 =
184
+ * Improved CSS Reset for comment checkbox
185
+
186
+ = 1.7.8 =
187
+ * Improved enqueue call to load stylesheet on frontend
188
+ * Fixed notice after submitting widget form (undefined variable $name)
189
+ * Fixed %%IP%% value in widget form
190
+ * Added debugging option. When `_nsu_debug` is in the POST or GET data it will echo the result of the sign-up request.
191
+
192
+ = 1.7.7 =
193
+ * Improved Improved HTML output for forms
194
+ * Improved code indentation
195
+ * Added OnBlur attribute to form input's. Default value now reappears after losing focus (while empty).
196
+ * Added replacement value's for additional data (`%%NAME%%` and `%%IP%%`)
197
+
198
+ = 1.7.6 =
199
+ * Fixed: The plugin now works with PHPList again. Thanks ryanjlaw.
200
+
201
+ = 1.7.5 =
202
+ * Fixed: Hidden inputs are now wrapped by a block element too, so the form output validates as XHTML 1.0 STRICT.
203
+
204
+ = 1.7.4 =
205
+ * Added: Ability to turn off double opt-in (Mailchimp API users only).
206
+ * Improved: Various CSS improvements
207
+
208
+ = 1.7.3 =
209
+ * Fixed: Actual fix for previous two plugin updates. My bad, sorry everone.
210
+
211
+ = 1.7.2 =
212
+ * Fixed: Bug after submitting comment or registration form.
213
+
214
+ = 1.7.1 =
215
+ * Fixed: Bug where you coudln't configure mailinglist specific settings (like MC API).
216
+
217
+ = 1.7 =
218
+ * Added: add subscribers to certain interest group(s) (limited to 1 grouping at the moment). (Mailchimp API users only)
219
+ * Improvement: Slightly better code readability
220
+
221
+ = 1.6.1 =
222
+ * Fixed notice on frontend when e-mail field not filled in
223
+ * Fixed provided values for First and Lastname field for Mailchimp when using both.
224
+
225
+ = 1.6 =
226
+ * Improvement: Huge backend changes. Everything is split up for increased maintainability.
227
+ * Improvement: Better code documenting
228
+ * Improvement: Consistent function names (with backwards compatibility for old function names)
229
+ * Improvement: Only load frontend CSS file if actually needed / asked to.
230
+ * Added: Added CSS class to text after signing up
231
+ * Added: Added option to automatically add paragraph's to text after signing up.
232
+ * Added: Added option to set default value for e-mail and name field.
233
+ * Added: Option to redirect to a given url after signing-up
234
+ * Added: More elegant error handling.
235
+ * Fix: "Hide checkbox for subscribers" did not work after version 1.5.1
trunk/vendor/autoload.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload.php @generated by Composer
4
+
5
+ require_once __DIR__ . '/composer/autoload_real.php';
6
+
7
+ return ComposerAutoloaderInit1a91be15fab4642f5ef43369c5aead5c::getLoader();
trunk/vendor/composer/ClassLoader.php ADDED
@@ -0,0 +1,445 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Composer.
5
+ *
6
+ * (c) Nils Adermann <naderman@naderman.de>
7
+ * Jordi Boggiano <j.boggiano@seld.be>
8
+ *
9
+ * For the full copyright and license information, please view the LICENSE
10
+ * file that was distributed with this source code.
11
+ */
12
+
13
+ namespace Composer\Autoload;
14
+
15
+ /**
16
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17
+ *
18
+ * $loader = new \Composer\Autoload\ClassLoader();
19
+ *
20
+ * // register classes with namespaces
21
+ * $loader->add('Symfony\Component', __DIR__.'/component');
22
+ * $loader->add('Symfony', __DIR__.'/framework');
23
+ *
24
+ * // activate the autoloader
25
+ * $loader->register();
26
+ *
27
+ * // to enable searching the include path (eg. for PEAR packages)
28
+ * $loader->setUseIncludePath(true);
29
+ *
30
+ * In this example, if you try to use a class in the Symfony\Component
31
+ * namespace or one of its children (Symfony\Component\Console for instance),
32
+ * the autoloader will first look for the class under the component/
33
+ * directory, and it will then fallback to the framework/ directory if not
34
+ * found before giving up.
35
+ *
36
+ * This class is loosely based on the Symfony UniversalClassLoader.
37
+ *
38
+ * @author Fabien Potencier <fabien@symfony.com>
39
+ * @author Jordi Boggiano <j.boggiano@seld.be>
40
+ * @see http://www.php-fig.org/psr/psr-0/
41
+ * @see http://www.php-fig.org/psr/psr-4/
42
+ */
43
+ class ClassLoader
44
+ {
45
+ // PSR-4
46
+ private $prefixLengthsPsr4 = array();
47
+ private $prefixDirsPsr4 = array();
48
+ private $fallbackDirsPsr4 = array();
49
+
50
+ // PSR-0
51
+ private $prefixesPsr0 = array();
52
+ private $fallbackDirsPsr0 = array();
53
+
54
+ private $useIncludePath = false;
55
+ private $classMap = array();
56
+ private $classMapAuthoritative = false;
57
+ private $missingClasses = array();
58
+ private $apcuPrefix;
59
+
60
+ public function getPrefixes()
61
+ {
62
+ if (!empty($this->prefixesPsr0)) {
63
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
64
+ }
65
+
66
+ return array();
67
+ }
68
+
69
+ public function getPrefixesPsr4()
70
+ {
71
+ return $this->prefixDirsPsr4;
72
+ }
73
+
74
+ public function getFallbackDirs()
75
+ {
76
+ return $this->fallbackDirsPsr0;
77
+ }
78
+
79
+ public function getFallbackDirsPsr4()
80
+ {
81
+ return $this->fallbackDirsPsr4;
82
+ }
83
+
84
+ public function getClassMap()
85
+ {
86
+ return $this->classMap;
87
+ }
88
+
89
+ /**
90
+ * @param array $classMap Class to filename map
91
+ */
92
+ public function addClassMap(array $classMap)
93
+ {
94
+ if ($this->classMap) {
95
+ $this->classMap = array_merge($this->classMap, $classMap);
96
+ } else {
97
+ $this->classMap = $classMap;
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Registers a set of PSR-0 directories for a given prefix, either
103
+ * appending or prepending to the ones previously set for this prefix.
104
+ *
105
+ * @param string $prefix The prefix
106
+ * @param array|string $paths The PSR-0 root directories
107
+ * @param bool $prepend Whether to prepend the directories
108
+ */
109
+ public function add($prefix, $paths, $prepend = false)
110
+ {
111
+ if (!$prefix) {
112
+ if ($prepend) {
113
+ $this->fallbackDirsPsr0 = array_merge(
114
+ (array) $paths,
115
+ $this->fallbackDirsPsr0
116
+ );
117
+ } else {
118
+ $this->fallbackDirsPsr0 = array_merge(
119
+ $this->fallbackDirsPsr0,
120
+ (array) $paths
121
+ );
122
+ }
123
+
124
+ return;
125
+ }
126
+
127
+ $first = $prefix[0];
128
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
129
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
130
+
131
+ return;
132
+ }
133
+ if ($prepend) {
134
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
135
+ (array) $paths,
136
+ $this->prefixesPsr0[$first][$prefix]
137
+ );
138
+ } else {
139
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
140
+ $this->prefixesPsr0[$first][$prefix],
141
+ (array) $paths
142
+ );
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Registers a set of PSR-4 directories for a given namespace, either
148
+ * appending or prepending to the ones previously set for this namespace.
149
+ *
150
+ * @param string $prefix The prefix/namespace, with trailing '\\'
151
+ * @param array|string $paths The PSR-4 base directories
152
+ * @param bool $prepend Whether to prepend the directories
153
+ *
154
+ * @throws \InvalidArgumentException
155
+ */
156
+ public function addPsr4($prefix, $paths, $prepend = false)
157
+ {
158
+ if (!$prefix) {
159
+ // Register directories for the root namespace.
160
+ if ($prepend) {
161
+ $this->fallbackDirsPsr4 = array_merge(
162
+ (array) $paths,
163
+ $this->fallbackDirsPsr4
164
+ );
165
+ } else {
166
+ $this->fallbackDirsPsr4 = array_merge(
167
+ $this->fallbackDirsPsr4,
168
+ (array) $paths
169
+ );
170
+ }
171
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
172
+ // Register directories for a new namespace.
173
+ $length = strlen($prefix);
174
+ if ('\\' !== $prefix[$length - 1]) {
175
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
176
+ }
177
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
178
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
179
+ } elseif ($prepend) {
180
+ // Prepend directories for an already registered namespace.
181
+ $this->prefixDirsPsr4[$prefix] = array_merge(
182
+ (array) $paths,
183
+ $this->prefixDirsPsr4[$prefix]
184
+ );
185
+ } else {
186
+ // Append directories for an already registered namespace.
187
+ $this->prefixDirsPsr4[$prefix] = array_merge(
188
+ $this->prefixDirsPsr4[$prefix],
189
+ (array) $paths
190
+ );
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Registers a set of PSR-0 directories for a given prefix,
196
+ * replacing any others previously set for this prefix.
197
+ *
198
+ * @param string $prefix The prefix
199
+ * @param array|string $paths The PSR-0 base directories
200
+ */
201
+ public function set($prefix, $paths)
202
+ {
203
+ if (!$prefix) {
204
+ $this->fallbackDirsPsr0 = (array) $paths;
205
+ } else {
206
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Registers a set of PSR-4 directories for a given namespace,
212
+ * replacing any others previously set for this namespace.
213
+ *
214
+ * @param string $prefix The prefix/namespace, with trailing '\\'
215
+ * @param array|string $paths The PSR-4 base directories
216
+ *
217
+ * @throws \InvalidArgumentException
218
+ */
219
+ public function setPsr4($prefix, $paths)
220
+ {
221
+ if (!$prefix) {
222
+ $this->fallbackDirsPsr4 = (array) $paths;
223
+ } else {
224
+ $length = strlen($prefix);
225
+ if ('\\' !== $prefix[$length - 1]) {
226
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
227
+ }
228
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
229
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Turns on searching the include path for class files.
235
+ *
236
+ * @param bool $useIncludePath
237
+ */
238
+ public function setUseIncludePath($useIncludePath)
239
+ {
240
+ $this->useIncludePath = $useIncludePath;
241
+ }
242
+
243
+ /**
244
+ * Can be used to check if the autoloader uses the include path to check
245
+ * for classes.
246
+ *
247
+ * @return bool
248
+ */
249
+ public function getUseIncludePath()
250
+ {
251
+ return $this->useIncludePath;
252
+ }
253
+
254
+ /**
255
+ * Turns off searching the prefix and fallback directories for classes
256
+ * that have not been registered with the class map.
257
+ *
258
+ * @param bool $classMapAuthoritative
259
+ */
260
+ public function setClassMapAuthoritative($classMapAuthoritative)
261
+ {
262
+ $this->classMapAuthoritative = $classMapAuthoritative;
263
+ }
264
+
265
+ /**
266
+ * Should class lookup fail if not found in the current class map?
267
+ *
268
+ * @return bool
269
+ */
270
+ public function isClassMapAuthoritative()
271
+ {
272
+ return $this->classMapAuthoritative;
273
+ }
274
+
275
+ /**
276
+ * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
277
+ *
278
+ * @param string|null $apcuPrefix
279
+ */
280
+ public function setApcuPrefix($apcuPrefix)
281
+ {
282
+ $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
283
+ }
284
+
285
+ /**
286
+ * The APCu prefix in use, or null if APCu caching is not enabled.
287
+ *
288
+ * @return string|null
289
+ */
290
+ public function getApcuPrefix()
291
+ {
292
+ return $this->apcuPrefix;
293
+ }
294
+
295
+ /**
296
+ * Registers this instance as an autoloader.
297
+ *
298
+ * @param bool $prepend Whether to prepend the autoloader or not
299
+ */
300
+ public function register($prepend = false)
301
+ {
302
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
303
+ }
304
+
305
+ /**
306
+ * Unregisters this instance as an autoloader.
307
+ */
308
+ public function unregister()
309
+ {
310
+ spl_autoload_unregister(array($this, 'loadClass'));
311
+ }
312
+
313
+ /**
314
+ * Loads the given class or interface.
315
+ *
316
+ * @param string $class The name of the class
317
+ * @return bool|null True if loaded, null otherwise
318
+ */
319
+ public function loadClass($class)
320
+ {
321
+ if ($file = $this->findFile($class)) {
322
+ includeFile($file);
323
+
324
+ return true;
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Finds the path to the file where the class is defined.
330
+ *
331
+ * @param string $class The name of the class
332
+ *
333
+ * @return string|false The path if found, false otherwise
334
+ */
335
+ public function findFile($class)
336
+ {
337
+ // class map lookup
338
+ if (isset($this->classMap[$class])) {
339
+ return $this->classMap[$class];
340
+ }
341
+ if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
342
+ return false;
343
+ }
344
+ if (null !== $this->apcuPrefix) {
345
+ $file = apcu_fetch($this->apcuPrefix.$class, $hit);
346
+ if ($hit) {
347
+ return $file;
348
+ }
349
+ }
350
+
351
+ $file = $this->findFileWithExtension($class, '.php');
352
+
353
+ // Search for Hack files if we are running on HHVM
354
+ if (false === $file && defined('HHVM_VERSION')) {
355
+ $file = $this->findFileWithExtension($class, '.hh');
356
+ }
357
+
358
+ if (null !== $this->apcuPrefix) {
359
+ apcu_add($this->apcuPrefix.$class, $file);
360
+ }
361
+
362
+ if (false === $file) {
363
+ // Remember that this class does not exist.
364
+ $this->missingClasses[$class] = true;
365
+ }
366
+
367
+ return $file;
368
+ }
369
+
370
+ private function findFileWithExtension($class, $ext)
371
+ {
372
+ // PSR-4 lookup
373
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
374
+
375
+ $first = $class[0];
376
+ if (isset($this->prefixLengthsPsr4[$first])) {
377
+ $subPath = $class;
378
+ while (false !== $lastPos = strrpos($subPath, '\\')) {
379
+ $subPath = substr($subPath, 0, $lastPos);
380
+ $search = $subPath . '\\';
381
+ if (isset($this->prefixDirsPsr4[$search])) {
382
+ $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
383
+ foreach ($this->prefixDirsPsr4[$search] as $dir) {
384
+ if (file_exists($file = $dir . $pathEnd)) {
385
+ return $file;
386
+ }
387
+ }
388
+ }
389
+ }
390
+ }
391
+
392
+ // PSR-4 fallback dirs
393
+ foreach ($this->fallbackDirsPsr4 as $dir) {
394
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
395
+ return $file;
396
+ }
397
+ }
398
+
399
+ // PSR-0 lookup
400
+ if (false !== $pos = strrpos($class, '\\')) {
401
+ // namespaced class name
402
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
403
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
404
+ } else {
405
+ // PEAR-like class name
406
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
407
+ }
408
+
409
+ if (isset($this->prefixesPsr0[$first])) {
410
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
411
+ if (0 === strpos($class, $prefix)) {
412
+ foreach ($dirs as $dir) {
413
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
414
+ return $file;
415
+ }
416
+ }
417
+ }
418
+ }
419
+ }
420
+
421
+ // PSR-0 fallback dirs
422
+ foreach ($this->fallbackDirsPsr0 as $dir) {
423
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
424
+ return $file;
425
+ }
426
+ }
427
+
428
+ // PSR-0 include paths.
429
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
430
+ return $file;
431
+ }
432
+
433
+ return false;
434
+ }
435
+ }
436
+
437
+ /**
438
+ * Scope isolated include.
439
+ *
440
+ * Prevents access to $this/self from included files.
441
+ */
442
+ function includeFile($file)
443
+ {
444
+ include $file;
445
+ }
trunk/vendor/composer/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Copyright (c) Nils Adermann, Jordi Boggiano
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished
9
+ to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+
trunk/vendor/composer/autoload_classmap.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_classmap.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
trunk/vendor/composer/autoload_namespaces.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_namespaces.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
trunk/vendor/composer/autoload_psr4.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_psr4.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
trunk/vendor/composer/autoload_real.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_real.php @generated by Composer
4
+
5
+ class ComposerAutoloaderInit1a91be15fab4642f5ef43369c5aead5c
6
+ {
7
+ private static $loader;
8
+
9
+ public static function loadClassLoader($class)
10
+ {
11
+ if ('Composer\Autoload\ClassLoader' === $class) {
12
+ require __DIR__ . '/ClassLoader.php';
13
+ }
14
+ }
15
+
16
+ public static function getLoader()
17
+ {
18
+ if (null !== self::$loader) {
19
+ return self::$loader;
20
+ }
21
+
22
+ spl_autoload_register(array('ComposerAutoloaderInit1a91be15fab4642f5ef43369c5aead5c', 'loadClassLoader'), true, true);
23
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit1a91be15fab4642f5ef43369c5aead5c', 'loadClassLoader'));
25
+
26
+ $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
+ if ($useStaticLoader) {
28
+ require_once __DIR__ . '/autoload_static.php';
29
+
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit1a91be15fab4642f5ef43369c5aead5c::getInitializer($loader));
31
+ } else {
32
+ $map = require __DIR__ . '/autoload_namespaces.php';
33
+ foreach ($map as $namespace => $path) {
34
+ $loader->set($namespace, $path);
35
+ }
36
+
37
+ $map = require __DIR__ . '/autoload_psr4.php';
38
+ foreach ($map as $namespace => $path) {
39
+ $loader->setPsr4($namespace, $path);
40
+ }
41
+
42
+ $classMap = require __DIR__ . '/autoload_classmap.php';
43
+ if ($classMap) {
44
+ $loader->addClassMap($classMap);
45
+ }
46
+ }
47
+
48
+ $loader->register(true);
49
+
50
+ return $loader;
51
+ }
52
+ }
trunk/vendor/composer/autoload_static.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_static.php @generated by Composer
4
+
5
+ namespace Composer\Autoload;
6
+
7
+ class ComposerStaticInit1a91be15fab4642f5ef43369c5aead5c
8
+ {
9
+ public static function getInitializer(ClassLoader $loader)
10
+ {
11
+ return \Closure::bind(function () use ($loader) {
12
+
13
+ }, null, ClassLoader::class);
14
+ }
15
+ }
vendor/autoload.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload.php @generated by Composer
4
+
5
+ require_once __DIR__ . '/composer/autoload_real.php';
6
+
7
+ return ComposerAutoloaderInit1a91be15fab4642f5ef43369c5aead5c::getLoader();
vendor/composer/ClassLoader.php ADDED
@@ -0,0 +1,445 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Composer.
5
+ *
6
+ * (c) Nils Adermann <naderman@naderman.de>
7
+ * Jordi Boggiano <j.boggiano@seld.be>
8
+ *
9
+ * For the full copyright and license information, please view the LICENSE
10
+ * file that was distributed with this source code.
11
+ */
12
+
13
+ namespace Composer\Autoload;
14
+
15
+ /**
16
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17
+ *
18
+ * $loader = new \Composer\Autoload\ClassLoader();
19
+ *
20
+ * // register classes with namespaces
21
+ * $loader->add('Symfony\Component', __DIR__.'/component');
22
+ * $loader->add('Symfony', __DIR__.'/framework');
23
+ *
24
+ * // activate the autoloader
25
+ * $loader->register();
26
+ *
27
+ * // to enable searching the include path (eg. for PEAR packages)
28
+ * $loader->setUseIncludePath(true);
29
+ *
30
+ * In this example, if you try to use a class in the Symfony\Component
31
+ * namespace or one of its children (Symfony\Component\Console for instance),
32
+ * the autoloader will first look for the class under the component/
33
+ * directory, and it will then fallback to the framework/ directory if not
34
+ * found before giving up.
35
+ *
36
+ * This class is loosely based on the Symfony UniversalClassLoader.
37
+ *
38
+ * @author Fabien Potencier <fabien@symfony.com>
39
+ * @author Jordi Boggiano <j.boggiano@seld.be>
40
+ * @see http://www.php-fig.org/psr/psr-0/
41
+ * @see http://www.php-fig.org/psr/psr-4/
42
+ */
43
+ class ClassLoader
44
+ {
45
+ // PSR-4
46
+ private $prefixLengthsPsr4 = array();
47
+ private $prefixDirsPsr4 = array();
48
+ private $fallbackDirsPsr4 = array();
49
+
50
+ // PSR-0
51
+ private $prefixesPsr0 = array();
52
+ private $fallbackDirsPsr0 = array();
53
+
54
+ private $useIncludePath = false;
55
+ private $classMap = array();
56
+ private $classMapAuthoritative = false;
57
+ private $missingClasses = array();
58
+ private $apcuPrefix;
59
+
60
+ public function getPrefixes()
61
+ {
62
+ if (!empty($this->prefixesPsr0)) {
63
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
64
+ }
65
+
66
+ return array();
67
+ }
68
+
69
+ public function getPrefixesPsr4()
70
+ {
71
+ return $this->prefixDirsPsr4;
72
+ }
73
+
74
+ public function getFallbackDirs()
75
+ {
76
+ return $this->fallbackDirsPsr0;
77
+ }
78
+
79
+ public function getFallbackDirsPsr4()
80
+ {
81
+ return $this->fallbackDirsPsr4;
82
+ }
83
+
84
+ public function getClassMap()
85
+ {
86
+ return $this->classMap;
87
+ }
88
+
89
+ /**
90
+ * @param array $classMap Class to filename map
91
+ */
92
+ public function addClassMap(array $classMap)
93
+ {
94
+ if ($this->classMap) {
95
+ $this->classMap = array_merge($this->classMap, $classMap);
96
+ } else {
97
+ $this->classMap = $classMap;
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Registers a set of PSR-0 directories for a given prefix, either
103
+ * appending or prepending to the ones previously set for this prefix.
104
+ *
105
+ * @param string $prefix The prefix
106
+ * @param array|string $paths The PSR-0 root directories
107
+ * @param bool $prepend Whether to prepend the directories
108
+ */
109
+ public function add($prefix, $paths, $prepend = false)
110
+ {
111
+ if (!$prefix) {
112
+ if ($prepend) {
113
+ $this->fallbackDirsPsr0 = array_merge(
114
+ (array) $paths,
115
+ $this->fallbackDirsPsr0
116
+ );
117
+ } else {
118
+ $this->fallbackDirsPsr0 = array_merge(
119
+ $this->fallbackDirsPsr0,
120
+ (array) $paths
121
+ );
122
+ }
123
+
124
+ return;
125
+ }
126
+
127
+ $first = $prefix[0];
128
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
129
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
130
+
131
+ return;
132
+ }
133
+ if ($prepend) {
134
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
135
+ (array) $paths,
136
+ $this->prefixesPsr0[$first][$prefix]
137
+ );
138
+ } else {
139
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
140
+ $this->prefixesPsr0[$first][$prefix],
141
+ (array) $paths
142
+ );
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Registers a set of PSR-4 directories for a given namespace, either
148
+ * appending or prepending to the ones previously set for this namespace.
149
+ *
150
+ * @param string $prefix The prefix/namespace, with trailing '\\'
151
+ * @param array|string $paths The PSR-4 base directories
152
+ * @param bool $prepend Whether to prepend the directories
153
+ *
154
+ * @throws \InvalidArgumentException
155
+ */
156
+ public function addPsr4($prefix, $paths, $prepend = false)
157
+ {
158
+ if (!$prefix) {
159
+ // Register directories for the root namespace.
160
+ if ($prepend) {
161
+ $this->fallbackDirsPsr4 = array_merge(
162
+ (array) $paths,
163
+ $this->fallbackDirsPsr4
164
+ );
165
+ } else {
166
+ $this->fallbackDirsPsr4 = array_merge(
167
+ $this->fallbackDirsPsr4,
168
+ (array) $paths
169
+ );
170
+ }
171
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
172
+ // Register directories for a new namespace.
173
+ $length = strlen($prefix);
174
+ if ('\\' !== $prefix[$length - 1]) {
175
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
176
+ }
177
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
178
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
179
+ } elseif ($prepend) {
180
+ // Prepend directories for an already registered namespace.
181
+ $this->prefixDirsPsr4[$prefix] = array_merge(
182
+ (array) $paths,
183
+ $this->prefixDirsPsr4[$prefix]
184
+ );
185
+ } else {
186
+ // Append directories for an already registered namespace.
187
+ $this->prefixDirsPsr4[$prefix] = array_merge(
188
+ $this->prefixDirsPsr4[$prefix],
189
+ (array) $paths
190
+ );
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Registers a set of PSR-0 directories for a given prefix,
196
+ * replacing any others previously set for this prefix.
197
+ *
198
+ * @param string $prefix The prefix
199
+ * @param array|string $paths The PSR-0 base directories
200
+ */
201
+ public function set($prefix, $paths)
202
+ {
203
+ if (!$prefix) {
204
+ $this->fallbackDirsPsr0 = (array) $paths;
205
+ } else {
206
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Registers a set of PSR-4 directories for a given namespace,
212
+ * replacing any others previously set for this namespace.
213
+ *
214
+ * @param string $prefix The prefix/namespace, with trailing '\\'
215
+ * @param array|string $paths The PSR-4 base directories
216
+ *
217
+ * @throws \InvalidArgumentException
218
+ */
219
+ public function setPsr4($prefix, $paths)
220
+ {
221
+ if (!$prefix) {
222
+ $this->fallbackDirsPsr4 = (array) $paths;
223
+ } else {
224
+ $length = strlen($prefix);
225
+ if ('\\' !== $prefix[$length - 1]) {
226
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
227
+ }
228
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
229
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Turns on searching the include path for class files.
235
+ *
236
+ * @param bool $useIncludePath
237
+ */
238
+ public function setUseIncludePath($useIncludePath)
239
+ {
240
+ $this->useIncludePath = $useIncludePath;
241
+ }
242
+
243
+ /**
244
+ * Can be used to check if the autoloader uses the include path to check
245
+ * for classes.
246
+ *
247
+ * @return bool
248
+ */
249
+ public function getUseIncludePath()
250
+ {
251
+ return $this->useIncludePath;
252
+ }
253
+
254
+ /**
255
+ * Turns off searching the prefix and fallback directories for classes
256
+ * that have not been registered with the class map.
257
+ *
258
+ * @param bool $classMapAuthoritative
259
+ */
260
+ public function setClassMapAuthoritative($classMapAuthoritative)
261
+ {
262
+ $this->classMapAuthoritative = $classMapAuthoritative;
263
+ }
264
+
265
+ /**
266
+ * Should class lookup fail if not found in the current class map?
267
+ *
268
+ * @return bool
269
+ */
270
+ public function isClassMapAuthoritative()
271
+ {
272
+ return $this->classMapAuthoritative;
273
+ }
274
+
275
+ /**
276
+ * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
277
+ *
278
+ * @param string|null $apcuPrefix
279
+ */
280
+ public function setApcuPrefix($apcuPrefix)
281
+ {
282
+ $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
283
+ }
284
+
285
+ /**
286
+ * The APCu prefix in use, or null if APCu caching is not enabled.
287
+ *
288
+ * @return string|null
289
+ */
290
+ public function getApcuPrefix()
291
+ {
292
+ return $this->apcuPrefix;
293
+ }
294
+
295
+ /**
296
+ * Registers this instance as an autoloader.
297
+ *
298
+ * @param bool $prepend Whether to prepend the autoloader or not
299
+ */
300
+ public function register($prepend = false)
301
+ {
302
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
303
+ }
304
+
305
+ /**
306
+ * Unregisters this instance as an autoloader.
307
+ */
308
+ public function unregister()
309
+ {
310
+ spl_autoload_unregister(array($this, 'loadClass'));
311
+ }
312
+
313
+ /**
314
+ * Loads the given class or interface.
315
+ *
316
+ * @param string $class The name of the class
317
+ * @return bool|null True if loaded, null otherwise
318
+ */
319
+ public function loadClass($class)
320
+ {
321
+ if ($file = $this->findFile($class)) {
322
+ includeFile($file);
323
+
324
+ return true;
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Finds the path to the file where the class is defined.
330
+ *
331
+ * @param string $class The name of the class
332
+ *
333
+ * @return string|false The path if found, false otherwise
334
+ */
335
+ public function findFile($class)
336
+ {
337
+ // class map lookup
338
+ if (isset($this->classMap[$class])) {
339
+ return $this->classMap[$class];
340
+ }
341
+ if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
342
+ return false;
343
+ }
344
+ if (null !== $this->apcuPrefix) {
345
+ $file = apcu_fetch($this->apcuPrefix.$class, $hit);
346
+ if ($hit) {
347
+ return $file;
348
+ }
349
+ }
350
+
351
+ $file = $this->findFileWithExtension($class, '.php');
352
+
353
+ // Search for Hack files if we are running on HHVM
354
+ if (false === $file && defined('HHVM_VERSION')) {
355
+ $file = $this->findFileWithExtension($class, '.hh');
356
+ }
357
+
358
+ if (null !== $this->apcuPrefix) {
359
+ apcu_add($this->apcuPrefix.$class, $file);
360
+ }
361
+
362
+ if (false === $file) {
363
+ // Remember that this class does not exist.
364
+ $this->missingClasses[$class] = true;
365
+ }
366
+
367
+ return $file;
368
+ }
369
+
370
+ private function findFileWithExtension($class, $ext)
371
+ {
372
+ // PSR-4 lookup
373
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
374
+
375
+ $first = $class[0];
376
+ if (isset($this->prefixLengthsPsr4[$first])) {
377
+ $subPath = $class;
378
+ while (false !== $lastPos = strrpos($subPath, '\\')) {
379
+ $subPath = substr($subPath, 0, $lastPos);
380
+ $search = $subPath . '\\';
381
+ if (isset($this->prefixDirsPsr4[$search])) {
382
+ $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
383
+ foreach ($this->prefixDirsPsr4[$search] as $dir) {
384
+ if (file_exists($file = $dir . $pathEnd)) {
385
+ return $file;
386
+ }
387
+ }
388
+ }
389
+ }
390
+ }
391
+
392
+ // PSR-4 fallback dirs
393
+ foreach ($this->fallbackDirsPsr4 as $dir) {
394
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
395
+ return $file;
396
+ }
397
+ }
398
+
399
+ // PSR-0 lookup
400
+ if (false !== $pos = strrpos($class, '\\')) {
401
+ // namespaced class name
402
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
403
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
404
+ } else {
405
+ // PEAR-like class name
406
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
407
+ }
408
+
409
+ if (isset($this->prefixesPsr0[$first])) {
410
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
411
+ if (0 === strpos($class, $prefix)) {
412
+ foreach ($dirs as $dir) {
413
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
414
+ return $file;
415
+ }
416
+ }
417
+ }
418
+ }
419
+ }
420
+
421
+ // PSR-0 fallback dirs
422
+ foreach ($this->fallbackDirsPsr0 as $dir) {
423
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
424
+ return $file;
425
+ }
426
+ }
427
+
428
+ // PSR-0 include paths.
429
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
430
+ return $file;
431
+ }
432
+
433
+ return false;
434
+ }
435
+ }
436
+
437
+ /**
438
+ * Scope isolated include.
439
+ *
440
+ * Prevents access to $this/self from included files.
441
+ */
442
+ function includeFile($file)
443
+ {
444
+ include $file;
445
+ }
vendor/composer/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Copyright (c) Nils Adermann, Jordi Boggiano
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished
9
+ to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+
vendor/composer/autoload_classmap.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_classmap.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_namespaces.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_namespaces.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_psr4.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_psr4.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_real.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_real.php @generated by Composer
4
+
5
+ class ComposerAutoloaderInit1a91be15fab4642f5ef43369c5aead5c
6
+ {
7
+ private static $loader;
8
+
9
+ public static function loadClassLoader($class)
10
+ {
11
+ if ('Composer\Autoload\ClassLoader' === $class) {
12
+ require __DIR__ . '/ClassLoader.php';
13
+ }
14
+ }
15
+
16
+ public static function getLoader()
17
+ {
18
+ if (null !== self::$loader) {
19
+ return self::$loader;
20
+ }
21
+
22
+ spl_autoload_register(array('ComposerAutoloaderInit1a91be15fab4642f5ef43369c5aead5c', 'loadClassLoader'), true, true);
23
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit1a91be15fab4642f5ef43369c5aead5c', 'loadClassLoader'));
25
+
26
+ $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
+ if ($useStaticLoader) {
28
+ require_once __DIR__ . '/autoload_static.php';
29
+
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit1a91be15fab4642f5ef43369c5aead5c::getInitializer($loader));
31
+ } else {
32
+ $map = require __DIR__ . '/autoload_namespaces.php';
33
+ foreach ($map as $namespace => $path) {
34
+ $loader->set($namespace, $path);
35
+ }
36
+
37
+ $map = require __DIR__ . '/autoload_psr4.php';
38
+ foreach ($map as $namespace => $path) {
39
+ $loader->setPsr4($namespace, $path);
40
+ }
41
+
42
+ $classMap = require __DIR__ . '/autoload_classmap.php';
43
+ if ($classMap) {
44
+ $loader->addClassMap($classMap);
45
+ }
46
+ }
47
+
48
+ $loader->register(true);
49
+
50
+ return $loader;
51
+ }
52
+ }
vendor/composer/autoload_static.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_static.php @generated by Composer
4
+
5
+ namespace Composer\Autoload;
6
+
7
+ class ComposerStaticInit1a91be15fab4642f5ef43369c5aead5c
8
+ {
9
+ public static function getInitializer(ClassLoader $loader)
10
+ {
11
+ return \Closure::bind(function () use ($loader) {
12
+
13
+ }, null, ClassLoader::class);
14
+ }
15
+ }