本文整理汇总了PHP中jetpack_site_icon_url函数的典型用法代码示例。如果您正苦于以下问题:PHP jetpack_site_icon_url函数的具体用法?PHP jetpack_site_icon_url怎么用?PHP jetpack_site_icon_url使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了jetpack_site_icon_url函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: jetpack_get_site_icon
function jetpack_get_site_icon($blog_id = null, $size = '512', $default = '', $alt = false)
{
if (!is_int($blog_id)) {
$blog_id = get_current_blog_id();
}
$size = esc_attr($size);
$class = "avatar avatar-{$size}";
$alt = $alt ? esc_attr($alt) : __('Site Icon', 'jetpack');
$src = esc_url(jetpack_site_icon_url($blog_id, $size, $default));
$avatar = "<img alt='{$alt}' src='{$src}' class='{$class}' height='{$size}' width='{$size}' />";
/**
* Filters the display options for the Site Icon.
*
* @module site-icon
*
* @since 3.2.0
*
* @param string $avatar The Site Icon in an html image tag.
* @param int $blog_id The local site Blog ID.
* @param string $size The size of the Site Icon, default is 512.
* @param string $default The default URL for the Site Icon.
* @param string $alt The alt tag for the avatar.
*/
return apply_filters('jetpack-get_site_icon', $avatar, $blog_id, $size, $default, $alt);
}
示例2: jetpack_get_site_icon
function jetpack_get_site_icon($blog_id = null, $size = '96', $default = '', $alt = false)
{
if (!is_int($blog_id)) {
$blog_id = get_current_blog_id();
}
$size = esc_attr($size);
$class = "avatar avatar-{$size}";
$alt = $alt ? esc_attr($alt) : __('Site Icon', 'jetpack');
$src = esc_url(jetpack_site_icon_url($blog_id, $size, $default));
$avatar = "<img alt='{$alt}' src='{$src}' class='{$class}' height='{$size}' width='{$size}' />";
return apply_filters('jetpack-get_site_icon', $avatar, $blog_id, $size, $default, $alt);
}
示例3: site_icon_add_meta
/**
* Add meta elements to a blog header to light up Blavatar icons recognized by user agents.
* @link http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#rel-icon HTML5 specification link icon
* @todo change Blavatar ico sizes once all Blavatars have been backfilled to new code
* @todo update apple-touch-icon to support retina display 114px and iPad 72px
*/
public function site_icon_add_meta()
{
if (apply_filters('site_icon_has_favicon', false)) {
return;
}
$url_114 = jetpack_site_icon_url(null, 114);
$url_72 = jetpack_site_icon_url(null, 72);
$url_32 = jetpack_site_icon_url(null, 32);
if ($url_32) {
echo '<link rel="icon" href="' . esc_url($url_32) . '" sizes="32x32" />' . "\n";
echo '<link rel="apple-touch-icon-precomposed" href="' . esc_url($url_114) . '">' . "\n";
// windows tiles
echo '<meta name="msapplication-TileImage" content="' . esc_url($url_114) . '"/>' . "\n";
}
}
示例4: 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;
}
示例5: function_exists
<?php
$site_logo = function_exists('jetpack_site_icon_url') ? jetpack_site_icon_url(null, 150) : get_stylesheet_directory_uri() . '/assets/images/logo.png';
$show_360 = false;
?>
<header class="w-section cabe-alho banner" role="banner">
<div class="w-container">
<div class="w-row">
<div class="w-col w-col-3 logo-container">
<a class="w-inline-block" href="#home" title="<?php
bloginfo('name');
?>
">
<img alt="<?php
bloginfo('name');
?>
" class="logo" src="<?php
echo esc_url($site_logo);
?>
" />
</a>
</div>
<div class="w-col w-col-2 redes-sociais">
<ul class="w-list-unstyled links-sociais">
<li class="social-item"><a class="social-link facebook imagem" href="http://facebook.com/www.dreamville.com.br" rel="external" title="Facebook">Facebook</a>
</li>
<li class="social-item"><a class="social-link twitter imagem" href="https://twitter.com/DreamvilleBuffe" rel="external" title="Twitter">Twitter</a>
</li>
<li class="social-item"><a class="social-link instagram imagem" href="https://instagram.com/dreamvillesalaodefestas" rel="external" title="Twitter">Instagram</a>
</li>
</ul>
示例6: jetpack_sync_core_icon
function jetpack_sync_core_icon()
{
if (function_exists('get_site_icon_url')) {
$url = get_site_icon_url();
} else {
return;
}
require_once JETPACK__PLUGIN_DIR . 'modules/site-icon/site-icon-functions.php';
// If there's a core icon, maybe update the option. If not, fall back to Jetpack's.
if (!empty($url) && $url !== jetpack_site_icon_url()) {
// This is the option that is synced with dotcom
Jetpack_Options::update_option('site_icon_url', $url);
} else {
if (empty($url) && did_action('delete_option_site_icon')) {
Jetpack_Options::delete_option('site_icon_url');
}
}
}
示例7: 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);
}
示例8: from_blavatar
/**
* @param int $post_id The post ID to check
* @param int $size
* @return Array containing details of the image, or empty array if none.
*/
static function from_blavatar($post_id, $size = 96)
{
$permalink = get_permalink($post_id);
if (function_exists('blavatar_domain') && function_exists('blavatar_exists') && function_exists('blavatar_url')) {
$domain = blavatar_domain($permalink);
if (!blavatar_exists($domain)) {
return array();
}
$url = blavatar_url($domain, 'img', $size);
} elseif (function_exists('jetpack_has_site_icon') && jetpack_has_site_icon()) {
$url = jetpack_site_icon_url(null, $size, $default = false);
} else {
return array();
}
return array(array('type' => 'image', 'from' => 'blavatar', 'src' => $url, 'src_width' => $size, 'src_height' => $size, 'href' => $permalink));
}
示例9: prepare_options_for_response
/**
* Remove 'validate_callback' item from options available for module.
* Fetch current option value and add to array of module options.
* Prepare values of module options that need special handling, like those saved in wpcom.
*
* @since 4.3.0
*
* @param string $module Module slug.
* @return array
*/
public static function prepare_options_for_response($module = '')
{
$options = self::get_module_available_options($module);
if (!is_array($options) || empty($options)) {
return $options;
}
foreach ($options as $key => $value) {
if (isset($options[$key]['validate_callback'])) {
unset($options[$key]['validate_callback']);
}
$default_value = isset($options[$key]['default']) ? $options[$key]['default'] : '';
$current_value = get_option($key, $default_value);
$options[$key]['current_value'] = self::cast_value($current_value, $options[$key]);
}
// Some modules need special treatment.
switch ($module) {
case 'monitor':
// Status of user notifications
$options['monitor_receive_notifications']['current_value'] = self::cast_value(self::get_remote_value('monitor', 'monitor_receive_notifications'), $options['monitor_receive_notifications']);
break;
case 'post-by-email':
// Email address
$options['post_by_email_address']['current_value'] = self::cast_value(self::get_remote_value('post-by-email', 'post_by_email_address'), $options['post_by_email_address']);
break;
case 'protect':
// Protect
$options['jetpack_protect_key']['current_value'] = get_site_option('jetpack_protect_key', false);
if (!function_exists('jetpack_protect_format_whitelist')) {
@(include JETPACK__PLUGIN_DIR . 'modules/protect/shared-functions.php');
}
$options['jetpack_protect_global_whitelist']['current_value'] = jetpack_protect_format_whitelist();
break;
case 'related-posts':
// It's local, but it must be broken apart since it's saved as an array.
$options = self::split_options($options, Jetpack_Options::get_option('relatedposts'));
break;
case 'verification-tools':
// It's local, but it must be broken apart since it's saved as an array.
$options = self::split_options($options, get_option('verification_services_codes'));
break;
case 'sharedaddy':
// It's local, but it must be broken apart since it's saved as an array.
if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
break;
}
$sharer = new Sharing_Service();
$options = self::split_options($options, $sharer->get_global_options());
$options['sharing_services']['current_value'] = $sharer->get_blog_services();
break;
case 'site-icon':
// Return site icon ID and URL to make it more complete.
$options['site_icon_id']['current_value'] = Jetpack_Options::get_option('site_icon_id');
if (!function_exists('jetpack_site_icon_url')) {
@(include JETPACK__PLUGIN_DIR . 'modules/site-icon/site-icon-functions.php');
}
$options['site_icon_url']['current_value'] = jetpack_site_icon_url();
break;
case 'after-the-deadline':
if (!function_exists('AtD_get_options')) {
@(include JETPACK__PLUGIN_DIR . 'modules/after-the-deadline.php');
}
$atd_options = array_merge(AtD_get_options(get_current_user_id(), 'AtD_options'), AtD_get_options(get_current_user_id(), 'AtD_check_when'));
unset($atd_options['name']);
foreach ($atd_options as $key => $value) {
$options[$key]['current_value'] = self::cast_value($value, $options[$key]);
}
$atd_options = AtD_get_options(get_current_user_id(), 'AtD_guess_lang');
$options['guess_lang']['current_value'] = self::cast_value(isset($atd_options['true']), $options['guess_lang']);
$options['ignored_phrases']['current_value'] = AtD_get_setting(get_current_user_id(), 'AtD_ignored_phrases');
unset($options['unignore_phrase']);
break;
case 'minileven':
$options['wp_mobile_excerpt']['current_value'] = 1 === intval($options['wp_mobile_excerpt']['current_value']) ? 'enabled' : 'disabled';
$options['wp_mobile_featured_images']['current_value'] = 1 === intval($options['wp_mobile_featured_images']['current_value']) ? 'enabled' : 'disabled';
break;
case 'stats':
// It's local, but it must be broken apart since it's saved as an array.
if (!function_exists('stats_get_options')) {
@(include JETPACK__PLUGIN_DIR . 'modules/stats.php');
}
$options = self::split_options($options, stats_get_options());
break;
}
return $options;
}
示例10: build_current_site_response
/**
* Collects the necessary information to return for a site's response.
*
* @return (array)
*/
public function build_current_site_response()
{
global $wpdb, $wp_version;
$response_format = self::$site_format;
$is_user_logged_in = is_user_logged_in();
$visible = array();
if ($is_user_logged_in) {
$current_user = wp_get_current_user();
$visible = get_user_meta($current_user->ID, 'blog_visibility', true);
if (!is_array($visible)) {
$visible = array();
}
}
$blog_id = (int) $this->api->get_blog_id_for_output();
/** This filter is documented in class.json-api-endpoints.php */
$is_jetpack = true === apply_filters('is_jetpack_site', false, $blog_id);
$site_url = get_option('siteurl');
if ($is_jetpack) {
remove_filter('option_stylesheet', 'fix_theme_location');
if ('https' !== parse_url($site_url, PHP_URL_SCHEME)) {
add_filter('set_url_scheme', array($this, 'force_http'), 10, 3);
}
}
foreach (array_keys($response_format) as $key) {
switch ($key) {
case 'ID':
$response[$key] = $blog_id;
break;
case 'name':
$response[$key] = (string) htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES);
break;
case 'description':
$response[$key] = (string) htmlspecialchars_decode(get_bloginfo('description'), ENT_QUOTES);
break;
case 'URL':
$response[$key] = (string) home_url();
break;
case 'jetpack':
$response[$key] = $is_jetpack;
// jetpack magic affects this value
break;
case 'is_private':
if (defined('IS_WPCOM') && IS_WPCOM) {
$public_setting = get_option('blog_public');
if (-1 == $public_setting) {
$response[$key] = true;
} else {
$response[$key] = false;
}
} else {
$response[$key] = false;
// magic
}
break;
case 'visible':
if ($is_user_logged_in) {
$is_visible = true;
if (isset($visible[$blog_id])) {
$is_visible = (bool) $visible[$blog_id];
}
// null and true are visible
$response[$key] = $is_visible;
}
break;
case 'post_count':
if ($is_user_logged_in) {
$response[$key] = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_status = 'publish'");
}
break;
case 'lang':
if ($is_user_logged_in) {
$response[$key] = (string) get_bloginfo('language');
}
break;
case 'icon':
if (function_exists('blavatar_domain') && function_exists('blavatar_exists') && function_exists('blavatar_url')) {
$domain = blavatar_domain(home_url());
if (blavatar_exists($domain)) {
$response[$key] = array('img' => (string) remove_query_arg('s', blavatar_url($domain, 'img')), 'ico' => (string) remove_query_arg('s', blavatar_url($domain, 'ico')));
} else {
// This is done so that we can access the updated blavatar on .com via the /me/sites endpoint
if (is_jetpack_site()) {
$site_icon_url = get_option('jetpack_site_icon_url');
if ($site_icon_url) {
$response[$key] = array('img' => (string) jetpack_photon_url($site_icon_url, array(), 'https'), 'ico' => (string) jetpack_photon_url($site_icon_url, array('w' => 16), 'https'));
}
}
}
} elseif (function_exists('jetpack_site_icon_url') && function_exists('jetpack_photon_url')) {
$response[$key] = array('img' => (string) jetpack_photon_url(jetpack_site_icon_url(get_current_blog_id(), 80), array('w' => 80), 'https'), 'ico' => (string) jetpack_photon_url(jetpack_site_icon_url(get_current_blog_id(), 16), array('w' => 16), 'https'));
}
break;
case 'logo':
// Set an empty response array.
$response[$key] = array('id' => (int) 0, 'sizes' => array(), 'url' => '');
//.........这里部分代码省略.........
示例11: all_done_page
/**
* All done page admin view
*
*/
public static function all_done_page()
{
$temp_image_data = get_option('site_icon_temp_data');
if (!$temp_image_data) {
// start again
self::select_page();
return;
}
$crop_ration = $temp_image_data['large_image_data'][0] / $temp_image_data['resized_image_data'][0];
// always bigger then 1
$crop_data = self::convert_coodiantes_from_resized_to_full($_POST['crop-x'], $_POST['crop-y'], $_POST['crop-w'], $_POST['crop-h'], $crop_ration);
$image_edit = wp_get_image_editor(_load_image_to_edit_path($temp_image_data['large_image_attachment_id']));
if (is_wp_error($image_edit)) {
return $image_edit;
}
// Delete the previous site_icon
$previous_site_icon_id = Jetpack_Options::get_option('site_icon_id');
self::delete_site_icon($previous_site_icon_id);
// crop the image
$image_edit->crop($crop_data['crop_x'], $crop_data['crop_y'], $crop_data['crop_width'], $crop_data['crop_height'], self::$min_size, self::$min_size);
$dir = wp_upload_dir();
$site_icon_filename = $image_edit->generate_filename(dechex(time()) . 'v' . self::$version . '_site_icon', null, 'png');
$image_edit->save($site_icon_filename);
add_filter('intermediate_image_sizes_advanced', array('Jetpack_Site_Icon', 'additional_sizes'));
$site_icon_id = self::save_attachment(__('Large Blog Image', 'jetpack'), $site_icon_filename, 'image/png');
remove_filter('intermediate_image_sizes_advanced', array('Jetpack_Site_Icon', 'additional_sizes'));
// Save the site_icon data into option
Jetpack_Options::update_option('site_icon_id', $site_icon_id);
//Get the site icon URL ready to sync
Jetpack_Options::update_option('site_icon_url', jetpack_site_icon_url(get_current_blog_id(), 512));
?>
<h2 class="site-icon-title"><?php
esc_html_e('Site Icon', 'jetpack');
?>
<span class="small"><?php
esc_html_e('All Done', 'jetpack');
?>
</span></h2>
<div id="message" class="updated below-h2"><p><?php
esc_html_e('Your site icon has been uploaded!', 'jetpack');
?>
<a href="<?php
echo esc_url(admin_url('options-general.php'));
?>
" ><?php
esc_html_e('Back to General Settings', 'jetpack');
?>
</a></p></div>
<?php
echo jetpack_get_site_icon(null, $size = '128');
?>
<?php
echo jetpack_get_site_icon(null, $size = '48');
?>
<?php
echo jetpack_get_site_icon(null, $size = '16');
?>
<?php
}
示例12: build_current_site_response
/**
* Collects the necessary information to return for a site's response.
*
* @return (array)
*/
public function build_current_site_response()
{
global $wpdb, $wp_version;
$response_format = self::$site_format;
$is_user_logged_in = is_user_logged_in();
$visible = array();
if ($is_user_logged_in) {
$current_user = wp_get_current_user();
$visible = get_user_meta($current_user->ID, 'blog_visibility', true);
if (!is_array($visible)) {
$visible = array();
}
}
$blog_id = (int) $this->api->get_blog_id_for_output();
$is_jetpack = true === apply_filters('is_jetpack_site', false, $blog_id);
$site_url = get_option('siteurl');
if ($is_jetpack) {
remove_filter('option_stylesheet', 'fix_theme_location');
if ('https' !== parse_url($site_url, PHP_URL_SCHEME)) {
add_filter('set_url_scheme', array($this, 'force_http'), 10, 3);
}
}
foreach (array_keys($response_format) as $key) {
switch ($key) {
case 'ID':
$response[$key] = $blog_id;
break;
case 'name':
$response[$key] = (string) htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES);
break;
case 'description':
$response[$key] = (string) htmlspecialchars_decode(get_bloginfo('description'), ENT_QUOTES);
break;
case 'URL':
$response[$key] = (string) home_url();
break;
case 'jetpack':
$response[$key] = $is_jetpack;
// jetpack magic affects this value
break;
case 'is_private':
if (defined('IS_WPCOM') && IS_WPCOM) {
$public_setting = get_option('blog_public');
if (-1 == $public_setting) {
$response[$key] = true;
} else {
$response[$key] = false;
}
} else {
$response[$key] = false;
// magic
}
break;
case 'visible':
if ($is_user_logged_in) {
$is_visible = true;
if (isset($visible[$blog_id])) {
$is_visible = $visible[$blog_id];
}
// null and true are visible
$response[$key] = $is_visible;
}
break;
case 'post_count':
if ($is_user_logged_in) {
$response[$key] = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_status = 'publish'");
}
break;
case 'lang':
if ($is_user_logged_in) {
$response[$key] = (string) get_bloginfo('language');
}
break;
case 'icon':
if (function_exists('blavatar_domain') && function_exists('blavatar_exists') && function_exists('blavatar_url')) {
$domain = blavatar_domain(home_url());
if (blavatar_exists($domain)) {
$response[$key] = array('img' => (string) remove_query_arg('s', blavatar_url($domain, 'img')), 'ico' => (string) remove_query_arg('s', blavatar_url($domain, 'ico')));
}
} elseif (function_exists('jetpack_site_icon_url') && function_exists('jetpack_photon_url')) {
$response[$key] = array('img' => (string) jetpack_photon_url(jetpack_site_icon_url(get_current_blog_id(), 80), array('w' => 80), 'https'), 'ico' => (string) jetpack_photon_url(jetpack_site_icon_url(get_current_blog_id(), 16), array('w' => 16), 'https'));
}
break;
case 'logo':
// Set an empty response array.
$response[$key] = array('id' => (int) 0, 'sizes' => array(), 'url' => '');
// Get current site logo values.
$logo = get_option('site_logo');
// Update the response array if there's a site logo currenty active.
if ($logo && 0 != $logo['id']) {
$response[$key]['id'] = $logo['id'];
$response[$key]['url'] = $logo['url'];
foreach ($logo['sizes'] as $size => $properties) {
$response[$key]['sizes'][$size] = $properties;
}
//.........这里部分代码省略.........
示例13: 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;
}
示例14: get_icon
function get_icon()
{
if (function_exists('jetpack_site_icon_url') && function_exists('jetpack_photon_url')) {
return array('img' => (string) jetpack_photon_url(jetpack_site_icon_url(get_current_blog_id(), 80), array('w' => 80), 'https'), 'ico' => (string) jetpack_photon_url(jetpack_site_icon_url(get_current_blog_id(), 16), array('w' => 16), 'https'));
}
return null;
}