Esempio n. 1
0
/**
 * Retrieve the site title (image or text).
 *
 * @since  1.0.0
 * @return string
 */
function king_news_get_site_title_by_type($type)
{
    if (!in_array($type, array('text', 'image'))) {
        $type = 'text';
    }
    $logo = get_bloginfo('name');
    if ('text' === $type) {
        return $logo;
    }
    $logo_url = get_theme_mod('header_logo_url', king_news_theme()->customizer->get_default('header_logo_url'));
    if (!$logo_url) {
        return $logo;
    }
    $logo_url = king_news_render_theme_url($logo_url);
    $retina_logo = '';
    $retina_logo_url = get_theme_mod('retina_header_logo_url');
    $retina_logo_url = king_news_render_theme_url($retina_logo_url);
    $logo_id = king_news_get_image_id_by_url($logo_url);
    if ($retina_logo_url) {
        $retina_logo = sprintf('srcset="%s 2x"', esc_url($retina_logo_url));
    }
    $logo_src = wp_get_attachment_image_src($logo_id, 'full');
    if ($logo_id && $logo_src) {
        $atts = ' width="' . $logo_src[1] . '" height="' . $logo_src[2] . '"';
    } else {
        $atts = '';
    }
    $format_image = apply_filters('king_news_header_logo_image_format', '<img src="%1$s" alt="%2$s" class="site-link__img" %3$s%4$s>');
    return sprintf($format_image, esc_url($logo_url), esc_attr($logo), $retina_logo, $atts);
}
Esempio n. 2
0
/**
 * Retrieve the site title (image or text).
 *
 * @since  1.0.0
 * @return string
 */
function king_news_get_site_title_by_type($type)
{
    if (!in_array($type, array('text', 'image'))) {
        $type = 'text';
    }
    $logo = get_bloginfo('name');
    if ('text' === $type) {
        return $logo;
    }
    $logo_url = get_theme_mod('header_logo_url', king_news_theme()->customizer->get_default('header_logo_url'));
    if (!$logo_url) {
        return $logo;
    }
    $retina_logo = '';
    $retina_logo_url = get_theme_mod('retina_header_logo_url');
    if ($retina_logo_url) {
        $retina_logo = sprintf('srcset="%s 2x"', esc_url($retina_logo_url));
    }
    $format_image = apply_filters('king_news_header_logo_image_format', '<img src="%1$s" alt="%2$s" class="site-link__img" %3$s>');
    return sprintf($format_image, esc_url(king_news_render_theme_url($logo_url)), esc_attr($logo), $retina_logo);
}