• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP jetpack_has_site_icon函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中jetpack_has_site_icon函数的典型用法代码示例。如果您正苦于以下问题:PHP jetpack_has_site_icon函数的具体用法?PHP jetpack_has_site_icon怎么用?PHP jetpack_has_site_icon使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了jetpack_has_site_icon函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: 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;
}
开发者ID:originallurch,项目名称:elderfinlayson.com,代码行数:96,代码来源:functions.opengraph.php


示例2: 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);
 }
开发者ID:dtekcth,项目名称:datateknologer.se,代码行数:36,代码来源:class.jetpack-twitter-cards.php


示例3: select_page

    /**
     * Select a file admin view
     */
    public static function select_page()
    {
        // Display the site_icon form to upload the image
        ?>
		<form action="<?php 
        echo esc_url(admin_url('options-general.php?page=jetpack-site_icon-upload'));
        ?>
" method="post" enctype="multipart/form-data">

			<h2 class="site-icon-title">
			<?php 
        if (jetpack_has_site_icon()) {
            esc_html_e('Update Site Icon', 'jetpack');
        } else {
            esc_html_e('Add Site Icon', 'jetpack');
        }
        ?>
 <span class="small"><?php 
        esc_html_e('select a file', 'jetpack');
        ?>
</span></h2>
			<p><?php 
        esc_html_e('Upload a image that you want to use as your site icon. You will be asked to crop it in the next step.', 'jetpack');
        ?>
</p>


			<p><input name="site-iconfile" id="site-iconfile" type="file" /></p>
			<p><?php 
        esc_html_e('The image needs to be at least', 'jetpack');
        ?>
 <strong><?php 
        echo self::$min_size;
        ?>
px</strong> <?php 
        esc_html_e('in both width and height.', 'jetpack');
        ?>
</p>
			<p class="submit site-icon-submit-form">
				<input name="submit" value="<?php 
        esc_attr_e('Upload Image', 'jetpack');
        ?>
" type="submit" class="button button-primary button-large" /><?php 
        printf(__(' or <a href="%s">Cancel</a> and go back to the settings.', 'jetpack'), esc_url(admin_url('options-general.php')));
        ?>
				<input name="step" value="2" type="hidden" />

				<?php 
        wp_nonce_field('update-site_icon-2', '_nonce');
        ?>
			</p>
		</form>
		<?php 
    }
开发者ID:shazadmaved,项目名称:vizblog,代码行数:57,代码来源:jetpack-site-icon.php


示例4: 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));
 }
开发者ID:dtekcth,项目名称:datateknologer.se,代码行数:21,代码来源:class.jetpack-post-images.php


示例5: 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;
}
开发者ID:dtekcth,项目名称:datateknologer.se,代码行数:68,代码来源:functions.opengraph.php



注:本文中的jetpack_has_site_icon函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP jetpack_has_site_logo函数代码示例发布时间:2022-05-15
下一篇:
PHP jetpack_get_site_logo函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap