From c0d2c3234466692c1a823aed59d3eb7a2ea105cb Mon Sep 17 00:00:00 2001 From: Salman Date: Mon, 22 Dec 2014 15:09:34 -0500 Subject: [PATCH] Add theme stylesheet options in customizer --- functions.php | 107 +++++--------------------------- stylesheets/sherman-default.css | 3 + 2 files changed, 20 insertions(+), 90 deletions(-) create mode 100644 stylesheets/sherman-default.css diff --git a/functions.php b/functions.php index a5290a0..f15eda4 100644 --- a/functions.php +++ b/functions.php @@ -5,17 +5,6 @@ * */ -// any custom js or css - -function sherman_scripts() { - wp_enqueue_script( 'sherman-js', get_stylesheet_directory_uri() . '/javascripts/min/sherman.min.js', array( 'jquery' )); -} - -add_action( 'wp_enqueue_scripts', 'sherman_scripts'); - - - - // Remove the Header Image Feature function sherman_remove_theme_features() { @@ -26,106 +15,44 @@ function sherman_remove_theme_features() { add_action( 'init', 'sherman_remove_theme_features' ); function sherman_customize_register( $wp_customize ) { - $wp_customize->remove_section('colors'); + //$wp_customize->remove_section('colors'); $wp_customize->remove_section('background_image'); $wp_customize->remove_section('nav'); } add_action( 'customize_register', 'sherman_customize_register' ); - - - - // Add Options for Sherman-specific Color options. -/* + function sherman_titlebar_register( $wp_customize ){ - $wp_customize->add_setting( 'titlebarColor', //Give it a SERIALIZED name (so all theme settings can live under one db record) + $wp_customize->add_setting( 'themeColor', //Give it a SERIALIZED name (so all theme settings can live under one db record) array( - 'default' => 'lightgrey', //Default setting/value to save + 'default' => 'sherman-default', //Default setting/value to save 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. 'transport' => 'refresh' ) ); - $wp_customize->add_control('titlebarColor', array( + $wp_customize->add_control('themeColor', array( 'type' => 'radio', - 'label' => 'Titlebar Color', + 'label' => 'Stylesheet', 'section' => 'colors', 'choices' => array( - 'blue'=>'Blue', - 'red'=>'Red', - 'black' => 'Black', - 'darkgrey' => 'Dark Grey', - 'lightgrey' => 'Light Grey', - 'white' => 'White' - ) - ) - ); - $wp_customize->add_setting( 'navColor', //Give it a SERIALIZED name (so all theme settings can live under one db record) - array( - 'default' => 'lightgrey', //Default setting/value to save - 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? - 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. - 'transport' => 'refresh' - ) - ); - $wp_customize->add_control('navColor', array( - 'type' => 'radio', - 'label' => 'Navigation Color', - 'section' => 'colors', - 'choices' => array( - 'blue'=>'Blue', - 'red'=>'Red', - 'black' => 'Black', - 'darkgrey' => 'Dark Grey', - 'lightgrey' => 'Light Grey', - 'white' => 'White' - ) - ) - ); - $wp_customize->add_setting( 'contentColor', //Give it a SERIALIZED name (so all theme settings can live under one db record) - array( - 'default' => 'standard', //Default setting/value to save - 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? - 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. - 'transport' => 'refresh' - ) - ); - $wp_customize->add_control('contentColor', array( - 'type' => 'radio', - 'label' => 'Text Colors', - 'section' => 'colors', - 'choices' => array( - 'standard'=>'Standard', - 'reverse'=>'Reverse' - ) - ) - ); - $wp_customize->add_setting( 'footColor', //Give it a SERIALIZED name (so all theme settings can live under one db record) - array( - 'default' => 'lightgrey', //Default setting/value to save - 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? - 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. - 'transport' => 'refresh' - ) - ); - $wp_customize->add_control('footColor', array( - 'type' => 'radio', - 'label' => 'Footer Color', - 'section' => 'colors', - 'choices' => array( - 'blue'=>'Blue', - 'red'=>'Red', - 'black' => 'Black', - 'darkgrey' => 'Dark Grey', - 'lightgrey' => 'Light Grey', - 'white' => 'White' + 'sherman-default' => 'Sherman Default', + 'sherman-red' => 'Sherman Red', + 'sherman-black' => 'Sherman Black', ) ) ); } add_action( 'customize_register', 'sherman_titlebar_register' , 34); -*/ + +function sherman_scripts() { + wp_enqueue_script( 'sherman-js', get_stylesheet_directory_uri() . '/javascripts/min/sherman.min.js', array( 'jquery' )); + $stylesheet = get_theme_mod('themeColor'); + wp_enqueue_style( $stylesheet, get_stylesheet_directory_uri() . '/stylesheets/'.$stylesheet.'.css', array('cs-style') ); +} + +add_action( 'wp_enqueue_scripts', 'sherman_scripts'); ?> \ No newline at end of file diff --git a/stylesheets/sherman-default.css b/stylesheets/sherman-default.css new file mode 100644 index 0000000..b959e66 --- /dev/null +++ b/stylesheets/sherman-default.css @@ -0,0 +1,3 @@ +/* +Sample css file, just to check if customizer stylesheet picking works + */ \ No newline at end of file