示例#1
0
    /**
     * Display Site Branding
     * @since  1.0.0
     * @return void
     */
    function storefront_site_branding()
    {
        if (function_exists('jetpack_has_site_logo') && jetpack_has_site_logo()) {
            jetpack_the_site_logo();
        } else {
            ?>
			<div class="site-branding  <?php 
            if (is_home() || is_front_page()) {
                echo 'homepage';
            }
            ?>
">
				<h1 class="site-title" style="display:none;"><a href="<?php 
            echo esc_url(home_url('/'));
            ?>
" rel="home"><?php 
            bloginfo('name');
            ?>
</a></h1>
				<p class="site-description" style="display:none;"><?php 
            bloginfo('description');
            ?>
</p>
				<img src="<?php 
            echo get_template_directory_uri();
            ?>
/images/logo.png" alt="">
			</div>
		<?php 
        }
    }
示例#2
0
    /**
     * Display Site Branding
     * @since  1.0.0
     * @return void
     */
    function storefront_site_branding()
    {
        if (function_exists('jetpack_has_site_logo') && jetpack_has_site_logo()) {
            jetpack_the_site_logo();
        } else {
            ?>
			<div class="site-branding">
				<h1 class="site-title"><a href="<?php 
            echo esc_url(home_url('/'));
            ?>
"
				                          rel="home"><?php 
            bloginfo('name');
            ?>
</a></h1>
				<?php 
            if ('' != get_bloginfo('description')) {
                ?>
					<p class="site-description"><?php 
                echo bloginfo('description');
                ?>
</p>
				<?php 
            }
            ?>
			</div>
		<?php 
        }
    }
示例#3
0
/**
 * Determine if a site logo is assigned or not.
 *
 * @since  0.1.0
 * @uses   GenLib_Site_Logo::has_site_logo
 * @return boolean True if there is an active logo, false otherwise
 */
function genlib_has_logo()
{
    if (class_exists('GenLib_Site_Logo', false)) {
        return genlib_class('site-logo')->has_site_logo();
    }
    if (function_exists('jetpack_the_site_logo')) {
        return jetpack_has_site_logo();
    }
}
/**
 * Determine if a site logo is assigned or not.
 *
 * @since  1.1.0
 * @uses   Flagship_Site_Logo::has_site_logo
 * @return boolean True if there is an active logo, false otherwise
 */
function flagship_has_logo()
{
    if (!class_exists('Flagship_Site_Logo', false)) {
        if (function_exists('jetpack_the_site_logo')) {
            return jetpack_has_site_logo();
        }
        if (function_exists('the_site_logo')) {
            return has_site_logo();
        }
        return null;
    }
    return flagship_library()->site_logo->has_site_logo();
}
示例#5
0
    /**
     * Display Site Branding
     * @since  1.0.0
     * @return void
     */
    function storefront_site_branding()
    {
        if (function_exists('jetpack_has_site_logo') && jetpack_has_site_logo()) {
            jetpack_the_site_logo();
        } else {
            $url = home_url('/');
            ?>
			<div class="site-branding">
			<img id="logo" src="/wp_development/content/plugins/rettner-plugin/new/images/uofrlogo.png">
			</div>
		<?php 
        }
    }
示例#6
0
/**
 * Adds custom classes to the array of body classes.
 *
 * @param array $classes Classes for the body element.
 * @return array
 */
function sketch_body_classes($classes)
{
    // Adds a class of group-blog to blogs with more than 1 published author.
    if (is_multi_author()) {
        $classes[] = 'group-blog';
    }
    if (function_exists('jetpack_has_site_logo') && jetpack_has_site_logo()) {
        $classes[] = 'has-site-logo';
    }
    if (!is_active_sidebar('sidebar-1')) {
        $classes[] = 'no-sidebar';
    }
    return $classes;
}
示例#7
0
/**
Adds custom classes to the array of body classes.
@param array $classes Classes for the body element.
@return array
*/
function zorkish_body_classes($classes)
{
    // Adds a class of group-blog to blogs with more than 1 published author.
    if (is_multi_author()) {
        $classes[] = 'group-blog';
    }
    if ('full' == get_post_meta(get_the_ID(), 'display', true)) {
        $classes[] = 'zk-full';
    }
    if ((!function_exists('jetpack_the_site_logo') || !jetpack_has_site_logo()) && get_theme_mod('zorkish_logo')) {
        $classes[] = 'has-site-logo';
    }
    return $classes;
}
示例#8
0
/**
 * Output an <img> tag of the site logo, at the size specified
 * in the theme's add_theme_support() declaration.
 *
 * @uses Site_Logo::logo
 * @uses Site_Logo::theme_size()
 * @uses jetpack_has_site_logo()
 * @uses jetpack_is_customize_preview()
 * @uses esc_url()
 * @uses home_url()
 * @uses esc_attr()
 * @uses wp_get_attachment_image()
 * @uses apply_filters()
 * @since 1.0
 */
