array( 'link' => esc_url('https://www.designlabthemes.com/brilliant-plus-wordpress-theme/?utm_source=wordpress&utm_campaign=brilliant&utm_content=customizer_link'), 'text' => __('Try Brilliant Plus', 'brilliant'), ), 'theme' => array( 'link' => esc_url('https://www.designlabthemes.com/brilliant-wordpress-theme/'), 'text' => __('Theme Homepage', 'brilliant'), ), 'documentation' => array( 'link' => esc_url('https://www.designlabthemes.com/brilliant-documentation/'), 'text' => __('Theme Documentation', 'brilliant'), ), 'rating' => array( 'link' => esc_url('https://wordpress.org/support/theme/brilliant/reviews/#new-post'), 'text' => __('Rate This Theme', 'brilliant'), ), 'twitter' => array( 'link' => esc_url('https://twitter.com/designlabthemes'), 'text' => __('Follow on Twitter', 'brilliant'), ) ); foreach ($important_links as $important_link) { echo '
'; } } } } /** * Theme Settings */ function brilliant_theme_customizer( $wp_customize ) { // Add postMessage support for site title and description for the Theme Customizer. $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; // Set to refresh the Background Color Setting $wp_customize->get_setting( 'background_color' )->transport = 'refresh'; // Brilliant Links $wp_customize->add_section('brilliant_links_section', array( 'priority' => 2, 'title' => __('Brilliant Links', 'brilliant'), ) ); $wp_customize->add_setting('brilliant_links', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize->add_control(new Brilliant_Important_Links($wp_customize, 'brilliant_links', array( 'section' => 'brilliant_links_section', ) ) ); // Theme Settings $wp_customize->add_panel( 'brilliant_panel', array( 'title' => __( 'Theme Settings', 'brilliant' ), 'priority' => 10, ) ); // General Section $wp_customize->add_section( 'general_section', array( 'title' => __( 'General', 'brilliant' ), 'priority' => 5, 'panel' => 'brilliant_panel', ) ); // Read More Link $wp_customize->add_setting( 'show_read_more', array( 'default' => 1, 'sanitize_callback' => 'brilliant_sanitize_checkbox', ) ); $wp_customize->add_control( 'show_read_more', array( 'label' => __( 'Display Read More Link', 'brilliant' ), 'section' => 'general_section', 'type' => 'checkbox', ) ); // Header Section $wp_customize->add_section( 'header_section', array( 'title' => __( 'Header', 'brilliant' ), 'priority' => 10, 'panel' => 'brilliant_panel', ) ); // Header Styles $wp_customize->add_setting( 'header_layout', array( 'default' => 'head-center1', 'sanitize_callback' => 'brilliant_sanitize_choices', ) ); $wp_customize->add_control( 'header_layout', array( 'label' => __( 'Styles', 'brilliant' ), 'section' => 'header_section', 'type' => 'radio', 'choices' => array( 'head-left1' => __('1: Site Title on the left and Navigation on the right', 'brilliant'), 'head-center1' => __('2: Site Title centered and Navigation below', 'brilliant'), ) ) ); // Blog Section $wp_customize->add_section( 'blog_section', array( 'title' => __( 'Blog', 'brilliant' ), 'priority' => 15, 'panel' => 'brilliant_panel', 'description' => __( 'Settings for Blog Posts Index Page.', 'brilliant' ), ) ); // Blog Layout $wp_customize->add_setting( 'blog_layout', array( 'default' => 'blog-layout4', 'sanitize_callback' => 'brilliant_sanitize_choices', ) ); $wp_customize->add_control( 'blog_layout', array( 'label' => __( 'Layout', 'brilliant' ), 'section' => 'blog_section', 'type' => 'radio', 'choices' => array( 'blog-layout1' => __('Classic: Large Posts + Sidebar', 'brilliant'), 'blog-layout2' => __('Grid: Two Columns + Sidebar', 'brilliant'), 'blog-layout3' => __('First Overlay Post then Large + Sidebar', 'brilliant'), 'blog-layout4' => __('First Overlay Post then Grid + Sidebar', 'brilliant'), ), ) ); // Blog Excerpt Length $wp_customize->add_setting( 'blog_excerpt_length', array( 'default' => 25, 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'blog_excerpt_length', array( 'label' => __( 'Excerpt length', 'brilliant' ), 'section' => 'blog_section', 'type' => 'number', ) ); // Archives Section $wp_customize->add_section( 'archive_section', array( 'title' => __( 'Categories & Archives', 'brilliant' ), 'priority' => 20, 'panel' => 'brilliant_panel', 'description' => __( 'Settings for Category, Tag, Search and Archive Pages.', 'brilliant' ), ) ); // Archives Layout $wp_customize->add_setting( 'archive_layout', array( 'default' => 'archive-layout2', 'sanitize_callback' => 'brilliant_sanitize_choices', ) ); $wp_customize->add_control( 'archive_layout', array( 'label' => __( 'Layout', 'brilliant' ), 'section' => 'archive_section', 'type' => 'radio', 'choices' => array( 'archive-layout1' => __('Classic: Large Posts + Sidebar', 'brilliant'), 'archive-layout2' => __('Grid: Two Columns + Sidebar', 'brilliant'), ), ) ); // Archives Excerpt Length $wp_customize->add_setting( 'archive_excerpt_length', array( 'default' => 25, 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'archive_excerpt_length', array( 'label' => __( 'Excerpt length', 'brilliant' ), 'section' => 'archive_section', 'type' => 'number', ) ); // Post Section $wp_customize->add_section( 'post_section', array( 'title' => __( 'Post', 'brilliant' ), 'priority' => 25, 'panel' => 'brilliant_panel', ) ); // Featured Image $wp_customize->add_setting( 'post_has_featured_image', array( 'default' => 1, 'sanitize_callback' => 'brilliant_sanitize_checkbox', ) ); $wp_customize->add_control( 'post_has_featured_image', array( 'label' => __( 'Display Featured Image', 'brilliant' ), 'section' => 'post_section', 'type' => 'checkbox', ) ); // Featured Image Style $wp_customize->add_setting( 'post_featured_image_size', array( 'default' => 'overlay', 'sanitize_callback' => 'brilliant_sanitize_choices', ) ); $wp_customize->add_control( 'post_featured_image_size', array( 'description' => __( 'Featured Image Style', 'brilliant' ), 'section' => 'post_section', 'type' => 'radio', 'choices' => array( 'onecolumn' => __('One Column', 'brilliant'), 'overlay' => __('Overlay (images must be at least 1160px)', 'brilliant'), ), 'active_callback' => 'brilliant_post_has_featured_image', ) ); // Author Bio $wp_customize->add_setting( 'show_author_bio', array( 'default' => '', 'sanitize_callback' => 'brilliant_sanitize_checkbox', ) ); $wp_customize->add_control( 'show_author_bio', array( 'label' => __( 'Display Author Bio', 'brilliant' ), 'section' => 'post_section', 'type' => 'checkbox', ) ); // Page Section $wp_customize->add_section( 'page_section', array( 'title' => __( 'Page', 'brilliant' ), 'priority' => 30, 'panel' => 'brilliant_panel', ) ); // Featured Image $wp_customize->add_setting( 'page_has_featured_image', array( 'default' => 1, 'sanitize_callback' => 'brilliant_sanitize_checkbox', ) ); $wp_customize->add_control( 'page_has_featured_image', array( 'label' => __( 'Display Featured Image', 'brilliant' ), 'section' => 'page_section', 'type' => 'checkbox', ) ); // Featured Image Style $wp_customize->add_setting( 'page_featured_image_size', array( 'default' => 'overlay', 'sanitize_callback' => 'brilliant_sanitize_choices', ) ); $wp_customize->add_control( 'page_featured_image_size', array( 'description' => __( 'Featured Image Style', 'brilliant' ), 'section' => 'page_section', 'type' => 'radio', 'choices' => array( 'onecolumn' => __('One Column', 'brilliant'), 'overlay' => __('Overlay (images must be at least 1160px)', 'brilliant'), ), 'active_callback' => 'brilliant_page_has_featured_image', ) ); // Logo Max Width (desktop) $wp_customize->add_setting( 'logo_width_lg', array( 'default' => 260, 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'logo_width_lg', array( 'label' => __( 'Logo Max Width (desktop)', 'brilliant' ), 'section' => 'title_tagline', 'type' => 'number', 'priority' => 9, ) ); // Logo Max Width (mobile) $wp_customize->add_setting( 'logo_width_sm', array( 'default' => 180, 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'logo_width_sm', array( 'label' => __( 'Logo Max Width (mobile)', 'brilliant' ), 'section' => 'title_tagline', 'type' => 'number', 'priority' => 9, ) ); // Accent Color $wp_customize->add_setting( 'accent_color', array( 'default' => '#e63855', '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', ) ) ); // Site Title Color $wp_customize->add_setting( 'site_title_color', array( 'default' => '#000000', 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'site_title_color', array( 'label' => __( 'Site Title', 'brilliant' ), 'section' => 'colors', ) ) ); // Site Tagline Color $wp_customize->add_setting( 'site_tagline_color', array( 'default' => '#666666', 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'site_tagline_color', array( 'label' => __( 'Site Tagline', 'brilliant' ), 'section' => 'colors', ) ) ); // Footer Background $wp_customize->add_setting( 'footer_bg', array( 'default' => '#1b2126', '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', ) ) ); } add_action('customize_register', 'brilliant_theme_customizer'); /** * Sanitize Checkbox * */ function brilliant_sanitize_checkbox( $input ) { if ( $input == 1 ) { return 1; } else { return ''; } } /** * Sanitize Radio Buttons and Select Lists * */ function brilliant_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; } } /** * Checks if Single Post has featured image. */ function brilliant_post_has_featured_image( $control ) { if ( $control->manager->get_setting('post_has_featured_image')->value() == 1 ) { return true; } else { return false; } } /** * Checks if Page has featured image. */ function brilliant_page_has_featured_image( $control ) { if ( $control->manager->get_setting('page_has_featured_image')->value() == 1 ) { return true; } else { return false; } } /** * Get Contrast * */ function brilliant_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; } /** * Add inline CSS for styles handled by the Theme customizer * */ function brilliant_add_styles() { $logo_w_desktop = esc_attr( get_theme_mod('logo_width_lg', 260) ); $logo_w_mobile = esc_attr( get_theme_mod('logo_width_sm', 180) ); $accent_color = esc_attr( get_theme_mod('accent_color') ); $site_title_color = esc_attr( get_theme_mod('site_title_color') ); $site_tagline_color = esc_attr( get_theme_mod('site_tagline_color') ); $footer_bg = esc_attr( get_theme_mod('footer_bg') ); $custom_styles = ""; // Logo Size if ( $logo_w_mobile != '' ) { $custom_styles .= " @media screen and (max-width: 480px) { .custom-logo {max-width: {$logo_w_mobile}px;} }"; } if ( $logo_w_desktop != '' ) { $custom_styles .= " @media screen and (min-width: 481px) { .custom-logo {max-width: {$logo_w_desktop}px;} }"; } // Accent Color if ( $accent_color != '' ) { $custom_styles .= " a, a:hover, .site-info a:hover, .widget a:hover, .comment-metadata a:hover, .site-title a:hover, .entry-title a:hover, .posts-navigation a:hover, .cover .read-more, .large-post .read-more, .main-navigation ul li:hover > a, .main-navigation ul li:focus > a, .main-navigation .woo-cart-link a:hover, .main-navigation > ul > li.current_page_item > a, .main-navigation > ul > li.current-menu-item > a, .dropdown-toggle:hover, .dropdown-toggle:focus { color: {$accent_color}; } button, input[type='button'], input[type='reset'], input[type='submit'], .cover .read-more:hover, .large-post .read-more:hover, .sidebar .widget_tag_cloud a:hover, .reply a:hover { background-color: {$accent_color}; } .cover .read-more, .large-post .read-more, .reply a { border-color: {$accent_color}; } .format-audio .entry-thumbnail:after, .format-gallery .entry-thumbnail:after, .format-image .entry-thumbnail:after, .format-quote .entry-thumbnail:after, .format-video .entry-thumbnail:after { border-top-color: {$accent_color}; }"; if ( brilliant_get_brightness($accent_color) > 155) { $custom_styles .= " button, input[type='button'], input[type='reset'], input[type='submit'], .cover .read-more:hover, .large-post .read-more:hover, .sidebar .widget_tag_cloud a:hover, .reply a:hover, .format-audio .entry-thumbnail:before, .format-gallery .entry-thumbnail:before, .format-image .entry-thumbnail:before, .format-quote .entry-thumbnail:before, .format-video .entry-thumbnail:before { color: rgba(0,0,0,.7); }"; } } // Site Title Color if ( $site_title_color != '' ) { $custom_styles .= " .site-title a, .site-title a:hover {color: {$site_title_color};} .site-title a:hover {opacity: .7;} "; } // Site Tagline Color if ( $site_tagline_color != '' ) { $custom_styles .= ".site-description {color: {$site_tagline_color};}"; } // Footer Background if ( $footer_bg != '' ) { $custom_styles .= " .site-footer {background-color: {$footer_bg};}"; if ( brilliant_get_brightness($footer_bg) > 155) { $custom_styles .= " .site-footer { border-top: 1px solid rgba(0,0,0,.08); } .site-info, .site-credits, .site-footer .widget-area { color: rgba(0,0,0,.7); } .site-info a, .site-footer .site-info a:hover, .site-footer .widget-title, .site-footer .widget a, .site-footer .widget a:hover { color: rgba(0,0,0,.8); } .site-footer .widget-area ul li { border-bottom-color: rgba(0,0,0,.05); } .site-footer .widget_tag_cloud a { border-color: rgba(0,0,0,.05); background-color: rgba(0,0,0,.05); }"; } } // Add Custom Styles if Body Background is white $background_color = get_background_color(); if ( $background_color == 'ffffff' ) { $custom_styles .= " .hentry, .no-results, .widget, .related-posts, .posts-navigation, .post-navigation, .comments-area, .author-info { box-shadow: none; } .posts-loop .entry-header, .posts-loop .entry-summary, .posts-loop .entry-footer, .entry-header, .entry-content, .entry-footer, .author-info, .comments-area { padding-left: 0;padding-right: 0; } .sidebar .widget {padding: 0;} @media screen and (min-width: 600px) { .list-post {padding: 0;margin-bottom: 30px;} }"; } if ( $custom_styles != '' ) { wp_add_inline_style( 'brilliant-style', $custom_styles ); } } add_action( 'wp_enqueue_scripts', 'brilliant_add_styles' );