'Source Sans Pro', 'Open Sans' => 'Open Sans', 'Lato' => 'Lato', 'Merriweather Sans' => 'Merriweather Sans', 'Ubuntu' => 'Ubuntu', 'Vollkorn' => 'Vollkorn', 'Alegreya' => 'Alegreya', 'Lora' => 'Lora', 'Sorts Mill Goudy' => 'Sorts Mill Goudy', 'Droid Serif' => 'Droid Serif', 'Noto Serif' => 'Noto Serif', 'Gentium Book Basic' => 'Gentium Book Basic' ); if ( array_key_exists( $input_bodyfont, $valid_bodyfont ) ) { return $input_bodyfont; } else { return 'Source Sans Pro'; } } // Sanitizing headings font function accent_sanitize_headingsfont( $input_headingsfont ) { $valid_headingsfont = array( 'Source Sans Pro' => 'Source Sans Pro', 'Open Sans' => 'Open Sans', 'Lato' => 'Lato', 'Merriweather Sans' => 'Merriweather Sans', 'Ubuntu' => 'Ubuntu', 'Vollkorn' => 'Vollkorn', 'Alegreya' => 'Alegreya', 'Lora' => 'Lora', 'Sorts Mill Goudy' => 'Sorts Mill Goudy', 'Droid Serif' => 'Droid Serif', 'Noto Serif' => 'Noto Serif', 'Gentium Book Basic' => 'Gentium Book Basic', 'Roboto Condensed' => 'Roboto Condensed', 'Varela Round' => 'Varela Round', 'Montserrat' => 'Montserrat', 'Sanchez' => 'Sanchez', 'Patua One' => 'Patua One', 'Bitter' => 'Bitter', 'Libre Baskerville' => 'Libre Baskerville' ); if ( array_key_exists( $input_headingsfont, $valid_headingsfont ) ) { return $input_headingsfont; } else { return 'Varela Round'; } } // Sanitizing checkboxes function accent_sanitize_checkbox( $input_checkbox ) { if ( $input_checkbox == 1 ) { return 1; } else { return ''; } } // Sanitizing uploads function accent_sanitize_image( $input_image ) { $output = ''; $filetype = wp_check_filetype($input_image); if ( $filetype["ext"] ) { $output = $input_image; } return $output; } function accent_customize_register( $wp_customize ) { // Register Theme section $wp_customize->add_section( 'typography', array( 'title' => __( 'Typography', 'accent' ), 'priority' => 40, ) ); // Link Color $wp_customize->add_setting( 'links_color', array( 'default' => '#48A3A6', 'sanitize_callback' => 'sanitize_hex_color', 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'transport' => 'refresh', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'links_color', array( 'label' => __( 'Links Color', 'accent' ), 'section' => 'colors', 'settings' => 'links_color', 'priority' => 10, ) ) ); // Header background color $wp_customize->add_setting( 'header_background', array( 'default' => '#2B2F3E', 'sanitize_callback' => 'sanitize_hex_color', 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'transport' => 'refresh', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_background', array( 'label' => __( 'Main Menu & Footer info Background Color', 'accent' ), 'section' => 'colors', 'settings' => 'header_background', 'priority' => 20, ) ) ); // Logo $wp_customize->add_setting( 'logo', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'accent_sanitize_image', 'transport' => 'refresh' ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'logo', array( 'label' => __( 'Upload your custom logo.', 'accent' ), 'section' => 'title_tagline', 'settings' => 'logo', 'context' => 'logo', 'priority' => 30, ) ) ); // Typography $wp_customize->add_setting( 'body_font', array( 'default' => 'Source Sans Pro', 'sanitize_callback' => 'accent_sanitize_bodyfont', ) ); $wp_customize->add_setting( 'headings_font', array( 'default' => 'Varela Round', 'sanitize_callback' => 'accent_sanitize_headingsfont', ) ); $wp_customize->add_setting( 'bold_titles', array( 'default' => '1', 'sanitize_callback' => 'accent_sanitize_checkbox', ) ); $wp_customize->add_control( 'body_font', array( 'label' => __( 'Body Font', 'accent' ), 'section' => 'typography', 'settings' => 'body_font', 'type' => 'select', 'choices' => array( 'Source Sans Pro' => 'Source Sans Pro', 'Open Sans' => 'Open Sans', 'Lato' => 'Lato', 'Merriweather Sans' => 'Merriweather Sans', 'Ubuntu' => 'Ubuntu', 'Vollkorn' => 'Vollkorn', 'Alegreya' => 'Alegreya', 'Lora' => 'Lora', 'Sorts Mill Goudy' => 'Sorts Mill Goudy', 'Droid Serif' => 'Droid Serif', 'Noto Serif' => 'Noto Serif', 'Gentium Book Basic' => 'Gentium Book Basic' ), 'priority' => 40 ) ); $wp_customize->add_control( 'headings_font', array( 'label' => __( 'Headings Font', 'accent' ), 'section' => 'typography', 'settings' => 'headings_font', 'type' => 'select', 'choices' => array( 'Source Sans Pro' => 'Source Sans Pro', 'Open Sans' => 'Open Sans', 'Lato' => 'Lato', 'Merriweather Sans' => 'Merriweather Sans', 'Ubuntu' => 'Ubuntu', 'Vollkorn' => 'Vollkorn', 'Alegreya' => 'Alegreya', 'Lora' => 'Lora', 'Sorts Mill Goudy' => 'Sorts Mill Goudy', 'Droid Serif' => 'Droid Serif', 'Noto Serif' => 'Noto Serif', 'Gentium Book Basic' => 'Gentium Book Basic', 'Roboto Condensed' => 'Roboto Condensed', 'Varela Round' => 'Varela Round', 'Montserrat' => 'Montserrat', 'Sanchez' => 'Sanchez', 'Patua One' => 'Patua One', 'Bitter' => 'Bitter', 'Libre Baskerville' => 'Libre Baskerville' ), 'priority' => 50 ) ); $wp_customize->add_control( 'bold_titles', array( 'type' => 'checkbox', 'label' => 'Bold Entry Titles', 'section' => 'typography', 'priority' => 60 ) ); $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'refresh'; } add_action( 'customize_register', 'accent_customize_register' ); /** * Outputting the custom css from the theme customizer. */ function accent_custom_css() { //Body and headings type if ( 'Source Sans Pro' != get_theme_mod( 'body_font', 'Source Sans Pro' ) ) { ?>