add_section('bsblog_options', array( 'title' => __('Options for BS Blog', 'bsblog'), 'priority' => 10, 'capability' => 'edit_theme_options', 'description' => __('Allows you to customize theme settings for Rowling.', 'bsblog'), )); $wp_customize->add_setting('accent_color', array( 'default' => '#00ad25', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_hex_color', )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'bsblog_accent_color', array( 'label' => __('Accent Color', 'bsblog'), 'section' => 'bsblog_options', 'settings' => 'accent_color', 'priority' => 10, ))); if (get_theme_mod('bsblog_logo')) { $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'bsblog_logo', array( 'label' => __('Logo', 'bsblog'), 'section' => 'bsblog_options', 'settings' => 'bsblog_logo', ))); $wp_customize->add_setting('bsblog_logo', array( 'sanitize_callback' => 'esc_url_raw', )); } } public static function header_output() { $accent_default = '#0093C2'; $accent = get_theme_mod('accent_color', $accent_default); if (!$accent || $accent == $accent_default) { return; } echo ''; echo ''; echo ''; } public static function generate_css($selector, $style, $value, $prefix = '', $postfix = '', $echo = true) { $return = ''; if ($value) { $return = sprintf('%s { %s:%s; }', $selector, $style, $prefix . $value . $postfix ); if ($echo) { echo $return; } } return $return; } } add_action('customize_register', array('BSBlog_Customize', 'register')); add_action('wp_head', array('BSBlog_Customize', 'header_output')); endif;