@@ -30,6 +30,11 @@ class MC4WP_Lite_Form_Request {
30
30
*/
31
31
private $ error_code = 'error ' ;
32
32
33
+ /**
34
+ * @var array The form options
35
+ */
36
+ private $ options ;
37
+
33
38
/**
34
39
* Constructor
35
40
*
@@ -81,6 +86,9 @@ public function act() {
81
86
// store number of submitted form
82
87
$ this ->form_instance_number = absint ( $ _POST ['_mc4wp_form_instance ' ] );
83
88
89
+ // store form options
90
+ $ this ->form_options = mc4wp_get_options ( 'form ' );
91
+
84
92
// validate form nonce
85
93
if ( ! isset ( $ _POST ['_mc4wp_form_nonce ' ] ) || ! wp_verify_nonce ( $ _POST ['_mc4wp_form_nonce ' ], '_mc4wp_form_nonce ' ) ) {
86
94
$ this ->error_code = 'invalid_nonce ' ;
@@ -140,11 +148,9 @@ public function act() {
140
148
// do stuff on success
141
149
if ( true === $ this ->success ) {
142
150
143
- $ opts = mc4wp_get_options ('form ' );
144
-
145
151
// check if we want to redirect the visitor
146
- if ( ! empty ( $ opts ['redirect ' ] ) ) {
147
- wp_redirect ( $ opts ['redirect ' ] );
152
+ if ( ! empty ( $ this -> form_options ['redirect ' ] ) ) {
153
+ wp_redirect ( $ this -> form_options ['redirect ' ] );
148
154
exit ;
149
155
}
150
156
@@ -266,7 +272,6 @@ private function subscribe( $email, $merge_vars = array() ) {
266
272
}
267
273
268
274
$ api = mc4wp_get_api ();
269
- $ opts = mc4wp_get_options ( 'form ' );
270
275
271
276
// get lists to subscribe to
272
277
$ lists = $ this ->get_lists ();
@@ -292,7 +297,7 @@ private function subscribe( $email, $merge_vars = array() ) {
292
297
$ list_merge_vars = apply_filters ( 'mc4wp_merge_vars ' , $ merge_vars , 0 , $ list_id );
293
298
294
299
// send a subscribe request to MailChimp for each list
295
- $ result = $ api ->subscribe ( $ list_id , $ email , $ list_merge_vars , $ email_type , $ opts ['double_optin ' ] );
300
+ $ result = $ api ->subscribe ( $ list_id , $ email , $ list_merge_vars , $ email_type , $ this -> form_options ['double_optin ' ] );
296
301
}
297
302
298
303
do_action ( 'mc4wp_after_subscribe ' , $ email , $ merge_vars , 0 , $ result );
@@ -411,9 +416,7 @@ private function get_email_type( ) {
411
416
*/
412
417
private function get_lists () {
413
418
414
- $ opts = mc4wp_get_options ('form ' );
415
-
416
- $ lists = $ opts ['lists ' ];
419
+ $ lists = $ this ->form_options ['lists ' ];
417
420
418
421
// get lists from form, if set.
419
422
if ( isset ( $ _POST ['_mc4wp_lists ' ] ) && ! empty ( $ _POST ['_mc4wp_lists ' ] ) ) {
0 commit comments