function jetpack_the_site_logo()
{
    $logo = site_logo()->logo;
    $size = site_logo()->theme_size();
    $html = '';
    // If no logo is set, but we're in the Customizer, leave a placeholder (needed for the live preview).
    if (!jetpack_has_site_logo()) {
        if (jetpack_is_customize_preview()) {
            $html = sprintf('<a href="%1$s" class="site-logo-link" style="display:none;"><img class="site-logo" data-size="%2$s" /></a>', esc_url(home_url('/')), esc_attr($size));
        }
    } else {
        $html = sprintf('<a href="%1$s" class="site-logo-link" rel="home" itemprop="url">%2$s</a>', esc_url(home_url('/')), wp_get_attachment_image($logo['id'], $size, false, array('class' => "site-logo attachment-{$size}", 'data-size' => $size, 'itemprop' => "logo")));
    }
    echo apply_filters('jetpack_the_site_logo', $html, $logo, $size);
}
示例#9
0
/**
 * Output an <img> tag of the site logo, at the size specified
 * in the theme's add_theme_support() declaration.
 *
 * @uses Site_Logo::logo
 * @uses Site_Logo::theme_size()
 * @uses jetpack_has_site_logo()
 * @uses jetpack_is_customize_preview()
 * @uses esc_url()
 * @uses home_url()
 * @uses esc_attr()
 * @uses wp_get_attachment_image()
 * @uses apply_filters()
 * @since 1.0
 */
function jetpack_the_site_logo()
{
    $logo = site_logo()->logo;
    $size = site_logo()->theme_size();
    // Bail if no logo is set. Leave a placeholder if we're in the Customizer, though (needed for the live preview).
    if (!jetpack_has_site_logo()) {
        if (jetpack_is_customize_preview()) {
            printf('<a href="%1$s" class="site-logo-link" style="display:none;"><img class="site-logo" data-size="%2$s" /></a>', esc_url(home_url('/')), esc_attr($size));
        }
        return;
    }
    // We have a logo. Logo is go.
    $html = sprintf('<a href="%1$s" class="site-logo-link" rel="home">%2$s</a>', esc_url(home_url('/')), wp_get_attachment_image($logo['id'], $size, false, array('class' => "site-logo attachment-{$size}", 'data-size' => $size)));
    echo apply_filters('jetpack_the_site_logo', $html, $logo, $size);
}
示例#10
0
 /**
  * Display the logo.
  */
 function ultra_display_logo()
 {
     $logo = siteorigin_setting('header_logo');
     $logo = apply_filters('ultra_logo_image_id', $logo);
     if (empty($logo)) {
         if (function_exists('jetpack_the_site_logo') && jetpack_has_site_logo()) {
             // We'll let Jetpack handle things
             jetpack_the_site_logo();
             return;
         }
         // Just display the site title
         $logo_html = '<h1 class="site-title">' . get_bloginfo('name') . '</h1>';
         $logo_html = apply_filters('ultra_logo_text', $logo_html);
     } else {
         // Load the logo image
         if (is_array($logo)) {
             list($src, $height, $width) = $logo;
         } else {
             $image = wp_get_attachment_image_src($logo, 'full');
             $src = $image[0];
             $height = $image[2];
             $width = $image[1];
         }
         // Add all the logo attributes
         $logo_attributes = apply_filters('ultra_logo_image_attributes', array('src' => $src, 'width' => round($width), 'height' => round($height), 'alt' => sprintf(__('%s Logo', 'ultra'), get_bloginfo('name'))));
         if (siteorigin_setting('header_sticky') && siteorigin_setting('header_scale')) {
             $logo_attributes['data-scale'] = '1';
         }
         $logo_attributes_str = array();
         if (!empty($logo_attributes)) {
             foreach ($logo_attributes as $name => $val) {
                 if (empty($val)) {
                     continue;
                 }
                 $logo_attributes_str[] = $name . '="' . esc_attr($val) . '" ';
             }
         }
         $logo_html = apply_filters('ultra_logo_image', '<img ' . implode(' ', $logo_attributes_str) . ' />');
     }
     // Echo the image
     echo apply_filters('ultra_logo_html', $logo_html);
 }
