Skip to content

Commit 0e0e5f1

Browse files
committed
Hide settings if list is not selected.
1 parent 0fca2d7 commit 0e0e5f1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

views/setup_page.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// If we have an API Key, see if we need to change the lists and its options
1212
mailchimp_sf_change_list_if_necessary();
13+
14+
$is_list_selected = false;
1315
?>
1416
<div class="wrap">
1517
<hr class="wp-header-end" />
@@ -76,7 +78,15 @@
7678
</div>
7779
<?php
7880
} else {
79-
$lists = $lists['lists'];
81+
$lists = $lists['lists'];
82+
$option = get_option( 'mc_list_id' );
83+
$list_ids = array_map(
84+
function( $list ) {
85+
return $list['id'];
86+
},
87+
$lists
88+
);
89+
$is_list_selected = in_array( $option, $list_ids, true );
8090
?>
8191
<table class="mc-list-select" cellspacing="0">
8292
<tr class="mc-list-row">
@@ -86,7 +96,6 @@
8696
<option value=""> &mdash; <?php esc_html_e( 'Select A List', 'mailchimp' ); ?> &mdash; </option>
8797
<?php
8898
foreach ( $lists as $list ) {
89-
$option = get_option( 'mc_list_id' );
9099
?>
91100
<option value="<?php echo esc_attr( $list['id'] ); ?>"<?php selected( $list['id'], $option ); ?>><?php echo esc_html( $list['name'] ); ?></option>
92101
<?php
@@ -110,7 +119,7 @@
110119

111120
<?php
112121
// Just get out if nothing else matters...
113-
if ( get_option( 'mc_list_id' ) === '' ) {
122+
if ( ! $is_list_selected ) {
114123
return;
115124
}
116125

0 commit comments

Comments
 (0)