/** * Enqueues front-end CSS for color scheme. * * @since Twenty Fifteen 1.0 * * @see wp_add_inline_style() */ function twentyfifteen_color_scheme_css() { $color_scheme_option = get_theme_mod('color_scheme', 'default'); // Don't do anything if the default color scheme is selected. if ('default' === $color_scheme_option) { return; } $color_scheme = twentyfifteen_get_color_scheme(); // Convert main and sidebar text hex color to rgba. $color_textcolor_rgb = twentyfifteen_hex2rgb($color_scheme[3]); $color_sidebar_textcolor_rgb = twentyfifteen_hex2rgb($color_scheme[4]); $colors = array('background_color' => $color_scheme[0], 'header_background_color' => $color_scheme[1], 'box_background_color' => $color_scheme[2], 'textcolor' => $color_scheme[3], 'secondary_textcolor' => vsprintf('rgba( %1$s, %2$s, %3$s, 0.7)', $color_textcolor_rgb), 'border_color' => vsprintf('rgba( %1$s, %2$s, %3$s, 0.1)', $color_textcolor_rgb), 'border_focus_color' => vsprintf('rgba( %1$s, %2$s, %3$s, 0.3)', $color_textcolor_rgb), 'sidebar_textcolor' => $color_scheme[4], 'sidebar_border_color' => vsprintf('rgba( %1$s, %2$s, %3$s, 0.1)', $color_sidebar_textcolor_rgb), 'sidebar_border_focus_color' => vsprintf('rgba( %1$s, %2$s, %3$s, 0.3)', $color_sidebar_textcolor_rgb), 'secondary_sidebar_textcolor' => vsprintf('rgba( %1$s, %2$s, %3$s, 0.7)', $color_sidebar_textcolor_rgb), 'meta_box_background_color' => $color_scheme[5]); $color_scheme_css = twentyfifteen_get_color_scheme_css($colors); wp_add_inline_style('twentyfifteen-style', $color_scheme_css); }
/** * Enqueues front-end CSS for the sidebar text color. * * @since Twenty Fifteen 1.0 */ function twentyfifteen_sidebar_text_color_css() { $color_scheme = twentyfifteen_get_color_scheme(); $default_color = $color_scheme[4]; $sidebar_link_color = get_theme_mod('sidebar_textcolor', $default_color); // Don't do anything if the current color is the default. if ($sidebar_link_color === $default_color) { return; } // If we get this far, we have custom styles. Let's do this. $sidebar_link_color_rgb = twentyfifteen_hex2rgb($sidebar_link_color); $sidebar_text_color = vsprintf('rgba( %1$s, %2$s, %3$s, 0.7)', $sidebar_link_color_rgb); $sidebar_border_color = vsprintf('rgba( %1$s, %2$s, %3$s, 0.1)', $sidebar_link_color_rgb); $sidebar_border_focus_color = vsprintf('rgba( %1$s, %2$s, %3$s, 0.3)', $sidebar_link_color_rgb); $css = ' /* Custom Sidebar Text Color */ .site-title a, .site-description, .secondary-toggle:before { color: %1$s; } .site-title a:hover, .site-title a:focus { color: %1$s; /* Fallback for IE7 and IE8 */ color: %2$s; } .secondary-toggle { border-color: %1$s; /* Fallback for IE7 and IE8 */ border-color: %3$s; } .secondary-toggle:hover, .secondary-toggle:focus { border-color: %1$s; /* Fallback for IE7 and IE8 */ border-color: %4$s; } .site-title a { outline-color: %1$s; /* Fallback for IE7 and IE8 */ outline-color: %4$s; } @media screen and (min-width: 59.6875em) { .secondary a, .dropdown-toggle:after, .widget-title, .widget blockquote cite, .widget blockquote small { color: %1$s; } .widget button, .widget input[type="button"], .widget input[type="reset"], .widget input[type="submit"], .widget_calendar tbody a { background-color: %1$s; } .textwidget a { border-color: %1$s; } .secondary a:hover, .secondary a:focus, .main-navigation .menu-item-description, .widget, .widget blockquote, .widget .wp-caption-text, .widget .gallery-caption { color: %2$s; } .widget button:hover, .widget button:focus, .widget input[type="button"]:hover, .widget input[type="button"]:focus, .widget input[type="reset"]:hover, .widget input[type="reset"]:focus, .widget input[type="submit"]:hover, .widget input[type="submit"]:focus, .widget_calendar tbody a:hover, .widget_calendar tbody a:focus { background-color: %2$s; } .widget blockquote { border-color: %2$s; } .main-navigation ul, .main-navigation li, .secondary-toggle, .widget input, .widget textarea, .widget table, .widget th, .widget td, .widget pre, .widget li, .widget_categories .children, .widget_nav_menu .sub-menu, .widget_pages .children, .widget abbr[title] { border-color: %3$s; } .dropdown-toggle:hover, .dropdown-toggle:focus, .widget hr { background-color: %3$s; } .widget input:focus, .widget textarea:focus { border-color: %4$s; } .sidebar a:focus, .dropdown-toggle:focus { outline-color: %4$s; } } '; wp_add_inline_style('twentyfifteen-style', sprintf($css, $sidebar_link_color, $sidebar_text_color, $sidebar_border_color, $sidebar_border_focus_color)); }
/** * Enqueues front-end CSS for color scheme. * * @since Twenty Fifteen 1.0 */ function twentyfifteen_color_scheme_css() { $color_scheme_option = get_theme_mod('color_scheme', 'default'); // Don't do anything if the default color scheme is selected. if ('default' === $color_scheme_option) { return; } // If we get this far, we have custom styles. Let's do this. $color_scheme = twentyfifteen_get_color_scheme(); // Convert main and sidebar text hex color to rgba. $color_main_text_rgb = twentyfifteen_hex2rgb($color_scheme[3]); $color_sidebar_link_rgb = twentyfifteen_hex2rgb($color_scheme[4]); $color_background = $color_scheme[0]; $color_sidebar_background = $color_scheme[1]; $color_box_background = $color_scheme[2]; $color_main_text = $color_scheme[3]; $color_secondary_text = vsprintf('rgba( %1$s, %2$s, %3$s, 0.7)', $color_main_text_rgb); $color_border = vsprintf('rgba( %1$s, %2$s, %3$s, 0.1)', $color_main_text_rgb); $color_border_focus = vsprintf('rgba( %1$s, %2$s, %3$s, 0.3)', $color_main_text_rgb); $color_sidebar_link = $color_scheme[4]; $color_sidebar_text = vsprintf('rgba( %1$s, %2$s, %3$s, 0.7)', $color_sidebar_link_rgb); $color_sidebar_border = vsprintf('rgba( %1$s, %2$s, %3$s, 0.1)', $color_sidebar_link_rgb); $color_sidebar_border_focus = vsprintf('rgba( %1$s, %2$s, %3$s, 0.3)', $color_sidebar_link_rgb); $color_meta_box = $color_scheme[5]; $css = ' /* Color Scheme */ /* Background Color */ body { background-color: %1$s; } /* Sidebar Background Color */ body:before, .site-header { background-color: %2$s; } /* Box Background Color */ .post-navigation, .pagination, .secondary, .site-footer, .hentry, .page-header, .page-content, .comments-area { background-color: %3$s; } /* Box Background Color */ button, input[type="button"], input[type="reset"], input[type="submit"], .pagination .prev, .pagination .next, .pagination .prev:before, .pagination .next:before, .entry-content .page-links a, .entry-content .page-links a:hover, .entry-content .page-links a:focus, .sticky-post { color: %3$s; } /* Main Text Color */ button, input[type="button"], input[type="reset"], input[type="submit"], .pagination .prev, .pagination .next, .page-links a, .sticky-post { background-color: %4$s; } /* Main Text Color */ body, blockquote cite, blockquote small, a, .image-navigation a:hover, .image-navigation a:focus, .comment-navigation a:hover, .comment-navigation a:focus, .entry-footer a:hover, .entry-footer a:focus, .comment-metadata a:hover, .comment-metadata a:focus, .pingback .edit-link a:hover, .pingback .edit-link a:focus, .comment-list .reply a:hover, .comment-list .reply a:focus, .site-info a:hover, .site-info a:focus { color: %4$s; } /* Main Text Color */ .entry-content a, .entry-summary a, .page-content a, .comment-content a, .author-description a, .comment-list .reply a:hover, .comment-list .reply a:focus { border-color: %4$s; } /* Secondary Text Color */ button:hover, button:focus, input[type="button"]:hover, input[type="button"]:focus, input[type="reset"]:hover, input[type="reset"]:focus, input[type="submit"]:hover, input[type="submit"]:focus, .pagination .prev:hover, .pagination .prev:focus, .pagination .next:hover, .pagination .next:focus, .page-links a:hover, .page-links a:focus { background-color: %4$s; /* Fallback for IE7 and IE8 */ background-color: %5$s; } /* Secondary Text Color */ blockquote, input[type="text"], input[type="email"], input[type="url"], input[type="password"], input[type="search"], textarea, a:hover, a:focus, .post-navigation .meta-nav, .post-navigation a:hover .post-title, .post-navigation a:focus .post-title, .image-navigation, .image-navigation a, .comment-navigation, .comment-navigation a, .author-heading, .entry-footer, .entry-footer a, .taxonomy-description, .page-links > .page-links-title, .entry-caption, .comment-author, .comment-metadata, .comment-metadata a, .pingback .comment-edit-link, .post-password-form label, .comment-form label, .comment-notes, .comment-awaiting-moderation, .logged-in-as, .form-allowed-tags, .no-comments, .site-info, .site-info a, .wp-caption-text, .gallery-caption, .comment-list .reply a { color: %4$s; /* Fallback for IE7 and IE8 */ color: %5$s; } /* Secondary Text Color */ blockquote, .entry-content a:hover, .entry-content a:focus, .entry-summary a:hover, .entry-summary a:focus, .page-content a:hover, .page-content a:focus, .comment-content a:hover, .comment-content a:focus, .author-description a:hover, .author-description a:focus { border-color: %4$s; /* Fallback for IE7 and IE8 */ border-color: %5$s; } /* Border Color */ hr { background-color: %4$s; /* Fallback for IE7 and IE8 */ background-color: %6$s; } /* Border Color */ pre, abbr[title], table, th, td, input, textarea, .post-navigation, .post-navigation .nav-previous:not(.has-post-thumbnail) + .nav-next:not(.has-post-thumbnail), .pagination, .comment-navigation, .site-header, .site-footer, .hentry + .hentry, .author-info, .entry-content .page-links a, .page-links > span, .page-header, .comments-area, .comment-list + .comment-respond, .comment-list article, .comment-list .pingback, .comment-list .trackback, .comment-list .reply a, .no-comments { border-color: %4$s; /* Fallback for IE7 and IE8 */ border-color: %6$s; } /* Border Focus Color */ input:focus, textarea:focus { border-color: %4$s; /* Fallback for IE7 and IE8 */ border-color: %7$s; } /* Sidebar Link Color */ .secondary-toggle:hover { border-color: %8$s; } .secondary-toggle:before { color: %8$s; } .secondary-toggle:focus { outline-color: %8$s; } .site-title a, .site-description { color: %8$s; } /* Sidebar Text Color */ .site-title a:hover, .site-title a:focus { color: %9$s; } /* Sidebar Border Color */ .secondary-toggle { border-color: %8$s; /* Fallback for IE7 and IE8 */ border-color: %10$s; } /* Meta Background Color */ .entry-footer { background-color: %12$s; } @media screen and (min-width: 38.75em) { /* Main Text Color */ .page-header { border-color: %4$s; } } @media screen and (min-width: 59.6875em) { /* Make sure its transparent on desktop */ .site-header, .secondary { background-color: transparent; } /* Sidebar Background Color */ .widget button, .widget input[type="button"], .widget input[type="reset"], .widget input[type="submit"], .widget_calendar tbody a, .widget_calendar tbody a:hover, .widget_calendar tbody a:focus, .widget mark, .widget ins { color: %2$s; } /* Sidebar Link Color */ .widget button, .widget input[type="button"], .widget input[type="reset"], .widget input[type="submit"], .widget_calendar tbody a, .widget mark, .widget ins { background-color: %8$s; } .secondary a, .dropdown-toggle:after, .widget-title, .widget blockquote cite, .widget blockquote small { color: %8$s; } .dropdown-toggle:focus { outline-color: %8$s; } /* Sidebar Text Color */ .secondary a:hover, .secondary a:focus, .widget, .main-navigation .menu-item-description, .widget blockquote, .widget .wp-caption-text, .widget .gallery-caption { color: %9$s; } .dropdown-toggle:hover, .dropdown-toggle:focus, .widget button:hover, .widget button:focus, .widget input[type="button"]:hover, .widget input[type="button"]:focus, .widget input[type="reset"]:hover, .widget input[type="reset"]:focus, .widget input[type="submit"]:hover, .widget input[type="submit"]:focus, .widget_calendar tbody a:hover, .widget_calendar tbody a:focus { background-color: %9$s; } .widget blockquote { border-color: %9$s; } /* Sidebar Border Color */ .main-navigation ul, .main-navigation li, .widget input, .widget textarea, .widget table, .widget th, .widget td, .widget input, .widget textarea, .widget pre, .widget li, .widget_categories .children, .widget_nav_menu .sub-menu, .widget_pages .children, .widget abbr[title] { border-color: %10$s; } .widget hr { background-color: %10$s; } /* Sidebar Border Focus Color */ .widget input:focus, .widget textarea:focus { border-color: %11$s; } } '; wp_add_inline_style('twentyfifteen-style', sprintf($css, $color_background, $color_sidebar_background, $color_box_background, $color_main_text, $color_secondary_text, $color_border, $color_border_focus, $color_sidebar_link, $color_sidebar_text, $color_sidebar_border, $color_sidebar_border_focus, $color_meta_box)); }