add( array( 'selectors' => array( 'body' ), 'declarations' => array( 'background-size' => $site_background_size ) ) ); } /** * Colors section */ // Get and escape options $color_primary = maybe_hash_hex_color( get_theme_mod( 'color-primary', bgbn_get_default( 'color-primary' ) ) ); $color_secondary = maybe_hash_hex_color( get_theme_mod( 'color-secondary', bgbn_get_default( 'color-secondary' ) ) ); $color_text = maybe_hash_hex_color( get_theme_mod( 'color-text', bgbn_get_default( 'color-text' ) ) ); $color_detail = maybe_hash_hex_color( get_theme_mod( 'color-detail', bgbn_get_default( 'color-detail' ) ) ); // Primary color if ( $color_primary !== bgbn_get_default( 'color-primary' ) ) { bgbn_get_css()->add( array( 'selectors' => array( '.color-primary-text', 'a', '.entry-author-byline a.vcard', '.entry-footer a:hover', '.comment-form .required', 'ul.bgbn-list-dot li:before', 'ol.bgbn-list-dot li:before' ), 'declarations' => array( 'color' => $color_primary ) ) ); bgbn_get_css()->add( array( 'selectors' => array( '.color-primary-background','.bgbn-button.color-primary-background' ), 'declarations' => array( 'background-color' => $color_primary ) ) ); bgbn_get_css()->add( array( 'selectors' => array( '.color-primary-border' ), 'declarations' => array( 'border-color' => $color_primary ) ) ); bgbn_get_css()->add( array( 'selectors' => array( '.site-navigation ul.menu ul a:hover', '.site-navigation ul.menu ul a:focus', '.site-navigation .menu ul ul a:hover', '.site-navigation .menu ul ul a:focus' ), 'declarations' => array( 'background-color' => $color_primary ), 'media' => 'screen and (min-width: 800px)' ) ); } // Secondary color if ( $color_secondary !== bgbn_get_default( 'color-secondary' ) ) { bgbn_get_css()->add( array( 'selectors' => array( '.color-secondary-text', '.builder-section-banner .cycle-pager', '.bgbn-shortcode-slider .cycle-pager', '.builder-section-banner .cycle-prev:before', '.builder-section-banner .cycle-next:before', '.bgbn-shortcode-slider .cycle-prev:before', '.bgbn-shortcode-slider .cycle-next:before', '.bgbn-shortcode-slider .cycle-caption', ), 'declarations' => array( 'color' => $color_secondary ) ) ); bgbn_get_css()->add( array( 'selectors' => array( '.color-secondary-background', 'blockquote.bgbn-testimonial', 'tt', 'kbd', 'pre', 'code', 'samp', 'var', 'textarea', 'input[type="date"]', 'input[type="datetime"]', 'input[type="datetime-local"]', 'input[type="email"]', 'input[type="month"]', 'input[type="number"]', 'input[type="password"]', 'input[type="search"]', 'input[type="tel"]', 'input[type="text"]', 'input[type="time"]', 'input[type="url"]', 'input[type="week"]', '.bgbn-button.color-secondary-background', 'button.color-secondary-background', 'input[type="button"].color-secondary-background', 'input[type="reset"].color-secondary-background', 'input[type="submit"].color-secondary-background', '.sticky-post-label', '.widget_tag_cloud a', ), 'declarations' => array( 'background-color' => $color_secondary ) ) ); bgbn_get_css()->add( array( 'selectors' => array( '.site-navigation .menu .sub-menu', '.site-navigation .menu .children', ), 'declarations' => array( 'background-color' => $color_secondary ), 'media' => 'screen and (min-width: 800px)' ) ); bgbn_get_css()->add( array( 'selectors' => array( '.color-secondary-border', 'table', 'table th', 'table td', '.header-layout-3 .site-navigation .menu', ), 'declarations' => array( 'border-color' => $color_secondary ) ) ); bgbn_get_css()->add( array( 'selectors' => array( 'hr', 'hr.bgbn-line-dashed', 'hr.bgbn-line-double', 'blockquote.bgbn-testimonial:after', ), 'declarations' => array( 'border-top-color' => $color_secondary ) ) ); bgbn_get_css()->add( array( 'selectors' => array( '.comment-body', '.post', '.widget li', ), 'declarations' => array( 'border-bottom-color' => $color_secondary ) ) ); } // Text color if ( $color_text !== bgbn_get_default( 'color-text' ) ) { bgbn_get_css()->add( array( 'selectors' => array( '.color-text', 'body', '.entry-date a', 'body', 'button', 'input', 'select', 'textarea', '[class*="navigation"] .nav-previous a', '[class*="navigation"] .nav-previous span', '[class*="navigation"] .nav-next a', '[class*="navigation"] .nav-next span' ), 'declarations' => array( 'color' => $color_text ) ) ); } // Detail color if ( $color_detail !== bgbn_get_default( 'color-detail' ) ) { bgbn_get_css()->add( array( 'selectors' => array( '.color-detail-text', '.builder-section-banner .cycle-pager .cycle-pager-active', '.bgbn-shortcode-slider .cycle-pager .cycle-pager-active', '.post-categories li:after', '.post-tags li:after' ), 'declarations' => array( 'color' => $color_detail ) ) ); bgbn_get_css()->add( array( 'selectors' => array( '.site-navigation .menu-item-has-children a:after' ), 'declarations' => array( 'color' => $color_detail ), 'media' => 'screen and (min-width: 800px)' ) ); bgbn_get_css()->add( array( 'selectors' => array( '.site-navigation .menu .sub-menu a', '.site-navigation .menu .sub-menu a' ), 'declarations' => array( 'border-bottom-color' => $color_detail ), 'media' => 'screen and (min-width: 800px)' ) ); bgbn_get_css()->add( array( 'selectors' => array( '.color-detail-background' ), 'declarations' => array( 'background-color' => $color_detail ) ) ); bgbn_get_css()->add( array( 'selectors' => array( '.color-detail-border' ), 'declarations' => array( 'border-color' => $color_detail ) ) ); } /** * Header section */ // Get and escape options $header_text_color = maybe_hash_hex_color( get_theme_mod( 'header-text-color', bgbn_get_default( 'header-text-color' ) ) ); $header_background_color = maybe_hash_hex_color( get_theme_mod( 'header-background-color', bgbn_get_default( 'header-background-color' ) ) ); $header_background_image = get_theme_mod( 'header-background-image', bgbn_get_default( 'header-background-image' ) ); $header_bar_text_color = maybe_hash_hex_color( get_theme_mod( 'header-bar-text-color', bgbn_get_default( 'header-bar-text-color' ) ) ); $header_bar_border_color = maybe_hash_hex_color( get_theme_mod( 'header-bar-border-color', bgbn_get_default( 'header-bar-border-color' ) ) ); $header_bar_background_color = maybe_hash_hex_color( get_theme_mod( 'header-bar-background-color', bgbn_get_default( 'header-bar-background-color' ) ) ); // Header text color if ( $header_text_color !== bgbn_get_default( 'header-text-color' ) ) { bgbn_get_css()->add( array( 'selectors' => array( '.site-header', '.site-header a', '.site-navigation .menu li a' ), 'declarations' => array( 'color' => $header_text_color ) ) ); } // Header background color if ( $header_background_color !== bgbn_get_default( 'header-background-color' ) ) { bgbn_get_css()->add( array( 'selectors' => array( '.site-header-main' ), 'declarations' => array( 'background-color' => $header_background_color ) ) ); } // Header background image if ( ! empty( $header_background_image ) ) { // Escape the background image URL properly $header_background_image = addcslashes( esc_url_raw( $header_background_image ), '"' ); // Get and escape related options $header_background_size = bgbn_sanitize_choice( get_theme_mod( 'header-background-size', bgbn_get_default( 'header-background-size' ) ), 'header-background-size' ); $header_background_repeat = bgbn_sanitize_choice( get_theme_mod( 'header-background-repeat', bgbn_get_default( 'header-background-repeat' ) ), 'header-background-repeat' ); $header_background_position = bgbn_sanitize_choice( get_theme_mod( 'header-background-position', bgbn_get_default( 'header-background-position' ) ), 'header-background-position' ); // All variables are escaped at this point bgbn_get_css()->add( array( 'selectors' => array( '.site-header-main' ), 'declarations' => array( 'background-image' => 'url("' . $header_background_image . '")', 'background-size' => $header_background_size, 'background-repeat' => $header_background_repeat, 'background-position' => $header_background_position . ' center' ) ) ); } // Header Bar text color if ( $header_bar_text_color !== bgbn_get_default( 'header-bar-text-color' ) ) { bgbn_get_css()->add( array( 'selectors' => array( '.header-bar' ), 'declarations' => array( 'color' => $header_bar_text_color ) ) ); } // Header Bar border color if ( $header_bar_border_color !== bgbn_get_default( 'header-bar-border-color' ) ) { bgbn_get_css()->add( array( 'selectors' => array( '.header-bar', '.header-bar .search-form input', '.header-social-links li:first-of-type', '.header-social-links li a' ), 'declarations' => array( 'border-color' => $header_bar_border_color ) ) ); } // Header Bar background color if ( $header_bar_background_color !== bgbn_get_default( 'header-bar-background-color' ) ) { bgbn_get_css()->add( array( 'selectors' => array( '.header-bar' ), 'declarations' => array( 'background-color' => $header_bar_background_color ) ) ); } /** * Site Title & Tagline section */ $color_site_title = maybe_hash_hex_color( get_theme_mod( 'color-site-title', bgbn_get_default( 'color-site-title' ) ) ); if ( $color_site_title !== bgbn_get_default( 'color-site-title' ) || $header_text_color !== $color_site_title ) { bgbn_get_css()->add( array( 'selectors' => array( '.site-header .site-title', '.site-header .site-title a' ), 'declarations' => array( 'color' => $color_site_title ) ) ); } /** * Main section */ // Get and escape options $main_background_color = maybe_hash_hex_color( get_theme_mod( 'main-background-color', bgbn_get_default( 'main-background-color' ) ) ); $main_background_image = get_theme_mod( 'main-background-image', bgbn_get_default( 'main-background-image' ) ); $main_content_link_underline = absint( get_theme_mod( 'main-content-link-underline', bgbn_get_default( 'main-content-link-underline' ) ) ); // Main background color if ( $main_background_color !== bgbn_get_default( 'main-background-color' ) ) { bgbn_get_css()->add( array( 'selectors' => array( '.site-content' ), 'declarations' => array( 'background-color' => $main_background_color ) ) ); } // Main background image if ( ! empty( $main_background_image ) ) { // Escape the background image URL properly $main_background_image = addcslashes( esc_url_raw( $main_background_image ), '"' ); // Get and escape related options $main_background_size = bgbn_sanitize_choice( get_theme_mod( 'main-background-size', bgbn_get_default( 'main-background-size' ) ), 'main-background-size' ); $main_background_repeat = bgbn_sanitize_choice( get_theme_mod( 'main-background-repeat', bgbn_get_default( 'main-background-repeat' ) ), 'main-background-repeat' ); $main_background_position = bgbn_sanitize_choice( get_theme_mod( 'main-background-position', bgbn_get_default( 'main-background-position' ) ), 'main-background-position' ); // All variables are escaped at this point bgbn_get_css()->add( array( 'selectors' => array( '.site-content' ), 'declarations' => array( 'background-image' => 'url("' . $main_background_image . '")', 'background-size' => $main_background_size, 'background-repeat' => $main_background_repeat, 'background-position' => $main_background_position . ' top' ) ) ); } // Main Content Link Underline if ( 1 === $main_content_link_underline ) { bgbn_get_css()->add( array( 'selectors' => array( '.entry-content a' ), 'declarations' => array( 'text-decoration' => 'underline' ) ) ); } /** * Footer section */ // Get and escape options $footer_text_color = maybe_hash_hex_color( get_theme_mod( 'footer-text-color', bgbn_get_default( 'footer-text-color' ) ) ); $footer_border_color = maybe_hash_hex_color( get_theme_mod( 'footer-border-color', bgbn_get_default( 'footer-border-color' ) ) ); $footer_background_color = maybe_hash_hex_color( get_theme_mod( 'footer-background-color', bgbn_get_default( 'footer-background-color' ) ) ); $footer_background_image = get_theme_mod( 'footer-background-image', bgbn_get_default( 'footer-background-image' ) ); // Footer text color if ( $footer_text_color !== bgbn_get_default( 'footer-text-color' ) ) { bgbn_get_css()->add( array( 'selectors' => array( '.site-footer' ), 'declarations' => array( 'color' => $footer_text_color ) ) ); } // Footer border color if ( $footer_border_color !== bgbn_get_default( 'footer-border-color' ) ) { bgbn_get_css()->add( array( 'selectors' => array( '.site-footer *:not(select)' ), 'declarations' => array( 'border-color' => $footer_border_color . ' !important' ) ) ); } // Footer background color if ( $footer_background_color !== bgbn_get_default( 'footer-background-color' ) ) { bgbn_get_css()->add( array( 'selectors' => array( '.site-footer' ), 'declarations' => array( 'background-color' => $footer_background_color ) ) ); } // Footer background image if ( ! empty( $footer_background_image ) ) { // Escape the background image URL properly $footer_background_image = addcslashes( esc_url_raw( $footer_background_image ), '"' ); // Get and escape related options $footer_background_size = bgbn_sanitize_choice( get_theme_mod( 'footer-background-size', bgbn_get_default( 'footer-background-size' ) ), 'footer-background-size' ); $footer_background_repeat = bgbn_sanitize_choice( get_theme_mod( 'footer-background-repeat', bgbn_get_default( 'footer-background-repeat' ) ), 'footer-background-repeat' ); $footer_background_position = bgbn_sanitize_choice( get_theme_mod( 'footer-background-position', bgbn_get_default( 'footer-background-position' ) ), 'footer-background-position' ); // All variables are escaped at this point bgbn_get_css()->add( array( 'selectors' => array( '.site-footer' ), 'declarations' => array( 'background-image' => 'url("' . $footer_background_image . '")', 'background-size' => $footer_background_size, 'background-repeat' => $footer_background_repeat, 'background-position' => $footer_background_position . ' center' ) ) ); } } endif; add_action( 'bgbn_css', 'bgbn_css_add_rules' );