From 181c3638003c123658d4a8dc420292089c8feddb Mon Sep 17 00:00:00 2001 From: obenland Date: Wed, 28 Nov 2012 14:51:38 -0800 Subject: [PATCH 1/4] Theme Customizer > Theme Options * Removes sample theme options * Adds Theme Customizer enhancement (actually working!) Goal: Emphasize the use of the Customizer versus out of style Theme Options. --- functions.php | 4 +- inc/theme-customizer.php | 30 +++ inc/theme-options/theme-options.php | 306 ---------------------------- js/theme-customizer.js | 19 ++ 4 files changed, 51 insertions(+), 308 deletions(-) create mode 100644 inc/theme-customizer.php delete mode 100644 inc/theme-options/theme-options.php create mode 100644 js/theme-customizer.js diff --git a/functions.php b/functions.php index cc043c24..049d1735 100644 --- a/functions.php +++ b/functions.php @@ -37,9 +37,9 @@ function _s_setup() { require( get_template_directory() . '/inc/extras.php' ); /** - * Custom Theme Options + * Theme Customizer additions */ - //require( get_template_directory() . '/inc/theme-options/theme-options.php' ); + require( get_template_directory() . '/inc/theme-customizer.php' ); /** * WordPress.com-specific functions and definitions diff --git a/inc/theme-customizer.php b/inc/theme-customizer.php new file mode 100644 index 00000000..e7876799 --- /dev/null +++ b/inc/theme-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/theme-customizer.js', array( 'customize-preview' ), '20120827', true ); +} +add_action( 'customize_preview_init', '_s_customize_preview_js' ); \ No newline at end of file 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(); - ?> - - - - - - - - -
- -
- - - - -
- - -

- - -
- -
-
- Date: Fri, 30 Nov 2012 09:13:05 -0800 Subject: [PATCH 2/4] s/theme-customizer/customizer --- functions.php | 4 ++-- inc/{theme-customizer.php => customizer.php} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename inc/{theme-customizer.php => customizer.php} (100%) diff --git a/functions.php b/functions.php index 049d1735..14e2b00c 100644 --- a/functions.php +++ b/functions.php @@ -37,9 +37,9 @@ function _s_setup() { require( get_template_directory() . '/inc/extras.php' ); /** - * Theme Customizer additions + * Customizer additions */ - require( get_template_directory() . '/inc/theme-customizer.php' ); + require( get_template_directory() . '/inc/customizer.php' ); /** * WordPress.com-specific functions and definitions diff --git a/inc/theme-customizer.php b/inc/customizer.php similarity index 100% rename from inc/theme-customizer.php rename to inc/customizer.php From 5bfc37093bf41409f90a2987d537b3030b1ddfeb Mon Sep 17 00:00:00 2001 From: obenland Date: Fri, 30 Nov 2012 09:26:37 -0800 Subject: [PATCH 3/4] Follow through with 'customizer' naming convention. --- inc/customizer.php | 2 +- js/{theme-customizer.js => customizer.js} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename js/{theme-customizer.js => customizer.js} (100%) diff --git a/inc/customizer.php b/inc/customizer.php index e7876799..b3556c0b 100644 --- a/inc/customizer.php +++ b/inc/customizer.php @@ -25,6 +25,6 @@ add_action( 'customize_register', '_s_customize_register' ); * @since _s 1.2 */ function _s_customize_preview_js() { - wp_enqueue_script( '_s-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20120827', true ); + 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' ); \ No newline at end of file diff --git a/js/theme-customizer.js b/js/customizer.js similarity index 100% rename from js/theme-customizer.js rename to js/customizer.js From faf979bb4d180b40b15ed6635a634a7634436c95 Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Fri, 28 Dec 2012 08:38:18 -0800 Subject: [PATCH 4/4] Add a space to let it shine. --- inc/customizer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/customizer.php b/inc/customizer.php index b3556c0b..a9768532 100644 --- a/inc/customizer.php +++ b/inc/customizer.php @@ -23,8 +23,8 @@ 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' ); \ No newline at end of file +add_action( 'customize_preview_init', '_s_customize_preview_js' );