Skip to content

Commit

Permalink
Merge pull request #4 from rinatkhaziev/master
Browse files Browse the repository at this point in the history
Fix a warning produced when second parameter for in_array check was actually a string instead of array. This check is needed to determine if a checkbox in a set of values for multiple checkboxes is selected but only one or no values were set, resulting options_checked variable being a string instead of an array. Cast to array before doing the check
  • Loading branch information
sboisvert committed Feb 24, 2014
2 parents f2c58db + 821e59d commit 8a08ded
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion library.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ function write_html() {
<input type="hidden" name="<?php echo esc_attr( $this->id ); ?>" />
<?php $count = 0; ?>
<?php foreach( $this->options as $option ) : ?>
<?php $checked = in_array( $option , $this->options_checked ) ? ' checked="checked" ' : ''; ?>
<?php $checked = in_array( $option , (array) $this->options_checked ) ? ' checked="checked" ' : ''; ?>
<?php $option_label = isset( $this->options_labels[$count] ) ? $this->options_labels[$count] : $option; ?>
<input type="checkbox" name="<?php echo esc_attr( $this->id ); ?>[]" id="<?php echo esc_attr( $this->id ); ?>-<?php echo esc_attr( $option ); ?>" value="<?php echo esc_attr( $option ); ?>" <?php echo $checked; ?> />
<label for="<?php echo esc_attr( $this->id ); ?>-<?php echo esc_attr( $option ); ?>"><?php echo esc_html( $option_label ); ?></label>
Expand Down

0 comments on commit 8a08ded

Please sign in to comment.