本文整理匯總了PHP中jetpack_get_site_logo函數的典型用法代碼示例。如果您正苦於以下問題:PHP jetpack_get_site_logo函數的具體用法?PHP jetpack_get_site_logo怎麽用?PHP jetpack_get_site_logo使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了jetpack_get_site_logo函數的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: wm_logo
function wm_logo()
{
//Helper variables
$output = '';
$blog_info = apply_filters('wmhook_wm_logo_blog_info', array('name' => trim(get_bloginfo('name')), 'description' => trim(get_bloginfo('description'))));
$args = apply_filters('wmhook_wm_logo_args', array('title_att' => $blog_info['description'] ? $blog_info['name'] . ' | ' . $blog_info['description'] : $blog_info['name'], 'logo_image' => function_exists('jetpack_get_site_logo') ? absint(jetpack_get_site_logo('id')) : false, 'logo_type' => 'text', 'url' => home_url('/')));
//Preparing output
//Logo image
if (!empty($args['logo_image'])) {
$img_id = is_numeric($args['logo_image']) ? absint($args['logo_image']) : wm_get_image_id_from_url($args['logo_image']);
if ($img_id) {
$logo_url = wp_get_attachment_image_src($img_id, 'full');
$atts = (array) apply_filters('wmhook_wm_logo_image_atts', array('alt' => esc_attr(sprintf(_x('%s logo', 'Site logo image "alt" HTML attribute text.', 'wm_domain'), $blog_info['name'])), 'title' => esc_attr($args['title_att']), 'class' => ''));
$args['logo_image'] = wp_get_attachment_image($img_id, 'full', false, $atts);
}
$args['logo_type'] = 'img';
}
$args['logo_image'] = apply_filters('wmhook_wm_logo_logo_image', $args['logo_image']);
//Logo HTML
$output .= '<div class="site-branding">';
$output .= '<h1 class="' . apply_filters('wmhook_wm_logo_class', 'site-title logo type-' . $args['logo_type'], $args) . '">';
$output .= '<a href="' . esc_url($args['url']) . '" title="' . esc_attr($args['title_att']) . '">';
if ('text' === $args['logo_type']) {
$output .= '<span class="text-logo">' . $blog_info['name'] . '</span>';
} else {
$output .= $args['logo_image'];
}
$output .= '</a></h1>';
if ($blog_info['description']) {
$output .= '<h2 class="site-description">' . $blog_info['description'] . '</h2>';
}
$output .= '</div>';
//Output
echo apply_filters('wmhook_wm_logo_output', $output);
}
示例2: genlib_get_logo
/**
* Retrieve the site logo URL or ID (URL by default). Pass in the string
* 'id' for ID.
*
* @since 0.1.0
* @uses GenLib_Site_Logo::get_site_logo
* @param string $format the format to return
* @return mixed The URL or ID of our site logo, false if not set
*/
function genlib_get_logo($format = 'url')
{
if (class_exists('GenLib_Site_Logo', false)) {
return genlib_class('site-logo')->get_site_logo($format);
}
if (function_exists('jetpack_the_site_logo')) {
return jetpack_get_site_logo($format);
}
}
示例3: flagship_get_logo
/**
* Retrieve the site logo URL or ID (URL by default). Pass in the string
* 'id' for ID.
*
* @since 1.1.0
* @uses Flagship_Site_Logo::get_flagship_logo
* @param string $format the format to return
* @return mixed The URL or ID of our site logo, false if not set
*/
function flagship_get_logo($format = 'url')
{
if (!class_exists('Flagship_Site_Logo', false)) {
if (function_exists('jetpack_the_site_logo')) {
return jetpack_get_site_logo($format);
}
if (function_exists('the_site_logo')) {
return get_site_logo($format);
}
return null;
}
return flagship_library()->site_logo->get_flagship_logo($format);
}
示例4: test_jetpack_og_get_site_icon_and_logo_url
/**
* @author automattic
* @covers ::jetpack_og_get_image
* @since 3.9.2
*/
public function test_jetpack_og_get_site_icon_and_logo_url()
{
$test_icon_id = self::_create_upload_object(dirname(__FILE__) . '/jetpack-icon.jpg');
// Test Jetpack's Site Logo
update_option('site_logo', array('id' => $test_icon_id, 'url' => wp_get_attachment_url($test_icon_id)));
require_once JETPACK__PLUGIN_DIR . 'modules/theme-tools/site-logo/inc/functions.php';
require_once JETPACK__PLUGIN_DIR . 'modules/theme-tools/site-logo/inc/class-site-logo.php';
$image_url = jetpack_og_get_image();
$this->assertEquals($image_url['src'], jetpack_get_site_logo('url'));
// Test core's Site Icon
update_option('site_icon', $test_icon_id);
$image_url = jetpack_og_get_image();
$this->assertEquals($image_url['src'], get_site_icon_url(512));
delete_option('site_icon');
wp_delete_attachment($test_icon_id);
}
示例5: cultiv8_get_site_logo
function cultiv8_get_site_logo()
{
if (function_exists('get_custom_logo')) {
// Try to use WP4.5 built in site logo feature
return wp_get_attachment_image_url(get_theme_mod('custom_logo'), 'full');
} elseif (function_exists('jetpack_get_site_logo')) {
// If not available, try Jetpack's site logo feature
return jetpack_get_site_logo();
} else {
// Last resort, try our own feature
if (get_theme_mod('cultiv8_site_logo')) {
return get_theme_mod('cultiv8_site_logo');
} else {
return '';
}
}
}
示例6: test_jetpack_og_get_site_icon_and_logo_url
/**
* @author automattic
* @covers ::jetpack_og_get_image
* @since 3.9.2
*/
public function test_jetpack_og_get_site_icon_and_logo_url()
{
$default_url = jetpack_og_get_image();
// Test Jetpack's Site Logo
update_option('site_logo', array('id' => $this->icon_id, 'url' => wp_get_attachment_url($this->icon_id)));
require_once JETPACK__PLUGIN_DIR . 'modules/theme-tools/site-logo/inc/functions.php';
require_once JETPACK__PLUGIN_DIR . 'modules/theme-tools/site-logo/inc/class-site-logo.php';
// Test Smaller/Invalid Jetpack's Site Logo
$image_url = jetpack_og_get_image(512, 512);
$this->assertNotEquals(jetpack_get_site_logo('url'), $image_url['src']);
$this->assertEquals($default_url['src'], $image_url['src']);
// Test Valid-sized Jetpack's Site Logo
$image_url = jetpack_og_get_image(128, 128);
$this->assertEquals(jetpack_get_site_logo('url'), $image_url['src']);
delete_option('site_logo');
update_option('site_icon', $this->icon_id);
// Test Valid-sized core's Site Icon
$image_url = jetpack_og_get_image(128, 128);
$this->assertEquals(get_site_icon_url(128), $image_url['src']);
delete_option('site_icon');
}
示例7: jetpack_og_get_image
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;
}
示例8: twitter_cards_define_type_based_on_image_count
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);
}
示例9: wm_google_fonts
function wm_google_fonts($fonts_setup)
{
//Helper variables
$fonts_setup = array_unique(array_filter(array(get_theme_mod('font-family-body'), get_theme_mod('font-family-headings'))));
if (!is_admin() && !(function_exists('jetpack_get_site_logo') && jetpack_get_site_logo('id')) && get_theme_mod('font-family-logo')) {
$fonts_setup[] = get_theme_mod('font-family-logo');
}
if (empty($fonts_setup)) {
$fonts_setup = array('Ubuntu:400,300');
}
//Output
return $fonts_setup;
}
示例10: jetpack_og_get_image
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;
}
示例11: get_site_logo
/**
* Unprefixed, backwards-compatible function for getting either the site logo's image URL or its ID.
*
* @param string $show Return the site logo URL or ID.
* @uses jetpack_get_site_logo()
* @return string Site logo ID or URL (the default).
*/
function get_site_logo($show = 'url')
{
return jetpack_get_site_logo($show);
}
示例12: esc_url
</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('/'));
?>
" rel="home"><?php
bloginfo('name');
?>