manager->get_control( $setting->id )->choices; //return input if valid or return default option return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } /** * Sanitize Checkbox Control Setting * @since 1.0.0 */ function ananya_sanitize_checkbox( $input ){ // Boolean check. return ( ( isset( $input ) && true === $input ) ? true : false ); } /** * Sanitize Text Control Setting * @since 1.0.0 */ function ananya_sanitize_text( $input ) { /** * @var array[] $allowedtags Array of KSES allowed HTML elements. * @since 1.0.0 */ $allowedtags = array( 'a' => array( 'href' => true, 'title' => true, ), 'abbr' => array( 'title' => true, ), 'acronym' => array( 'title' => true, ), 'b' => array(), 'blockquote' => array( 'cite' => true, ), 'br' => array(), 'button' => array( 'disabled' => true, 'name' => true, 'type' => true, 'value' => true, ), 'cite' => array(), 'code' => array(), 'del' => array( 'datetime' => true, ), 'em' => array(), 'i' => array(), 'q' => array( 'cite' => true, ), 's' => array(), 'strike' => array(), 'strong' => array(), ); return wp_kses( force_balance_tags( $input ), $allowedtags ); } /** * Sanitize Select Control Setting * @since 1.0.0 */ function ananya_sanitize_select( $input, $setting ) { // get all select options $options = $setting->manager->get_control( $setting->id )->choices; // return default if not valid return ( array_key_exists( $input, $options ) ? $input : $setting->default ); }