Skip to content

Commit 3cda251

Browse files
Fix undefined index notice in CF7 integration
1 parent c7866fd commit 3cda251

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

includes/integrations/class-general.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ public function checkbox_was_checked() {
8080
*/
8181
public function try_subscribe( $trigger = 'other_form' ) {
8282

83-
if ( $this->checkbox_was_checked() === false ) {
84-
return false;
85-
}
86-
8783
// start running..
8884
$email = null;
8985
$merge_vars = array(

includes/integrations/class-integration.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
abstract class MC4WP_Integration {
1010

11-
protected $checkbox_name_value = '_mc4wp_subscribe';
12-
11+
/**
12+
* @var string
13+
*/
1314
protected $type = 'integration';
1415

1516
/**
@@ -27,7 +28,7 @@ public function checkbox_was_checked() {
2728
return false;
2829
}
2930

30-
return ( isset( $_POST[ $this->checkbox_name_value ] ) && $_POST[ $this->checkbox_name_value ] == 1 );
31+
return ( isset( $_POST[ '_mc4wp_subscribe' ] ) && $_POST[ '_mc4wp_subscribe' ] == 1 );
3132
}
3233

3334
/**
@@ -83,7 +84,7 @@ public function get_checkbox( $args = array() ) {
8384
// checkbox
8485
$content .= '<p id="mc4wp-checkbox">';
8586
$content .= '<label>';
86-
$content .= '<input type="checkbox" name="' . esc_attr( $this->checkbox_name_value ) . '" value="1" '. $checked . ' /> ';
87+
$content .= '<input type="checkbox" name="_mc4wp_subscribe" value="1" '. $checked . ' /> ';
8788
$content .= $label;
8889
$content .= '</label>';
8990
$content .= '</p>';
@@ -140,11 +141,11 @@ protected function subscribe( $email, array $merge_vars = array(), $signup_type
140141

141142
if( empty( $lists) ) {
142143
if( ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && current_user_can( 'manage_options' ) ) {
143-
wp_die('
144-
<h3>MailChimp for WP - Error</h3>
145-
<p>Please select a list to subscribe to in the <a href="'. admin_url( 'admin.php?page=mc4wp-checkbox-settings' ) .'">checkbox settings</a>.</p>
146-
<p style="font-style:italic; font-size:12px;">This message is only visible to administrators for debugging purposes.</p>
147-
', 'Error - MailChimp for WP', array( 'back_link' => true ) );
144+
wp_die(
145+
'<h3>MailChimp for WP - Error</h3>
146+
<p>Please select a list to subscribe to in the <a href="'. admin_url( 'admin.php?page=mc4wp-lite-checkbox-settings' ) .'">checkbox settings</a>.</p>
147+
<p style="font-style:italic; font-size:12px;">This message is only visible to administrators for debugging purposes.</p>',
148+
'Error - MailChimp for WP', array( 'back_link' => true ) );
148149
}
149150

150151
return 'no_lists_selected';
@@ -169,7 +170,7 @@ protected function subscribe( $email, array $merge_vars = array(), $signup_type
169170
do_action( 'mc4wp_before_subscribe', $email, $merge_vars );
170171

171172
foreach( $lists as $list_id ) {
172-
$result = $api->subscribe( $list_id, $email, $merge_vars, $email_type, $opts['double_optin'], false, true, $opts['send_welcome'] );
173+
$result = $api->subscribe( $list_id, $email, $merge_vars, $email_type, $opts['double_optin'], false, true );
173174
}
174175

175176
do_action( 'mc4wp_after_subscribe', $email, $merge_vars, $result );

0 commit comments

Comments
 (0)