示例#11
0
/**
 * Output an <img> tag of the site logo, at the size specified
 * in the theme's add_theme_support() declaration.
 *
 * @uses Site_Logo::logo
 * @uses Site_Logo::theme_size()
 * @uses jetpack_has_site_logo()
 * @uses jetpack_is_customize_preview()
 * @uses esc_url()
 * @uses home_url()
 * @uses esc_attr()
 * @uses wp_get_attachment_image()
 * @uses apply_filters()
 * @since 1.0
 */
function jetpack_the_site_logo()
{
    $logo = site_logo()->logo;
    $size = site_logo()->theme_size();
    $html = '';
    // If no logo is set, but we're in the Customizer, leave a placeholder (needed for the live preview).
    if (!jetpack_has_site_logo()) {
        if (jetpack_is_customize_preview()) {
            $html = sprintf('<a href="%1$s" class="site-logo-link" style="display:none;"><img class="site-logo" data-size="%2$s" /></a>', esc_url(home_url('/')), esc_attr($size));
        }
    } else {
        $html = sprintf('<a href="%1$s" class="site-logo-link" rel="home" itemprop="url">%2$s</a>', esc_url(home_url('/')), wp_get_attachment_image($logo['id'], $size, false, array('class' => "site-logo attachment-{$size}", 'data-size' => $size, 'itemprop' => "logo")));
    }
    /**
     * Filter the Site Logo output.
     *
     * @since 3.2.0
     *
     * @param string $html Site Logo HTML output.
     * @param array $logo Array of Site Logo details.
     * @param string $size Size specified in add_theme_support declaration, or 'thumbnail' default.
     */
    echo apply_filters('jetpack_the_site_logo', $html, $logo, $size);
}
示例#12
0
文件: header.php 项目: peiche/_smdl
			<?php 
    }
    ?>

		</header>
	<?php 
}
?>

	<!-- TODO customizer setting for fixed drawer -->

	<div class="mdl-layout__drawer">
    <span class="site-title mdl-layout-title">

			<?php 
if (function_exists('jetpack_has_site_logo') && jetpack_has_site_logo()) {
    ?>
				<img src="<?php 
    echo esc_url(jetpack_get_site_logo('url'));
    ?>
" alt="<?php 
    echo esc_attr(get_bloginfo('name'));
    ?>
" class="site-logo">
			<?php 
}
?>

			<a href="<?php 
echo esc_url(home_url('/'));
?>
    /**
     * Layout
     * Adjusts the default Storefront layout when the plugin is active
     */
    public function woa_sf_layout_adjustments()
    {
        $check = get_theme_mod('woa_sf_enable_logo', 'title_tagline');
        $logo = get_theme_mod('woa_sf_logo', null);
        if (($check == 'logo_img' || $check == 'logo_img_tagline') && $logo) {
            if (is_ssl()) {
                $logo = str_replace('http://', 'https://', $logo);
            }
            ?>
			<div class="site-branding site-logo-anchor">
				<a href="<?php 
            bloginfo('url');
            ?>
">
					<img src="<?php 
            echo $logo;
            ?>
" style="display:inline-block;">
				</a>
				<?php 
            if ($check == 'logo_img_tagline') {
                ?>
					<p class="site-description"><?php 
                bloginfo('description');
                ?>
</p>
				<?php 
            }
            ?>
			</div>
		<?php 
        } else {
            if (function_exists('jetpack_has_site_logo') && jetpack_has_site_logo()) {
                jetpack_the_site_logo();
            } else {
                ?>
			<div class="site-branding">
				<h1 class="site-title"><a href="<?php 
                echo esc_url(home_url('/'));
                ?>
" rel="home"><?php 
                bloginfo('name');
                ?>
</a></h1>
				<p class="site-description"><?php 
                bloginfo('description');
                ?>
</p>
			</div>
		<?php 
            }
        }
    }
示例#14
0
            
	<header id="masthead" class="group site-header title-bar top-bar" role="banner" data-sticky data-options="marginTop:0;" style="width:100%" data-top-anchor="masthead" data-btm-anchor="colophon:bottom">
            
            <div class="row"> <!-- Start Foundation row -->
                
                <div class="top-bar-title">
