'Roboto', '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' ); if ( array_key_exists( $input_bodyfont, $valid_bodyfont ) ) { return $input_bodyfont; } else { return 'Lato'; } } // Sanitizing headings font function atomic_sanitize_headingsfont( $input_headingsfont ) { $valid_headingsfont = array( 'Roboto' => 'Roboto', '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 'Roboto Condensed'; } } // Sanitizing Overlay options function atomic_sanitize_overlay( $input_overlay ) { $valid_overlay = array( 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAQAAADYv8WvAAAADklEQVQIHWNgYGBoACMABIoBAUIssgcAAAAASUVORK5CYII=' => 'Pattern1-default', 'iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAD0lEQVQIW2NkQABjRmQOAAM+AGkQsDBSAAAAAElFTkSuQmCC' => 'Pattern2', 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAEUlEQVQIHWNggIBiEGUFxJUABisBJ85jLc8AAAAASUVORK5CYII=' => 'Pattern3', 'iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAGklEQVQIW2P4//8/AxI2RuGAaBQOTADOAWEAjAwwnWPnCWYAAAAASUVORK5CYII=' => 'Pattern4', 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg==' => 'None' ); if ( array_key_exists( $input_overlay, $valid_overlay ) ) { return $input_overlay; } else { return 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAQAAADYv8WvAAAADklEQVQIHWNgYGBoACMABIoBAUIssgcAAAAASUVORK5CYII='; } } // Sanitizing checkboxes function atomic_sanitize_checkbox( $input_checkbox ) { if ( $input_checkbox == 1 ) { return 1; } else { return ''; } } // Sanitizing uploads function atomic_sanitize_image( $input_image ) { $output = ''; $filetype = wp_check_filetype($input_image); if ( $filetype["ext"] ) { $output = $input_image; } return $output; } function atomic_customize_register( $wp_customize ) { // Register Theme section $wp_customize->add_section( 'typography', array( 'title' => __( 'Typography', 'atomic' ), 'priority' => 40, ) ); // Register Theme section $wp_customize->add_section( 'post_options', array( 'title' => __( 'Post Options', 'atomic' ), 'priority' => 50, ) ); // Link Color $wp_customize->add_setting( 'links_color', array( 'default' => '#00C8C8', '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 & Accent Color', 'atomic' ), 'section' => 'colors', 'settings' => 'links_color', 'priority' => 10, ) ) ); // Logo $wp_customize->add_setting( 'logo', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'atomic_sanitize_image', 'transport' => 'refresh' ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'logo', array( 'label' => __( 'Upload your custom logo.', 'atomic' ), 'section' => 'title_tagline', 'settings' => 'logo', 'context' => 'logo', 'priority' => 30, ) ) ); // Typography $wp_customize->add_setting( 'body_font', array( 'default' => 'Lato', 'sanitize_callback' => 'atomic_sanitize_bodyfont', ) ); $wp_customize->add_setting( 'headings_font', array( 'default' => 'Roboto Condensed', 'sanitize_callback' => 'atomic_sanitize_headingsfont', ) ); $wp_customize->add_setting( 'bold_titles', array( 'default' => '1', 'sanitize_callback' => 'atomic_sanitize_checkbox', ) ); $wp_customize->add_control( 'body_font', array( 'label' => __( 'Body Font', 'atomic' ), 'section' => 'typography', 'settings' => 'body_font', 'type' => 'select', 'choices' => array( 'Roboto' => 'Roboto', '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', 'atomic' ), 'section' => 'typography', 'settings' => 'headings_font', 'type' => 'select', 'choices' => array( 'Roboto' => 'Roboto', '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', 'atomic' ), 'section' => 'typography', 'priority' => 60 ) ); // Overlay options $wp_customize->add_setting( 'overlay_options', array( 'default' => 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAQAAADYv8WvAAAADklEQVQIHWNgYGBoACMABIoBAUIssgcAAAAASUVORK5CYII=', 'sanitize_callback' => 'atomic_sanitize_overlay', ) ); $wp_customize->add_control( 'overlay_options', array( 'label' => __( 'Overlay pattern options', 'atomic' ), 'section' => 'header_image', 'settings' => 'overlay_options', 'type' => 'select', 'choices' => array( 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAQAAADYv8WvAAAADklEQVQIHWNgYGBoACMABIoBAUIssgcAAAAASUVORK5CYII=' => 'Pattern1-default', 'iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAD0lEQVQIW2NkQABjRmQOAAM+AGkQsDBSAAAAAElFTkSuQmCC' => 'Pattern2', 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAEUlEQVQIHWNggIBiEGUFxJUABisBJ85jLc8AAAAASUVORK5CYII=' => 'Pattern3', 'iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAGklEQVQIW2P4//8/AxI2RuGAaBQOTADOAWEAjAwwnWPnCWYAAAAASUVORK5CYII=' => 'Pattern4', 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg==' => 'None' ), 'priority' => 70 ) ); // Post Options $wp_customize->add_setting( 'featured_header', array( 'sanitize_callback' => 'atomic_sanitize_checkbox', ) ); $wp_customize->add_setting( 'post_sidebar', array( 'sanitize_callback' => 'atomic_sanitize_checkbox', ) ); $wp_customize->add_control( 'featured_header', array( 'type' => 'checkbox', 'label' => __( 'Use the featured image as header background image.', 'atomic' ), 'section' => 'post_options', 'priority' => 70 ) ); $wp_customize->add_control( 'post_sidebar', array( 'type' => 'checkbox', 'label' => __( 'Show sidebar on single posts and pages.', 'atomic' ), 'section' => 'post_options', 'priority' => 80 ) ); $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', 'atomic_customize_register' ); /** * Outputting the custom css from the theme customizer. */ function atomic_custom_css() { //Body and headings type if ( 'Lato' != get_theme_mod( 'body_font', 'Lato' ) ) { ?>