/** * Custom CSS built from user theme options * For proper sanitization, always use functions from hoot/functions/css-styles.php * * @since 1.0 * @access public */ function hoot_custom_css() { $css = ''; $accent_color = hoot_get_option('accent_color'); $accent_color_dark = hoot_color_decrease($accent_color, 20, 20); $accent_font = hoot_get_option('accent_font'); $cssrules = array(); // Hoot Grid $cssrules['.grid'] = hoot_css_grid_width(); // Base Typography and HTML $cssrules['a'] = hoot_css_rule('color', $accent_color); // Overridden by hoot_premium_custom_cssrules() $cssrules['.invert-typo'] = array(hoot_css_rule('background', $accent_color), hoot_css_rule('color', $accent_font)); $cssrules['.invert-typo a, .invert-typo a:hover, .invert-typo h1, .invert-typo h2, .invert-typo h3, .invert-typo h4, .invert-typo h5, .invert-typo h6, .invert-typo .title'] = hoot_css_rule('color', $accent_font); $cssrules['input[type="submit"], #submit, .button'] = array(hoot_css_rule('background', $accent_color), hoot_css_rule('color', $accent_font)); $cssrules['input[type="submit"]:hover, #submit:hover, .button:hover'] = array(hoot_css_rule('background', $accent_color_dark), hoot_css_rule('color', $accent_font)); // Layout $content_bg = hoot_get_option('background'); $cssrules['body'][] = hoot_css_background($content_bg); if (hoot_get_option('site_layout') == 'boxed') { $content_bg = hoot_get_option('box_background'); $cssrules['#page-wrapper'][] = hoot_css_background($content_bg); } $cssrules['#page-wrapper'][] = hoot_css_rule('border-color', $accent_color); // Header $cssrules['#topbar-right-inner' . ', ' . '#topbar-right-inner input'] = hoot_css_rule('background', $content_bg['color']); // Shortcodes $cssrules['#page-wrapper ul.shortcode-tabset-nav li.current'] = hoot_css_rule('border-bottom-color', $content_bg['color']); // Light Slider $cssrules['.lSSlideOuter .lSPager.lSpg > li:hover a, .lSSlideOuter .lSPager.lSpg > li.active a'] = hoot_css_rule('background-color', $accent_color); // Allow CSS to be modified $cssrules = apply_filters('hoot_dynamic_cssrules', $cssrules); /** Print CSS Rules **/ foreach ($cssrules as $selector => $rules) { if (!empty($selector)) { $css .= $selector . ' {'; if (is_array($rules)) { foreach ($rules as $rule) { $css .= $rule . ' '; } } else { $css .= $rules; } $css .= ' }' . "\n"; } } // @todo add media queries to preceding code // Allow CSS to be modified $cssrules = apply_filters('hoot_dynamic_css', $css); // Print CSS if (!empty($css)) { wp_add_inline_style('style', $css); } }
</div> </div><?php } } ?> </div> <!-- <ul class="slick <?php echo $class; ?> "<?php echo $atts; ?> ><?php foreach ($hoot_theme->slider as $slide) { if (!empty($slide['image']) || !empty($slide['content'])) { $slide_bg = hoot_css_background($slide['background']); $is_custom_bg = isset($slide['background']['type']) && 'custom' == $slide['background']['type'] ? ' is-custom-bg ' : ''; $column = !empty($slide['image']) && !empty($slide['content']) ? ' column-1-2 ' : ' column-1-1 '; $slide['button'] = empty($slide['button']) ? __('Know More', 'responsive-brix') : $slide['button']; ?> <li class="slick hootslider-html-slide hootslider-html-slide-<?php echo $slide_count; $slide_count++; ?> <?php echo $is_custom_bg; ?> " style="<?php echo esc_attr($slide_bg); ?> ">
/** * Custom CSS built from user theme options * For proper sanitization, always use functions from hoot/functions/css-styles.php * * @since 1.0 * @access public */ function hoot_custom_css() { $css = ''; $vars = array(); $accent_color = hoot_get_option('accent_color'); $accent_color_dark = hoot_color_increase($accent_color, 10, 10); $accent_font = hoot_get_option('accent_font'); $cssrules = array(); // Hoot Grid $cssrules['.grid'] = hoot_css_grid_width(); // Base Typography and HTML $cssrules['a'] = hoot_css_rule('color', $accent_color); // Overridden by hoot_premium_custom_cssrules() $cssrules['.invert-typo'] = array(hoot_css_rule('background', $accent_color), hoot_css_rule('color', $accent_font)); $cssrules['.invert-typo a, .invert-typo a:hover, .invert-typo h1, .invert-typo h2, .invert-typo h3, .invert-typo h4, .invert-typo h5, .invert-typo h6, .invert-typo .title'] = hoot_css_rule('color', $accent_font); $cssrules['input[type="submit"], #submit, .button'] = array(hoot_css_rule('background', $accent_color), hoot_css_rule('color', $accent_font)); $cssrules['input[type="submit"]:hover, #submit:hover, .button:hover'] = array(hoot_css_rule('background', $accent_color_dark), hoot_css_rule('color', $accent_font)); // Override @headingsFontFamily if selected in options if ('cursive' != hoot_get_option('headings_fontface')) { $cssrules['h1, h2, h3, h4, h5, h6, .title, .titlefont'] = array(hoot_css_rule('font-family', '"Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif'), hoot_css_rule('font-weight', '300'), hoot_css_rule('color', '#000000')); } // Layout $content_bg = hoot_get_option('background'); $cssrules['body'][] = hoot_css_background($content_bg); if (hoot_get_option('site_layout') == 'boxed') { $content_bg = array('color' => hoot_get_option('box_background_color')); $cssrules['#page-wrapper'][] = hoot_css_background($content_bg); } $vars['content_bg'] = $content_bg; // Header (Topbar, Header, Main Nav Menu) // Topbar $cssrules['.topbar-right-inner input'] = hoot_css_rule('background', $content_bg['color']); // Header Layout if (hoot_get_option('logo_background_type') == 'accent') { $cssrules['#header:before'] = hoot_css_rule('background', $accent_color); } else { $cssrules['#header:before, #site-logo'] = hoot_css_rule('background', 'transparent'); $cssrules['#header, #branding, #header-aside'] = hoot_css_rule('background', 'none'); $cssrules['#site-logo #site-title, #site-logo #site-description'] = hoot_css_rule('color', $accent_color); } // Logo (with icon) $title_icon_size = hoot_get_option('site_title_icon_size', NULL); if (intval($title_icon_size)) { $cssrules['.site-logo-with-icon #site-title i'] = hoot_css_rule('font-size', $title_icon_size); } $title_icon = hoot_get_option('site_title_icon', NULL); if ($title_icon && intval($title_icon_size)) { $cssrules['.site-logo-with-icon #site-title'] = hoot_css_rule('padding-left', $title_icon_size); } // Mixed Logo (with image) $logo_image_width = hoot_get_option('logo_image_width', NULL); $logo_image_width = intval($logo_image_width) ? intval($logo_image_width) : 120; $cssrules['.site-logo-with-image .site-logo-mixed-image, .site-logo-with-image .site-logo-mixed-image img'] = hoot_css_rule('width', intval($logo_image_width) . 'px'); // Important to have logo img width as img does not follow max-width inside non-fixed tables in Firefox // Custom Logo $hoot_logo = hoot_get_option('logo'); if ('custom' == $hoot_logo || 'mixedcustom' == $hoot_logo) { $title_custom = apply_filters('hoot_logo_custom_text', hoot_get_option('logo_custom')); if (is_array($title_custom) && !empty($title_custom)) { $lcount = 1; foreach ($title_custom as $title_line) { if (!empty($title_line['size'])) { $cssrules['#site-logo-custom .site-title-line' . $lcount . ',#site-logo-mixedcustom .site-title-line' . $lcount] = hoot_css_rule('font-size', $title_line['size']); } $lcount++; } } } // Light Slider $cssrules['.lSSlideOuter .lSPager.lSpg > li:hover a, .lSSlideOuter .lSPager.lSpg > li.active a'] = hoot_css_rule('background-color', $accent_color); // Allow CSS to be modified $cssrules = apply_filters('hoot_dynamic_cssrules', $cssrules, $vars); /** Print CSS Rules **/ foreach ($cssrules as $selector => $rules) { if (!empty($selector)) { $css .= $selector . ' {'; if (is_array($rules)) { foreach ($rules as $rule) { $css .= $rule . ' '; } } else { $css .= $rules; } $css .= ' }' . "\n"; } } // @todo add media queries to preceding code // Allow CSS to be modified $cssrules = apply_filters('hoot_dynamic_css', $css, $vars); // Print CSS if (!empty($css)) { wp_add_inline_style('style', $css); } }
/** * Create general CSS style * * @since 1.0.0 * @access public * @param string $style name of the css property * @param string $value value of the css property * @param bool $echo * @param bool $important * @return void|string */ function hoot_css_rule($style, $value, $echo = false, $important = false) { if (empty($style) || empty($value)) { return ''; } $important = $important ? ' !important' : ''; // Load Sanitization functions if not loaded already (for frontend) if (!function_exists('hoot_of_sanitize_enum')) { require trailingslashit(HOOTOPTIONS_DIR) . 'includes/sanitization.php'; } // Sanitize CSS values // @todo box-shadow -moz-box-shadow -webkit-box-shadow switch ($style) { case 'color': case 'background-color': case 'border-color': case 'border-right-color': case 'border-bottom-color': case 'border-top-color': case 'border-left-color': if ('none' == $value || 'transparent' == $value) { $value = 'transparent'; } else { // sanitize color. hoot_of_sanitize_hex() will return null if $value is not a formatted hex color $value = hoot_of_sanitize_hex($value); } break; case 'background': if (is_array($value)) { // use the hoot_css_background function for multiple background properties hoot_css_background($value); return; } elseif ('none' == $value || 'transparent' == $value) { $value = 'none'; } else { // sanitize for background color. hoot_of_sanitize_hex() will return null if $value is not a formatted hex color $value = hoot_of_sanitize_hex($value); } break; case 'background-image': $value = 'url("' . esc_url($value) . '")'; break; case 'background-repeat': $recognized = hoot_of_recognized_background_repeat(); $value = array_key_exists($value, $recognized) ? $value : ''; break; case 'background-position': $recognized = hoot_of_recognized_background_position(); $value = array_key_exists($value, $recognized) ? $value : ''; break; case 'background-attachment': $recognized = hoot_of_recognized_background_attachment(); $value = array_key_exists($value, $recognized) ? $value : ''; break; case 'font': if (is_array($value)) { // use the hoot_css_typography function for multiple font properties hoot_css_typography($value); return; } else { // Recognized font-families in hoot/options/includes/fonts{-google}.php $recognized = hoot_of_recognized_font_faces(); $value = stripslashes($value); $value = array_key_exists($value, $recognized) ? $value : ''; } break; case 'font-family': // Recognized font-families in hoot/options/includes/fonts{-google}.php $recognized = hoot_of_recognized_font_faces(); $value = stripslashes($value); $value = array_key_exists($value, $recognized) ? $value : ''; break; case 'font-style': $recognized = array('inherit', 'initial', 'italic', 'normal', 'oblique'); $value = in_array($value, $recognized) ? $value : ''; break; case 'font-weight': $value_check = intval($value); if (!empty($value_check)) { // for numerical weights like 300, 600 etc. $value = $value_check; } else { // for strings like 'bold', 'light', 'lighter' etc. $recognized = array('bold', 'bolder', 'inherit', 'initial', 'lighter', 'normal'); $value = in_array($value, $recognized) ? $value : ''; } break; case 'text-decoration': $recognized = array('blink', 'inherit', 'initial', 'line-through', 'overline', 'underline'); $value = in_array($value, $recognized) ? $value : ''; break; case 'text-transform': $recognized = array('capitalize', 'inherit', 'initial', 'lowercase', 'none', 'uppercase'); $value = in_array($value, $recognized) ? $value : ''; break; case 'font-size': case 'padding': case 'padding-right': case 'padding-bottom': case 'padding-left': case 'padding-top': case 'margin': case 'margin-right': case 'margin-bottom': case 'margin-left': case 'margin-top': $value_check = preg_replace('/px|em|rem/', '', $value); $value_check = intval($value_check); $value = !empty($value_check) || '0' === $value_check || 0 === $value_check ? $value : ''; break; case 'opacity': $value_check = intval($value); $value = !empty($value_check) || '0' === $value_check || 0 === $value_check ? $value : ''; break; } // Return if $value is empty (failed sanitization checks) if (empty($value)) { return ''; } $output = " {$style}: {$value}{$important}; "; if (true === $echo || 'true' === $echo) { echo $output; } else { return $output; } }