Skip to content

Instantly share code, notes, and snippets.

@designbuildtest
Created September 30, 2015 03:54
Show Gist options
  • Save designbuildtest/c90a040ce231e0197bb5 to your computer and use it in GitHub Desktop.
Save designbuildtest/c90a040ce231e0197bb5 to your computer and use it in GitHub Desktop.
Timezone customizer setting and control
<?php
/**
* Timezone
*
*/
$wp_customize->add_setting( 'timezone_string', array(
'type' => 'option',
'sanitize_callback' => 'sanitize_text_field',
) );
class Timezone_Control extends WP_Customize_Control {
public $type = 'dbt_timezone';
public function render_content() {
$timezone = get_option( 'timezone_string' );
$selected = esc_attr( $timezone ); ?>
<label>
<span class="customize-control-title"><?php esc_html_e( $this->label ); ?></span>
<span class="description customize-control-description"><?php esc_html_e( $this->description ); ?></span>
<select name="timezone_string" value <?php $this->link()?>>
<?php echo wp_timezone_choice( $selected ); ?>
</select>
</label><?php
}
}
$wp_customize->add_control( new Timezone_Control( $wp_customize, 'timezone_string', array(
'section' => 'dbt_settings',
'label' => __( 'Timezone' ),
'priority' => 30,
) ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment