diff --git a/functions.php b/functions.php index cc043c24..14e2b00c 100644 --- a/functions.php +++ b/functions.php @@ -37,9 +37,9 @@ function _s_setup() { require( get_template_directory() . '/inc/extras.php' ); /** - * Custom Theme Options + * Customizer additions */ - //require( get_template_directory() . '/inc/theme-options/theme-options.php' ); + require( get_template_directory() . '/inc/customizer.php' ); /** * WordPress.com-specific functions and definitions diff --git a/inc/customizer.php b/inc/customizer.php new file mode 100644 index 00000000..a9768532 --- /dev/null +++ b/inc/customizer.php @@ -0,0 +1,30 @@ +get_setting( 'blogname' )->transport = 'postMessage'; + $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; +} +add_action( 'customize_register', '_s_customize_register' ); + +/** + * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. + * + * @since _s 1.2 + */ +function _s_customize_preview_js() { + wp_enqueue_script( '_s_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20120827', true ); +} +add_action( 'customize_preview_init', '_s_customize_preview_js' ); diff --git a/inc/theme-options/theme-options.php b/inc/theme-options/theme-options.php deleted file mode 100644 index 015ff133..00000000 --- a/inc/theme-options/theme-options.php +++ /dev/null @@ -1,306 +0,0 @@ - array( - 'value' => '0', - 'label' => __( 'Zero', '_s' ) - ), - '1' => array( - 'value' => '1', - 'label' => __( 'One', '_s' ) - ), - '2' => array( - 'value' => '2', - 'label' => __( 'Two', '_s' ) - ), - '3' => array( - 'value' => '3', - 'label' => __( 'Three', '_s' ) - ), - '4' => array( - 'value' => '4', - 'label' => __( 'Four', '_s' ) - ), - '5' => array( - 'value' => '5', - 'label' => __( 'Five', '_s' ) - ) - ); - - return apply_filters( '_s_sample_select_options', $sample_select_options ); -} - -/** - * Returns an array of sample radio options registered for _s. - * - * @since _s 1.0 - */ -function _s_sample_radio_buttons() { - $sample_radio_buttons = array( - 'yes' => array( - 'value' => 'yes', - 'label' => __( 'Yes', '_s' ) - ), - 'no' => array( - 'value' => 'no', - 'label' => __( 'No', '_s' ) - ), - 'maybe' => array( - 'value' => 'maybe', - 'label' => __( 'Maybe', '_s' ) - ) - ); - - return apply_filters( '_s_sample_radio_buttons', $sample_radio_buttons ); -} - -/** - * Returns the options array for _s. - * - * @since _s 1.0 - */ -function _s_get_theme_options() { - $saved = (array) get_option( '_s_theme_options' ); - $defaults = array( - 'sample_checkbox' => 'off', - 'sample_text_input' => '', - 'sample_select_options' => '', - 'sample_radio_buttons' => '', - 'sample_textarea' => '', - ); - - $defaults = apply_filters( '_s_default_theme_options', $defaults ); - - $options = wp_parse_args( $saved, $defaults ); - $options = array_intersect_key( $options, $defaults ); - - return $options; -} - -/** - * Renders the sample checkbox setting field. - */ -function _s_settings_field_sample_checkbox() { - $options = _s_get_theme_options(); - ?> - - - - - - - - -