Last active
September 30, 2015 03:57
-
-
Save designbuildtest/e5e73ed24703a043e6ca to your computer and use it in GitHub Desktop.
Language customizer control
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Language | |
* | |
*/ | |
$wp_customize->add_setting( 'WPLANG', array( | |
'type' => 'option', | |
'sanitize_callback' => 'dbt_sanitize_language_choice', | |
) ); | |
$wp_customize->add_control( 'WPLANG', array( | |
'section' => 'dbt_settings', | |
'type' => 'select', | |
'label' => __( 'Language' ), | |
'choices' => dbt_language_choices(), | |
'priority' => 70, | |
) ); | |
/** Language choices. */ | |
function dbt_language_choices() { | |
return apply_filters( 'dbt_language_choices', array( | |
'de_DE' => __( 'German' ), | |
'' => __( 'English (US)' ), | |
'en_GB' => __( 'English (UK)' ), | |
'es_ES' => __( 'Spanish' ), | |
) ); | |
} | |
function dbt_sanitize_language_choice( $value ) { | |
$choices = dbt_language_choices(); | |
if ( ! array_key_exists( $value, $choices ) ) { | |
$value = ''; | |
} | |
return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment