diff --git a/functions.php b/functions.php index 4649838..c90312a 100644 --- a/functions.php +++ b/functions.php @@ -110,17 +110,33 @@ function metallic_customize_register($wp_customize) { metallic_add_option($wp_customize, 'show_title', __('Show Title', 'default')); metallic_add_option($wp_customize, 'gradients', __('Gradients', 'metallic')); metallic_add_option($wp_customize, 'show_logo', __('Show Logo', 'default')); - metallic_add_option($wp_customize, 'logo_url', __('Logo URL', 'metallic'), 'text'); + metallic_add_option($wp_customize, 'logo_url', __('Logo URL', 'metallic'), 'text', ''); +// metallic_add_option($wp_customize, 'user_color', __('User Color', 'metallic'), 'colorbox', ''); + // ============================= - // Select Scheme + // = Color Picker = // ============================= - $wp_customize->add_setting('color_scheme', array( - 'default' => 'Gray', - 'capability' => 'edit_theme_options', - 'type' => 'theme_mod', //or 'option' if u want to have a record in database + + $wp_customize->add_setting('user_color', array( + 'default' => '', + 'sanitize_callback' => 'sanitize_hex_color', + 'capability' => 'edit_theme_options', + 'type' => 'theme_mod', )); + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'user_color', array( + 'settings' => 'user_color', + 'label' => __('User Color', 'metallic'), + 'section' => 'metallic_options' + ) + ) + ); + + // ============================= + // Select Scheme + // ============================= + $shemes = array(); $dir = dirname(__FILE__).'/schemes'; @@ -137,12 +153,19 @@ function metallic_customize_register($wp_customize) { closedir($handle); } - $wp_customize->add_control( 'color_select_box', array( + $wp_customize->add_setting('color_scheme', array( + 'default' => 'Gray', + 'capability' => 'edit_theme_options', + 'type' => 'theme_mod', //or 'option' if u want to have a record in database + + )); + + $wp_customize->add_control('color_select_box', array( 'settings' => 'color_scheme', - 'label' => 'Select Color:', - 'section' => 'metallic_options', - 'type' => 'select', - 'choices' => $shemes + 'label' => __('Select Scheme', 'metallic'), + 'section' => 'metallic_options', + 'type' => 'select', + 'choices' => $shemes ) ); } @@ -163,11 +186,13 @@ function metallic_generate_css_cache(){ global $wp_customize; $scheme = get_theme_mod('color_scheme', 'gray'); $gradients = get_theme_mod('gradients', true); + $user_color = get_theme_mod('user_color', ''); $css_macro = new CssMacro; $css_macro->load_values(dirname(__FILE__).'/default.scheme.ini'); $css_macro->load_values(dirname(__FILE__).'/schemes/'.$scheme.'.scheme.ini'); $css_macro->set('gradients', $gradients); $css_macro->set('scheme', $scheme); + $css_macro->set('user_color', $user_color); $file= dirname(__FILE__).'/style.css'; if (file_exists($file)) { $style = file_get_contents($file); diff --git a/header.php b/header.php index ce32bca..1689550 100644 --- a/header.php +++ b/header.php @@ -23,6 +23,13 @@ else $pass .= '0'; + $user_color = get_theme_mod('user_color', ''); + if (!empty($user_color)) { + if (substr($user_color, 0, 1) === '#') + $user_color = substr($user_color, 1); + $pass .= '&user_color='.$user_color; + } + if (isset($_GET['scheme']) and !empty($_GET['scheme'])) $scheme = $_GET['scheme']; /* if Debug is enabled or using theme customize we need on the fly css */ diff --git a/style.css b/style.css index 0445f82..ff219bc 100644 --- a/style.css +++ b/style.css @@ -151,7 +151,7 @@ embed, iframe, object { position: relative; background: $color(base); $if(gradients)< - background: linear-gradient(to bottom, $color(base, 10) 1%, $color(base, 25) 10%, $color(base) 40%); + background: linear-gradient(to bottom, $color(base, 10) 1%, $color(base, 25) 10%, $color(base) 60%); > z-index: 999; text-decoration: none; diff --git a/style.php b/style.php index 908c5a3..eb1950f 100644 --- a/style.php +++ b/style.php @@ -20,11 +20,20 @@ if (empty($gradients)) $gradients = '0'; //default; +if (isset($_GET['user_color']) and !empty($_GET['user_color'])) + $user_color = $_GET['user_color']; + +if (!empty($user_color)) { + if (substr($user_color, 0, 1) === '#') + $user_color = substr($user_color, 1); +} $css_macro = new CssMacro(); $css_macro->load_values(dirname(__FILE__).'/default.scheme.ini'); //load default values $css_macro->load_values(dirname(__FILE__).'/schemes/'.$scheme.'.scheme.ini'); $css_macro->set('gradients', $gradients); +if (!empty($user_color)) + $css_macro->set('base', '#'.$user_color); $css_macro->set('scheme', $scheme); echo $css_macro->generate(file_get_contents(dirname(__FILE__).'/style.css'));