get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; // Theme Settings $wp_customize->add_panel( 'dl_panel', array( 'title' => 'Theme Settings', 'priority' => 10, ) ); // Logo Section $wp_customize->add_section( 'dl_logo_section', array( 'title' => __( 'Logo', 'brilliant' ), 'description' => __( 'To upload your Logo go to Customizer -> Site Identity. Need WordPress 4.5+', 'brilliant' ), 'priority' => 5, 'panel' => 'dl_panel', ) ); // Logo Max Width (desktop) $wp_customize->add_setting( 'dl_logo_width_desktop', array( 'default' => 240, 'sanitize_callback' => 'dl_sanitize_integer', ) ); $wp_customize->add_control( 'dl_logo_width_desktop', array( 'label' => __( 'Max Width (desktop)', 'brilliant' ), 'section' => 'dl_logo_section', 'settings' => 'dl_logo_width_desktop', 'type' => 'number', ) ); // Logo Max Width (mobile) $wp_customize->add_setting( 'dl_logo_width_mobile', array( 'default' => 180, 'sanitize_callback' => 'dl_sanitize_integer', ) ); $wp_customize->add_control( 'dl_logo_width_mobile', array( 'label' => __( 'Max Width (mobile)', 'brilliant' ), 'section' => 'dl_logo_section', 'settings' => 'dl_logo_width_mobile', 'type' => 'number', ) ); // Header Section $wp_customize->add_section( 'dl_header_section', array( 'title' => __( 'Header', 'brilliant' ), 'priority' => 10, 'panel' => 'dl_panel', ) ); // Homepage Section $wp_customize->add_section( 'dl_home_section', array( 'title' => __( 'Homepage', 'brilliant' ), 'priority' => 15, 'panel' => 'dl_panel', 'description' => __( 'Settings for Homepage.', 'brilliant' ), ) ); // Homepage Styles $wp_customize->add_setting( 'dl_home_style', array( 'default' => 'home1', 'sanitize_callback' => 'dl_sanitize_choices', ) ); $wp_customize->add_control( 'dl_home_style', array( 'label' => __( 'Homepage Styles', 'brilliant' ), 'section' => 'dl_home_section', 'settings' => 'dl_home_style', 'type' => 'radio', 'choices' => array( 'home0' => __('Classic: One Column Posts + Sidebar', 'brilliant'), 'home1' => __('Fashion: First Article Fullwidth, two Column Posts + Sidebar', 'brilliant'), 'home2' => __('Modern: First Article Fullwidth, one Column Posts + Sidebar', 'brilliant'), ), ) ); // Blog Section $wp_customize->add_section( 'dl_blog_section', array( 'title' => __( 'Blog', 'brilliant' ), 'priority' => 20, 'panel' => 'dl_panel', 'description' => __( 'Settings for Category, Tag, Search result, Author and Archive Pages.', 'brilliant' ), ) ); // Blog Styles $wp_customize->add_setting( 'dl_blog_style', array( 'default' => 'blog1', 'sanitize_callback' => 'dl_sanitize_choices', ) ); $wp_customize->add_control( 'dl_blog_style', array( 'label' => __( 'Blog Styles', 'brilliant' ), 'section' => 'dl_blog_section', 'settings' => 'dl_blog_style', 'type' => 'radio', 'choices' => array( 'blog0' => __('Classic: One Column Posts + Sidebar', 'brilliant'), 'blog1' => __('Fashion: Two Column Posts + Sidebar', 'brilliant'), ), ) ); // Post Section $wp_customize->add_section( 'dl_post_section', array( 'title' => __( 'Post', 'brilliant' ), 'priority' => 25, 'panel' => 'dl_panel', ) ); // Feauted Image $wp_customize->add_setting( 'dl_post_featured_image', array( 'default' => 1, 'sanitize_callback' => 'dl_sanitize_checkbox', ) ); $wp_customize->add_control( 'dl_post_featured_image', array( 'label' => __( 'Show Featured Image', 'brilliant' ), 'section' => 'dl_post_section', 'settings' => 'dl_post_featured_image', 'type' => 'checkbox', ) ); // Featured Image Size $wp_customize->add_setting( 'dl_post_featured_image_size', array( 'default' => 'fullwidth', 'sanitize_callback' => 'dl_sanitize_choices', ) ); $wp_customize->add_control( 'dl_post_featured_image_size', array( 'description' => __( 'Featured Image Size', 'brilliant' ), 'section' => 'dl_post_section', 'settings' => 'dl_post_featured_image_size', 'type' => 'radio', 'choices' => array( 'onecolumn' => __('One Column Width', 'brilliant'), 'fullwidth' => __('Full Width (images must be at least 1160px)', 'brilliant'), ), 'active_callback' => 'post_has_featured_image', ) ); // Page Section $wp_customize->add_section( 'dl_page_section', array( 'title' => __( 'Page', 'brilliant' ), 'priority' => 30, 'panel' => 'dl_panel', ) ); // Feauted Image $wp_customize->add_setting( 'dl_page_featured_image', array( 'default' => 1, 'sanitize_callback' => 'dl_sanitize_checkbox', ) ); $wp_customize->add_control( 'dl_page_featured_image', array( 'label' => __( 'Show Featured Image', 'brilliant' ), 'section' => 'dl_page_section', 'settings' => 'dl_page_featured_image', 'type' => 'checkbox', ) ); // Featured Image Size $wp_customize->add_setting( 'dl_page_featured_image_size', array( 'default' => 'fullwidth', 'sanitize_callback' => 'dl_sanitize_choices', ) ); $wp_customize->add_control( 'dl_page_featured_image_size', array( 'description' => __( 'Featured Image Size', 'brilliant' ), 'section' => 'dl_page_section', 'settings' => 'dl_page_featured_image_size', 'type' => 'radio', 'choices' => array( 'onecolumn' => __('One Column Width', 'brilliant'), 'fullwidth' => __('Full Width (images must be at least 1160px)', 'brilliant'), ), 'active_callback' => 'page_has_featured_image', ) ); // Accent Color $wp_customize->add_setting( 'accent_color', array( 'default' => '#e52e7a', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'accent_color', array( 'label' => __( 'Accent Color', 'brilliant' ), 'section' => 'colors', 'settings' => 'accent_color', ) ) ); $wp_customize->add_setting( 'footer_bg', array( 'default' => '#1b2126', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'footer_bg', array( 'label' => __( 'Footer background', 'brilliant' ), 'section' => 'colors', 'settings' => 'footer_bg', ) ) ); } add_action('customize_register', 'brilliant_theme_customizer'); /** * Sanitize Checkbox * */ function dl_sanitize_checkbox( $input ) { if ( $input == 1 ) { return 1; } else { return ''; } } /** * Sanitize Radio Buttons and Select Lists * */ function dl_sanitize_choices( $input, $setting ) { global $wp_customize; $control = $wp_customize->get_control( $setting->id ); if ( array_key_exists( $input, $control->choices ) ) { return $input; } else { return $setting->default; } } /** * Sanitizes text: only safe HTML tags (the same tags that are allowed in a standard WordPress post) * */ function dl_sanitize_text( $input ) { return wp_kses_post( $input ); } /** * Sanitize Social Links * */ function social_links_sanitize( $input ) { return wp_filter_nohtml_kses( esc_url_raw( $input ) ); } /** * Sanitize Numbers * */ function dl_sanitize_integer( $input ) { return intval( $input ); } /** * Empty Sanitize * */ function empty_sanitize( $value ) { return $value; } /** * Checks if Single Post has featured image */ function post_has_featured_image( $control ) { if ( $control->manager->get_setting('dl_post_featured_image')->value() == 1 ) { return true; } else { return false; } } /** * Checks if Page has featured image */ function page_has_featured_image( $control ) { if ( $control->manager->get_setting('dl_page_featured_image')->value() == 1 ) { return true; } else { return false; } } /** * Get Contrast * */ function get_brightness($hex) { // returns brightness value from 0 to 255 // strip off any leading # $hex = str_replace('#', '', $hex); $c_r = hexdec(substr($hex, 0, 2)); $c_g = hexdec(substr($hex, 2, 2)); $c_b = hexdec(substr($hex, 4, 2)); return (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; } /** * Homepage Classes * */ function home_loop_classes() { $home_style = get_theme_mod('dl_home_style', 'home1'); switch ($home_style) { case "home1": $home_classes = 'flex-row home-style-1'; break; case "home2": $home_classes = 'home-style-2'; break; default: $home_classes = ''; } echo $home_classes; } /** * Blog Classes * */ function blog_loop_classes() { $blog_style = get_theme_mod('dl_blog_style', 'blog1'); switch ($blog_style) { case "blog1": $blog_classes = 'flex-row blog-style-1'; break; default: $blog_classes = ''; } echo $blog_classes; } /** * Add CSS in for styles handled by the theme customizer * */ function add_brilliant_styles() { $accent_color = get_option('accent_color'); $footer_bg = get_option('footer_bg'); ?>