Skip to content

Commit

Permalink
Fixed settings validation for boolean flags
Browse files Browse the repository at this point in the history
  • Loading branch information
stklcode committed Nov 2, 2018
1 parent 3eecaaf commit 0d23a27
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions includes/class-scliveticker-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,11 @@ public static function settings_page() {
*/
public static function validate_settings( $input ) {
$defaults = self::default_options();
$result = wp_parse_args( $input, $defaults );
foreach ( $defaults as $k => $v ) {
if ( is_int( $v ) ) {
$result[ $k ] = intval( $result[ $k ] );
}
}

$result['enable_ajax'] = isset( $input['enable_ajax'] ) ? intval( $input['enable_ajax'] ) : 0;
$result['poll_interval'] = isset( $input['poll_interval'] ) ? intval( $input['poll_interval'] ) : $defaults['poll_interval'];
$result['enable_css'] = isset( $input['enable_css'] ) ? intval( $input['enable_css'] ) : 0;
$result['show_feed'] = isset( $input['show_feed'] ) ? intval( $input['show_feed'] ) : 0;

return $result;
}
Expand Down

0 comments on commit 0d23a27

Please sign in to comment.