Ejemplo n.º 1
0
/**
 * 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 .= $css;
    }
    // Return output
    return $output;
}
Ejemplo n.º 2
0
 function wpex_page_header_css($output)
 {
     // Get post ID
     $post_id = wpex_get_the_id();
     // Return if ID not defined
     if (!$post_id) {
         return $output;
     }
     // Define var
     $css = $bg_img = '';
     $title_style = wpex_page_header_style($post_id);
     // Background Color
     if ($title_style == 'solid-color' || $title_style == 'background-image') {
         $bg_color = get_post_meta($post_id, 'wpex_post_title_background_color', true);
         if ($bg_color) {
             $css .= 'background-color: ' . $bg_color . ';';
         }
     }
     // Background image
     if ($title_style == 'background-image') {
         $bg_img = wpex_page_header_background_image($post_id);
         if ($bg_img) {
             $css .= 'background-image: url(' . $bg_img . ');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($post_id, 'wpex_post_title_height', true);
     if ($title_height) {
         $title_height = $title_height;
     } else {
         $title_height = '400';
     }
     if ($title_height && $bg_img) {
         $css .= 'height:' . intval($title_height) . 'px;';
     }
     // Apply all css to the page-header class
     if ('' != $css) {
         $output .= '.page-header { ' . $css . ' }';
     }
     // Overlay Color
     $overlay_color = get_post_meta($post_id, 'wpex_post_title_background_overlay', true);
     if ('bg_color' == $overlay_color && $title_style == 'background-image' && isset($bg_color)) {
         $output .= '.background-image-page-header-overlay { background-color: ' . $bg_color . '; }';
     }
     // Return css
     return $output;
 }