Skip to content

Instantly share code, notes, and snippets.

@designbuildtest
Created September 30, 2015 04:02
Show Gist options
  • Save designbuildtest/77cc1fd50fb9409b11e6 to your computer and use it in GitHub Desktop.
Save designbuildtest/77cc1fd50fb9409b11e6 to your computer and use it in GitHub Desktop.
Customizer YES/NO choices
<?php
// Sanitize YES/NO choice.
function dbt_yes_no_choices() {
return apply_filters( 'dbt_yes_no_choices', array(
'no' => __( 'No' ),
'yes' => __( 'Yes' ),
) );
}
function dbt_sanitize_yes_no_choice( $value ) {
$choices = dbt_yes_no_choices();
if ( ! array_key_exists( $value, $choices ) ) {
$value = 'no';
}
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment