0 ){ return (int) $value; }else if( $value = '' || $value < 0 ){ return $value = ''; }else{ return $value = ''; } } /** * Float value sanitization */ function themecon_sanitize_float( $value ) { return filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); } /** * Select sanitization * * @param string $input Slug to sanitize. * @param WP_Customize_Setting $setting Setting instance. * @return string Sanitized slug if it is a valid choice; otherwise, the setting default. */ function themecon_sanitize_select( $input, $setting ){ //input must be a slug: lowercase alphanumeric characters, dashes and underscores are allowed only //get the list of possible select options $choices = $setting->manager->get_control( $setting->id.'_control' )->choices; //return input if valid or return default option return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } /** *Checkbox sanitization */ function themecon_sanitize_checkbox( $input ){ //returns true if checkbox is checked return ( $input ? true : false ); } function themecon_validate_image( $input, $default = '' ) { $img_types = array( 'jpg|jpeg|jpe' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', ); $file = wp_check_filetype( $input, $img_types ); return ( $file['ext'] ? $input : $default ); } ?>