/* * Sanitize Checkbox */ // Source: https://github.com/FlagshipWP/flagship-library/blob/develop/customizer/classes/customizer-base.php /** * Sanitize a checkbox to only allow 0 or 1 * * @since 1.2.0 * @access public * @param $input * @return int */ public function sanitize_checkbox( $input ) { return ( 1 === absint( $input ) ) ? 1 : 0; } //Source: https://github.com/WPTRT/code-examples/blob/master/customizer/sanitization-callbacks.php /** * Checkbox Sanitization Callback * * Sanitization callback for 'checkbox' type controls. * This callback sanitizes $input as a Boolean value, either * TRUE or FALSE. */ function theme_slug_sanitize_checkbox( $input ) { // Boolean check return ( ( isset( $input ) && true == $input ) ? true : false ); }