add_setting('roman_link_color', array( 'default' => '#555555', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color', )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'roman_link_color', array( 'label' => __('Link and Highlight Color','roman'), 'section' => 'colors', 'settings' => 'roman_link_color', ))); // Logo upload $wp_customize->add_section('roman_logo_section', array( 'title' => __('Logo', 'roman'), 'priority' => 30, 'description' => __('Upload a logo to replace the default site name and description in the header','roman'), )); $wp_customize->add_setting('roman_logo', array( 'sanitize_callback' => 'esc_url_raw', )); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'roman_logo', array( 'label' => __('Logo', 'roman'), 'section' => 'roman_logo_section', 'settings' => 'roman_logo', ))); $wp_customize->add_setting( 'logo_placement', array( 'default' => 'center', 'sanitize_callback' => 'roman_sanitize_logo_placement', ) ); $wp_customize->add_control( 'logo_placement', array( 'type' => 'radio', 'label' => __('Logo placement','roman'), 'section' => 'roman_logo_section', 'choices' => array( 'left' => 'Left', 'right' => 'Right', 'center' => 'Center', ), ) ); $wp_customize->add_section('copyright_text', array( 'title' => __('Copyrigth text', 'roman') )); $wp_customize->add_setting( 'copyright_textbox', array( 'default' => __('Default copyright text','roman'), 'sanitize_callback' => 'roman_sanitize_text', ) ); $wp_customize->add_control( 'copyright_textbox', array( 'label' => __('Copyright text','roman'), 'section' => 'copyright_text', 'type' => 'text', ) ); $wp_customize->add_setting( 'hide_copyright',array( 'sanitize_callback' => 'roman_sanitize_checkbox', )); $wp_customize->add_control( 'hide_copyright', array( 'type' => 'checkbox', 'label' => __('Hide copyright text','roman'), 'section' => 'copyright_text', ) ); } add_action('customize_register', 'roman_theme_customizer'); /** * Sanitizes a hex color. Identical to core's sanitize_hex_color(), which is not available on the wp_head hook. * * Returns either '', a 3 or 6 digit hex color (with #), or null. * For sanitizing values without a #, see sanitize_hex_color_no_hash(). * * @since 1.7 */ function roman_sanitize_hex_color($color) { if ('' === $color) return ''; // 3 or 6 hex digits, or the empty string. if (preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color)) return $color; return null; } /** * Sanitizes our post content value (either excerpts or full post content). * * @since 1.7 */ function roman_sanitize_index_content($content) { if ('option2' == $content) { return 'option2'; } else { return 'option1'; } } function roman_sanitize_text( $input ) { return wp_kses_post( force_balance_tags( $input ) ); } function roman_sanitize_logo_placement( $input ) { $valid = array( 'left' => 'Left', 'right' => 'Right', 'center' => 'Center', ); if ( array_key_exists( $input, $valid ) ) { return $input; } else { return ''; } } function roman_sanitize_checkbox( $input ) { if ( $input == 1 ) { return 1; } else { return ''; } } /** * Add CSS in for styles handled by the theme customizer * * @since 1.5 */ function roman_add_customizer_css() { $color = roman_sanitize_hex_color(get_theme_mod('roman_link_color')); ?>