/**
 * Outputs Custom CSS for the page title
 *
 * @since 1.5.3
 */
function wpex_page_header_css($output)
{
    // Get global object
    $obj = wpex_global_obj();
    // Return output if page header is disabled
    if (!isset($obj->has_page_header) || !$obj->has_page_header) {
        return $output;
    }
    // Return if there isn't a page header style defined
    if (!$obj->page_header_style) {
        return $output;
    }
    // Define var
    $css = '';
    // Check if a header style is defined and make header style dependent tweaks
    if ($obj->page_header_style) {
        // Customize background color
        if ($obj->page_header_style == 'solid-color' || $obj->page_header_style == 'background-image') {
            $bg_color = get_post_meta($obj->post_id, 'wpex_post_title_background_color', true);
            if ($bg_color) {
                $css .= 'background-color: ' . $bg_color . ' !important;';
            }
        }
        // Background image Style
        if ($obj->page_header_style == 'background-image') {
            // Add background image
            $bg_img = wpex_page_header_background_image($obj->post_id);
            if ($bg_img) {
                // Add css for background image
                $css .= 'background-image: url(' . $bg_img . ' ) !important;
						background-position: 50% 0;
						-webkit-background-size: cover;
						-moz-background-size: cover;
						-o-background-size: cover;
						background-size: cover;';
                // Custom height
                $title_height = get_post_meta($obj->post_id, 'wpex_post_title_height', true);
                $title_height = $title_height ? $title_height : '400';
                $title_height = apply_filters('wpex_post_title_height', $title_height);
                if ($title_height) {
                    $css .= 'height:' . wpex_sanitize_data($title_height, 'px') . ' !important;';
                }
            }
        }
    }
    // Apply all css to the page-header class
    if (!empty($css)) {
        $css = '.page-header { ' . $css . ' }';
    }
    // Overlay Color
    if (!empty($bg_img)) {
        $overlay_color = get_post_meta($obj->post_id, 'wpex_post_title_background_overlay', true);
        if ('bg_color' == $overlay_color && $obj->page_header_style == 'background-image' && isset($bg_color)) {
            $css .= '.background-image-page-header-overlay { background-color: ' . $bg_color . ' !important; }';
        }
    }
    // If css var isn't empty add to custom css output
    if (!empty($css)) {
        $output .= wpex_minify_css($css);
    }
    // Return output
    return $output;
}
Example #2
0
 /**
  * All theme functions hook into the wpex_head_css filter for this function.
  * This way all dynamic CSS is minified and outputted in one location in the site header.
  *
  * @since 1.6.0
  */
 public static function custom_css($output = NULL)
 {
     // Add filter for adding custom css via other functions
     $output = apply_filters('wpex_head_css', $output);
     // Minify and output CSS in the wp_head
     if (!empty($output)) {
         echo "<!-- TOTAL CSS -->\n<style type=\"text/css\">\n" . wp_strip_all_tags(wpex_minify_css($output)) . "\n</style>";
     }
 }