<!--                    <div class="title-bar" data-responsive-toggle="example-menu" data-hide-for="large">
                    <button class="menu-icon" type="button" data-toggle></button>
                    <div class="title-bar-title">Menu</div>
                    </div>-->
                    <div class="site-branding">
                    <?php 
if (has_custom_logo() || jetpack_has_site_logo()) {
    jinn_the_site_logo();
}
if (!has_custom_logo() && !jetpack_has_site_logo() || has_custom_logo() && get_theme_mod('show_logo_sitename') === true) {
    ?>
                    
                                <?php 
    if (is_front_page() || is_home() || is_page_template('page-templates/frontpage-portfolio.php')) {
        ?>
                                    <h1 class="site-title"><a href="<?php 
        echo esc_url(home_url('/'));
        ?>
" rel="home"><?php 
        bloginfo('name');
        ?>
</a></h1>
                                <?php 
    } else {
        ?>
/**
 *
 */
function storefront_site_branding()
{
    $is_logo = pbosfc_get_option('site_logo');
    $logo_uri = pbosfc_get_option('site_logo_image');
    if ($is_logo && $logo_uri) {
        if (is_ssl()) {
            $logo_uri = str_replace('http://', 'https://', $logo_uri);
        }
        ?>
		<div class="site-logo-anchor">
			<a href="<?php 
        bloginfo('url');
        ?>
"><img src="<?php 
        echo esc_html($logo_uri);
        ?>
" style="display:inline-block;"></a>
		</div>
		<?php 
    } else {
        if (function_exists('jetpack_has_site_logo') && jetpack_has_site_logo()) {
            jetpack_the_site_logo();
        } else {
            ?>
		<div class="site-branding">
			<h1 class="site-title"><a href="<?php 
            echo esc_url(home_url('/'));
            ?>
"
			                          rel="home"><?php 
            bloginfo('name');
            ?>
</a></h1>
			<?php 
            if ('' != get_bloginfo('description')) {
                ?>
				<p class="site-description"><?php 
                echo bloginfo('description');
                ?>
</p>
			<?php 
            }
            ?>
		</div>
	<?php 
        }
    }
}
 static function twitter_cards_define_type_based_on_image_count($og_tags, $extract)
 {
     $card_type = 'summary';
     $img_count = $extract['count']['image'];
     if (empty($img_count)) {
         // No images, use Blavatar as a thumbnail for the summary type.
         if (function_exists('blavatar_domain')) {
             $blavatar_domain = blavatar_domain(site_url());
             if (blavatar_exists($blavatar_domain)) {
                 $og_tags['twitter:image'] = blavatar_url($blavatar_domain, 'img', 240);
             }
         }
         // Second fall back, Site Logo
         if (empty($og_tags['twitter:image']) && (function_exists('jetpack_has_site_logo') && jetpack_has_site_logo())) {
             $og_tags['twitter:image'] = jetpack_get_site_logo('url');
         }
         // Third fall back, Site Icon
         if (empty($og_tags['twitter:image']) && (function_exists('jetpack_has_site_icon') && jetpack_has_site_icon())) {
             $og_tags['twitter:image'] = jetpack_site_icon_url(null, '240');
         }
         // Not falling back on Gravatar, because there's no way to know if we end up with an auto-generated one.
     } elseif (1 == $img_count && ('image' == $extract['type'] || 'gallery' == $extract['type'])) {
         // 1 image = photo
         // Test for $extract['type'] to limit to image and gallery, so we don't send a potential fallback image like a Gravatar as a photo post.
         $card_type = 'photo';
         $og_tags['twitter:image'] = add_query_arg('w', 1400, empty($extract['images']) ? $extract['image'] : $extract['images'][0]['url']);
     } elseif ($img_count <= 3) {
         // 2-3 images = summary with small thumbnail
         $og_tags['twitter:image'] = add_query_arg('w', 240, empty($extract['images']) ? $extract['image'] : $extract['images'][0]['url']);
     } elseif ($img_count >= 4) {
         // >= 4 images = gallery
         $card_type = 'gallery';
         $og_tags = self::twitter_cards_gallery($extract, $og_tags);
     }
     return array($og_tags, $card_type);
 }
示例#17
0
/**
 * Halves the size of the site-logo to make it retina ready
 *
 * @param	$html string The rendered site-logo html
 * @param	$logo array The logo-Jetpack object
 * @param	$size string The size of the logo
 * @see	jetpack_the_site_logo filter in Jetpack
 */
function regala_the_site_logo($html, $logo, $size)
{
    if (empty($logo)) {
        return '<a href="' . esc_url(home_url('/')) . '" class="site-logo-link" rel="home"><img class="site-logo attachment" width="160" src="' . get_template_directory_uri() . '/images/logo.png" title="Regala WordPress Theme"/></a>';
    }
    if (empty($logo['url'])) {
        return '<a href="' . esc_url(home_url('/')) . '" class="site-logo-link" rel="home"><img class="site-logo attachment" width="160" src="' . get_template_directory_uri() . '/images/logo.png" title="Regala WordPress Theme"/></a>';
    }
    // Checker, comes from jetpack_the_site_logo
    if (!jetpack_has_site_logo()) {
        return $html;
    }
    // Get the image size
    $imageAttachment = wp_get_attachment_image_src($logo['id'], $size);
    // Half the image size since we want a retina ready image
    $html = preg_replace('/width="(\\d+)"/i', 'width="' . $imageAttachment[1] / 2 . '"', $html);
    $html = preg_replace('/height="(\\d+)"/i', 'height="' . $imageAttachment[2] / 2 . '"', $html);
    return $html;
}
 /**
  * Display the logo 
  */
 function vantage_display_logo()
 {
     $logo = siteorigin_setting('logo_image');
     $logo = apply_filters('vantage_logo_image_id', $logo);
     if (empty($logo)) {
         if (function_exists('jetpack_the_site_logo') && jetpack_has_site_logo()) {
             // We'll let Jetpack handle things
             jetpack_the_site_logo();
             return;
         }
         // Just display the site title
         $logo_html = '<h1 class="site-title">' . get_bloginfo('name') . '</h1>';
         $logo_html = apply_filters('vantage_logo_text', $logo_html);
     } else {
         // load the logo image
         if (is_array($logo)) {
             list($src, $height, $width) = $logo;
         } else {
             $image = wp_get_attachment_image_src($logo, 'full');
             $src = $image[0];
             $height = $image[2];
             $width = $image[1];
         }
         // Add all the logo attributes
         $logo_attributes = apply_filters('vantage_logo_image_attributes', array('src' => $src, 'class' => siteorigin_setting('logo_in_menu_constrain') ? 'logo-height-constrain' : 'logo-no-height-constrain', 'width' => round($width), 'height' => round($height), 'alt' => sprintf(__('%s Logo', 'vantage'), get_bloginfo('name'))));
         if ($logo_attributes['width'] > vantage_get_site_width()) {
             // Don't let the width be more than the site width.
             $width = vantage_get_site_width();
             $logo_attributes['height'] = round($logo_attributes['height'] / ($logo_attributes['width'] / $width));
             $logo_attributes['width'] = $width;
         }
         $logo_attributes_str = array();
         if (!empty($logo_attributes)) {
             foreach ($logo_attributes as $name => $val) {
                 if (empty($val)) {
                     continue;
                 }
                 $logo_attributes_str[] = $name . '="' . esc_attr($val) . '" ';
             }
         }
         $logo_html = apply_filters('vantage_logo_image', '<img ' . implode(' ', $logo_attributes_str) . ' />');
     }
     // Echo the image
     echo apply_filters('vantage_logo_html', $logo_html);
 }
示例#19
0
 function lsx_site_identity()
 {
     if (function_exists('jetpack_has_site_logo') && jetpack_has_site_logo()) {
         jetpack_the_site_logo();
     } else {
         // shouldn't show both together.. its just strange
         if (true == get_theme_mod('site_logo_header_text', 1)) {
             lsx_site_title();
         }
     }
 }
function jetpack_og_get_image($width = 200, $height = 200, $max_images = 4)
{
    // Facebook requires thumbnails to be a minimum of 200x200
    $image = '';
    if (is_singular() && !is_home()) {
        global $post;
        $image = '';
        // Attempt to find something good for this post using our generalized PostImages code
        if (class_exists('Jetpack_PostImages')) {
            $post_images = Jetpack_PostImages::get_images($post->ID, array('width' => $width, 'height' => $height));
            if ($post_images && !is_wp_error($post_images)) {
                $image = array();
                foreach ((array) $post_images as $post_image) {
                    $image[] = $post_image['src'];
                }
            }
        }
    } else {
        if (is_author()) {
            $author = get_queried_object();
            if (function_exists('get_avatar_url')) {
                // Prefer the core function get_avatar_url() if available, WP 4.2+
                $image = get_avatar_url($author->user_email, array('size' => $width));
            } else {
                $has_filter = has_filter('pre_option_show_avatars', '__return_true');
                if (!$has_filter) {
                    add_filter('pre_option_show_avatars', '__return_true');
                }
                $avatar = get_avatar($author->user_email, $width);
                if (!$has_filter) {
                    remove_filter('pre_option_show_avatars', '__return_true');
                }
                if (!empty($avatar) && !is_wp_error($avatar)) {
                    if (preg_match('/src=["\']([^"\']+)["\']/', $avatar, $matches)) {
                    }
                    $image = wp_specialchars_decode($matches[1], ENT_QUOTES);
                }
            }
        }
    }
    if (empty($image)) {
        $image = array();
    } else {
        if (!is_array($image)) {
            $image = array($image);
        }
    }
    // First fall back, blavatar
    if (empty($image) && function_exists('blavatar_domain')) {
        $blavatar_domain = blavatar_domain(site_url());
        if (blavatar_exists($blavatar_domain)) {
            $image[] = blavatar_url($blavatar_domain, 'img', $width);
        }
    }
    // Second fall back, Site Logo
    if (empty($image) && (function_exists('jetpack_has_site_logo') && jetpack_has_site_logo())) {
        $image[] = jetpack_get_site_logo('url');
    }
    // Third fall back, Site Icon
    if (empty($image) && (function_exists('jetpack_has_site_icon') && jetpack_has_site_icon())) {
        $image[] = jetpack_site_icon_url(null, '512');
    }
    // Fourth fall back, blank image
    if (empty($image)) {
        $image[] = apply_filters('jetpack_open_graph_image_default', 'https://s0.wp.com/i/blank.jpg');
    }
    return $image;
}
示例#21
0
    ?>
			<a class="hamburger" data-action="toggle-overlay" data-overlay-id="menu-overlay" href="#menu-overlay"><span></span></a>
		<?php 
}
?>
	</div>
    
    <div class="site-info">
        <?php 
if (function_exists('jetpack_has_site_logo')) {
    ?>
            <a href="<?php 
    echo esc_url(home_url('/'));
    ?>
" class="site-logo-link" <?php 
    if (!jetpack_has_site_logo()) {
        ?>
style="display: none;"<?php 
    }
    ?>
><img src="<?php 
    echo esc_url(jetpack_get_site_logo('url'));
    ?>
" alt="<?php 
    echo esc_attr(get_bloginfo('name'));
    ?>
" class="site-logo"></a>
        <?php 
}
?>
        <a href="<?php 
示例#22
0
<body <?php 
body_class();
?>
 <?php 
hybrid_attr('body');
?>
>
<div id="page" class="site">

<div class="play-episode-overlay" play-episode-overlay></div>
	<a class="skip-link screen-reader-text" href="#content"><?php 
_e('Skip to content', 'toivo-lite');
?>
</a>
	<?php 
if (has_nav_menu('top') || has_nav_menu('social') || function_exists('jetpack_has_site_logo') && jetpack_has_site_logo()) {
    ?>
		<div id="top-header" class="top-header">
			<div id="top-header-buttons" class="top-header-buttons">
				<?php 
    if (has_nav_menu('top')) {
        ?>
					<button id="top-nav-toggle"><?php 
        _e('Top Menu', 'toivo-lite');
        ?>
</button>
				<?php 
    }
    ?>
			
				<?php 
function jetpack_og_get_image($width = 200, $height = 200, $max_images = 4)
{
    // Facebook requires thumbnails to be a minimum of 200x200
    $image = '';
    if (is_singular() && !is_home()) {
        global $post;
        $image = '';
        // Grab obvious image if $post is an attachment page for an image
        if (is_attachment($post->ID) && 'image' == substr($post->post_mime_type, 0, 5)) {
            $image = wp_get_attachment_url($post->ID);
        }
        // Attempt to find something good for this post using our generalized PostImages code
        if (!$image && class_exists('Jetpack_PostImages')) {
            $post_images = Jetpack_PostImages::get_images($post->ID, array('width' => $width, 'height' => $height));
            if ($post_images && !is_wp_error($post_images)) {
                $image = array();
                foreach ((array) $post_images as $post_image) {
                    $image['src'] = $post_image['src'];
                    if (isset($post_image['src_width'], $post_image['src_height'])) {
                        $image['width'] = $post_image['src_width'];
                        $image['height'] = $post_image['src_height'];
                    }
                }
            }
        }
    } else {
        if (is_author()) {
            $author = get_queried_object();
            if (function_exists('get_avatar_url')) {
                // Prefer the core function get_avatar_url() if available, WP 4.2+
                $image['src'] = get_avatar_url($author->user_email, array('size' => $width));
            } else {
                $has_filter = has_filter('pre_option_show_avatars', '__return_true');
                if (!$has_filter) {
                    add_filter('pre_option_show_avatars', '__return_true');
                }
                $avatar = get_avatar($author->user_email, $width);
                if (!$has_filter) {
                    remove_filter('pre_option_show_avatars', '__return_true');
                }
                if (!empty($avatar) && !is_wp_error($avatar)) {
                    if (preg_match('/src=["\']([^"\']+)["\']/', $avatar, $matches)) {
                    }
                    $image['src'] = wp_specialchars_decode($matches[1], ENT_QUOTES);
                }
            }
        }
    }
    if (empty($image)) {
        $image = array();
    } else {
        if (!is_array($image)) {
            $image = array('src' => $image);
        }
    }
    // First fall back, blavatar
    if (empty($image) && function_exists('blavatar_domain')) {
        $blavatar_domain = blavatar_domain(site_url());
        if (blavatar_exists($blavatar_domain)) {
            $image['src'] = blavatar_url($blavatar_domain, 'img', $width, false, true);
            $image['width'] = $width;
            $image['height'] = $height;
        }
    }
    // Second fall back, Site Logo
    if (empty($image) && (function_exists('jetpack_has_site_logo') && jetpack_has_site_logo())) {
        $image['src'] = jetpack_get_site_logo('url');
        $image_dimensions = jetpack_get_site_logo_dimensions();
        if (!empty($image_dimensions)) {
            $image['width'] = $image_dimensions['width'];
            $image['height'] = $image_dimensions['height'];
        }
    }
    // Third fall back, Site Icon
    if (empty($image) && (function_exists('jetpack_has_site_icon') && jetpack_has_site_icon())) {
        $image['src'] = jetpack_site_icon_url(null, '512');
        $image['width'] = '512';
        $image['height'] = '512';
    }
    // Fourth fall back, Core Site Icon. Added in WP 4.3.
    if (empty($image) && (function_exists('has_site_icon') && has_site_icon())) {
        $image['src'] = get_site_icon_url(null, '512');
    }
    // Finally fall back, blank image
    if (empty($image)) {
        /**
         * Filter the default Open Graph Image tag, used when no Image can be found in a post.
         *
         * @since 3.0.0
         *
         * @param string $str Default Image URL.
         */
        $image['src'] = apply_filters('jetpack_open_graph_image_default', 'https://s0.wp.com/i/blank.jpg');
    }
    return $image;
}
示例#24
0
 /**
  * Unprefixed, backwards-compatible function for determining if a site logo has been set.
  *
  * @uses   jetpack_has_site_logo()
  * @return bool True if a site logo is set, false otherwise.
  */
 function has_site_logo()
 {
     return jetpack_has_site_logo();
 }
    /**
     * Display the site title or logo
     *
     * @since  2.1.0
     * @return void
     */
    function storefront_site_title_or_logo()
    {
        if (function_exists('the_custom_logo') && has_custom_logo()) {
            $logo = get_custom_logo();
            echo $logo = is_home() ? '<h1 class="logo">' . $logo . '</h1>' : $logo;
        } elseif (function_exists('jetpack_has_site_logo') && jetpack_has_site_logo()) {
            jetpack_the_site_logo();
        } else {
            $tag = is_home() ? 'h1' : 'div';
            echo '<' . esc_attr($tag) . ' class="beta site-title"><a href="' . esc_url(home_url('/')) . '" rel="home">' . esc_attr(get_bloginfo('name')) . '</a></' . esc_attr($tag) . '>';
            if ('' != get_bloginfo('description')) {
                ?>
				<p class="site-description"><?php 
                echo bloginfo('description');
                ?>
</p>
				<?php 
            }
        }
    }