/**
 * Retrieve header image for custom header.
 *
 * @since 0.1
 * @uses HEADER_IMAGE
 * @uses HEADER_IMAGE_WIDTH
 * @uses HEADER_IMAGE_HEIGHT
 *
 * @return string
 */
function boom_header_image($width = null, $height = null)
{
    $default = defined('HEADER_IMAGE') ? HEADER_IMAGE : '';
    $url = get_theme_mod('header_image', $default);
    $width = defined('HEADER_IMAGE_WIDTH') ? HEADER_IMAGE_WIDTH : $width;
    $height = defined('HEADER_IMAGE_HEIGHT') ? HEADER_IMAGE_HEIGHT : $height;
    if ('remove-header' == $url) {
        return false;
    } elseif ('boom-slider-uploaded' == $url || 'boom-slider-default' == $url) {
        // slider
        echo boom_build_nivo_slider(boom_get_header_images(), $width, $height);
        return;
    } elseif (is_random_header_image()) {
        // random header mode
        $url = get_random_header_image();
    }
    if (is_ssl()) {
        $url = str_replace('http://', 'https://', $url);
    } else {
        $url = str_replace('https://', 'http://', $url);
    }
    $output = "<img src='" . esc_url_raw($url) . "' alt='' />";
    echo $output;
}
Пример #2
0
/**
 * Check if random header image is in use.
 *
 * Always true if user expressly chooses the option in Appearance > Header.
 * Also true if theme has multiple header images registered, no specific header image
 * is chosen, and theme turns on random headers with add_theme_support().
 *
 * @since 3.2.0
 *
 * @param string $type The random pool to use. any|default|uploaded
 * @return boolean
 */
function is_random_header_image($type = 'any')
{
    $header_image_mod = get_theme_mod('header_image', get_theme_support('custom-header', 'default-image'));
    if ('any' == $type) {
        if ('random-default-image' == $header_image_mod || 'random-uploaded-image' == $header_image_mod || '' != get_random_header_image() && empty($header_image_mod)) {
            return true;
        }
    } else {
        if ("random-{$type}-image" == $header_image_mod) {
            return true;
        } elseif ('default' == $type && empty($header_image_mod) && '' != get_random_header_image()) {
            return true;
        }
    }
    return false;
}
/**
 * Check if random header image is in use.
 *
 * Always true if user expressly chooses the option in Appearance > Header.
 * Also true if theme has multiple header images registered, no specific header image
 * is chosen, and theme turns on random headers with add_theme_support().
 *
 * @since 3.2.0
 * @uses HEADER_IMAGE
 *
 * @param string $type The random pool to use. any|default|uploaded
 * @return boolean
 */
function is_random_header_image($type = 'any')
{
    $default = defined('HEADER_IMAGE') ? HEADER_IMAGE : '';
    $header_image_mod = get_theme_mod('header_image', $default);
    if ('any' == $type) {
        if ('random-default-image' == $header_image_mod || 'random-uploaded-image' == $header_image_mod || '' != get_random_header_image() && empty($header_image_mod)) {
            return true;
        }
    } else {
        if ("random-{$type}-image" == $header_image_mod) {
            return true;
        } elseif ('default' == $type && empty($header_image_mod) && '' != get_random_header_image()) {
            return true;
        }
    }
    return false;
}
function jacket_core_custom_header_style()
{
    global $jacket_core;
    if (!isset($jacket_core->custom_header['css_name']) || empty($jacket_core->custom_header['css_name'])) {
        return;
    }
    $css_txt = '';
    $css_image = get_header_image();
    // ISSUE:: Random images don't work!
    if (empty($css_image)) {
        $css_image = get_random_header_image();
    }
    if (empty($css_image)) {
        $css_image = $jacket_core->custom_header['header_image'];
    }
    $h_height = apply_filters('jacket_core_custom_header_css_background_height', get_custom_header()->height);
    $h_width = apply_filters('jacket_core_custom_header_css_background_width', get_custom_header()->width);
    if (!empty($h_height)) {
        $css_txt .= "\n height: " . $h_height . 'px;';
    }
    /*
    	ISSUE::
    	Below Commented because we want the header to be more responsive.
    	This will keep custom header image from pushing outside of
    	the containing element
    
    	if ( !empty( $h_width ) ) $css_txt .= "\n width: " . $h_width . 'px;';
    */
    if (!empty($jacket_core->custom_header['css_bg_color'])) {
        $css_txt .= "\n background-color: " . $jacket_core->custom_header['css_bg_color'] . ';';
    }
    if (!empty($css_image)) {
        $css_image = apply_filters('jacket_core_custom_header_css_background_url', $css_image);
        $css_txt .= "\n background-image: " . ' url("' . $css_image . '");';
        if (!isset($jacket_core->custom_header['css_repeat_from_theme']) && $jacket_core->custom_header['css_repeat_from_theme'] != true) {
            if (!empty($jacket_core->custom_header['css_repeat'])) {
                $css_txt .= "\n background-repeat: " . $jacket_core->custom_header['css_repeat'] . ';';
            }
        }
        if (!isset($jacket_core->custom_header['css_position_from_theme']) && $jacket_core->custom_header['css_position_from_theme'] != true) {
            if (!empty($jacket_core->custom_header['css_position_x'])) {
                $css_position_txt .= ' ' . $jacket_core->custom_header['css_position_x'];
            }
            if (!empty($jacket_core->custom_header['css_position_y'])) {
                $css_position_txt .= ' ' . $jacket_core->custom_header['css_position_y'];
            }
            if (!empty(${$css_position_txt})) {
                $css_txt .= "\n background-position: " . $css_position_txt . ';';
            }
        }
    }
    $css_txt = apply_filters('jacket_core_custom_header_css_background', $css_txt);
    if (empty($css_txt)) {
        return;
    }
    ?>
<style type="text/css">
<?php 
    echo $jacket_core->custom_header['css_name'];
    ?>
 {
<?php 
    echo $css_txt . "\n";
    ?>
}
</style><?php 
}