Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions mailchimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -683,9 +683,15 @@ function mailchimp_sf_get_merge_vars( $list_id, $new_list ) {
update_option( 'mc_merge_vars', $mv['merge_fields'] );
foreach ( $mv['merge_fields'] as $mv_var ) {
$opt = 'mc_mv_' . $mv_var['tag'];
// turn them all on by default
if ( $new_list ) {
update_option( $opt, 'on' );
$public = isset( $mv_var['public'] ) ? $mv_var['public'] : false;
if ( ! $public ) {
// This is a hidden field, so we don't want to include it.
update_option( $opt, 'off' );
} else {
// We need to set the option to 'on' so that it shows up in the form.
update_option( $opt, 'on' );
}
}
}
return $mv['merge_fields'];
Expand Down
25 changes: 25 additions & 0 deletions mailchimp_upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ function mailchimp_version_check() {
mailchimp_update_1_6_0();
}

if ( false === $db_option || version_compare( '1.7.0', $db_option, '>' ) ) {
mailchimp_update_1_7_0();
}

update_option( 'mc_version', MCSF_VER );
}

Expand All @@ -36,3 +40,24 @@ function mailchimp_version_check() {
function mailchimp_update_1_6_0() {
delete_option( 'mc_rewards' );
}

/**
* Version 1.7.0 update routine
* - Set "Include?" value to "off" for hidden fields
*
* @return void
*/
function mailchimp_update_1_7_0() {
$form_fields = get_option( 'mc_merge_vars' );

if ( ! empty( $form_fields ) && is_array( $form_fields ) ) {
foreach ( $form_fields as $field ) {
if ( ! $field['required'] && ! $field['public'] ) {
$option = 'mc_mv_' . $field['tag'];
// This is a hidden field, so we don't want to include it.
// We need to set the option to 'off' so that it doesn't show up in the form.
update_option( $option, 'off' );
}
}
}
}
6 changes: 1 addition & 5 deletions mailchimp_widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,7 @@ function mailchimp_sf_signup_form( $args = array() ) {

// Loop over our vars, and output the ones that are set to display
foreach ( $mv as $mv_var ) {
if ( ! $mv_var['public'] ) {
echo '<div style="display:none;">' . mailchimp_form_field( $mv_var, $num_fields ) . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Ignoring because form field is escaped in function
} else {
echo mailchimp_form_field( $mv_var, $num_fields ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Ignoring because form field is escaped in function
}
echo mailchimp_form_field( $mv_var, $num_fields ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Ignoring because form field is escaped in function
}

// Show an explanation of the * if there's more than one field
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"build": "10up-toolkit build"
},
"devDependencies": {
"@10up/cypress-wp-utils": "^0.4.0",
"@10up/cypress-wp-utils": "^0.5.0",
"@wordpress/env": "^10.2.0",
"10up-toolkit": "^6.2.0",
"cypress": "^13.13.2",
Expand Down
2 changes: 1 addition & 1 deletion views/setup_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ function ( $ele ) {
<td><?php echo esc_html( ( 1 === intval( $mv_var['required'] ) ) ? 'Y' : 'N' ); ?></td>
<td>
<?php
if ( ! $mv_var['required'] && $mv_var['public'] ) {
if ( ! $mv_var['required'] ) {
$opt = 'mc_mv_' . $mv_var['tag'];
?>
<label class="screen-reader-text" for="<?php echo esc_attr( $opt ); ?>">
Expand Down