当前位置: 首页>>代码示例>>PHP>>正文


PHP jetpack_og_get_image函数代码示例

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


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

示例1: 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);
 }
开发者ID:bisko,项目名称:jetpack,代码行数:21,代码来源:test_class.functions.opengraph.php

示例2: 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');
 }
开发者ID:automattic,项目名称:jetpack,代码行数:26,代码来源:test_class.functions.opengraph.php

示例3: jetpack_og_tags


//.........这里部分代码省略.........
            }
        }
    }
    /**
     * Allow plugins to inject additional template-specific Open Graph tags.
     *
     * @module sharedaddy, publicize
     *
     * @since 3.0.0
     *
     * @param array $tags Array of Open Graph Meta tags.
     * @param array $args Array of image size parameters.
     */
    $tags = apply_filters('jetpack_open_graph_base_tags', $tags, compact('image_width', 'image_height'));
    // Re-enable widont if we had disabled it
    if ($disable_widont) {
        add_filter('the_title', 'widont');
    }
    /**
     * Do not return any Open Graph Meta tags if we don't have any info about a post.
     *
     * @module sharedaddy, publicize
     *
     * @since 3.0.0
     *
     * @param bool true Do not return any Open Graph Meta tags if we don't have any info about a post.
     */
    if (empty($tags) && apply_filters('jetpack_open_graph_return_if_empty', true)) {
        return;
    }
    $tags['og:site_name'] = get_bloginfo('name');
    // Get image info and build tags
    if (!post_password_required()) {
        $image_info = jetpack_og_get_image($image_width, $image_height);
        $tags['og:image'] = $image_info['src'];
        if (!empty($image_info['width'])) {
            $tags['og:image:width'] = $image_info['width'];
        }
        if (!empty($image_info['height'])) {
            $tags['og:image:height'] = $image_info['height'];
        }
    }
    // Facebook whines if you give it an empty title
    if (empty($tags['og:title'])) {
        $tags['og:title'] = __('(no title)', 'jetpack');
    }
    // Shorten the description if it's too long
    if (isset($tags['og:description'])) {
        $tags['og:description'] = strlen($tags['og:description']) > $description_length ? mb_substr($tags['og:description'], 0, $description_length) . '…' : $tags['og:description'];
    }
    // Try to add OG locale tag if the WP->FB data mapping exists
    if (defined('JETPACK__GLOTPRESS_LOCALES_PATH') && file_exists(JETPACK__GLOTPRESS_LOCALES_PATH)) {
        require_once JETPACK__GLOTPRESS_LOCALES_PATH;
        $_locale = get_locale();
        // We have to account for w.org vs WP.com locale divergence
        if (defined('IS_WPCOM') && IS_WPCOM) {
            $gp_locale = GP_Locales::by_field('slug', $_locale);
        } else {
            $gp_locale = GP_Locales::by_field('wp_locale', $_locale);
        }
    }
    if (isset($gp_locale->facebook_locale) && !empty($gp_locale->facebook_locale)) {
        $tags['og:locale'] = $gp_locale->facebook_locale;
    }
    /**
     * Allow the addition of additional Open Graph Meta tags, or modify the existing tags.
开发者ID:originallurch,项目名称:elderfinlayson.com,代码行数:67,代码来源:functions.opengraph.php

示例4: jetpack_og_tags

function jetpack_og_tags()
{
    if (false === apply_filters('jetpack_enable_opengraph', true)) {
        _deprecated_function('jetpack_enable_opengraph', '2.0.3', 'jetpack_enable_open_graph');
        return;
    }
    // Disable the widont filter on WP.com to avoid stray &nbsps
    $disable_widont = remove_filter('the_title', 'widont');
    $og_output = "\n<!-- Jetpack Open Graph Tags -->\n";
    $tags = array();
    $image_width = absint(apply_filters('jetpack_open_graph_image_width', 200));
    $image_height = absint(apply_filters('jetpack_open_graph_image_height', 200));
    $description_length = 197;
    if (is_home() || is_front_page()) {
        $site_type = get_option('open_graph_protocol_site_type');
        $tags['og:type'] = !empty($site_type) ? $site_type : 'blog';
        $tags['og:title'] = get_bloginfo('name');
        $tags['og:description'] = get_bloginfo('description');
        $front_page_id = get_option('page_for_posts');
        if ($front_page_id && is_home()) {
            $tags['og:url'] = get_permalink($front_page_id);
        } else {
            $tags['og:url'] = home_url('/');
        }
        // Associate a blog's root path with one or more Facebook accounts
        $facebook_admins = get_option('facebook_admins');
        if (!empty($facebook_admins)) {
            $tags['fb:admins'] = $facebook_admins;
        }
    } else {
        if (is_author()) {
            $tags['og:type'] = 'profile';
            $author = get_queried_object();
            $tags['og:title'] = $author->display_name;
            $tags['og:url'] = get_author_posts_url($author->ID);
            $tags['og:description'] = $author->description;
            $tags['profile:first_name'] = get_the_author_meta('first_name', $author->ID);
            $tags['profile:last_name'] = get_the_author_meta('last_name', $author->ID);
        } else {
            if (is_singular()) {
                global $post;
                $data = $post;
                // so that we don't accidentally explode the global
                $tags['og:type'] = 'article';
                $tags['og:title'] = empty($data->post_title) ? ' ' : wp_kses($data->post_title, array());
                $tags['og:url'] = get_permalink($data->ID);
                if (!post_password_required()) {
                    $tags['og:description'] = !empty($data->post_excerpt) ? strip_shortcodes(wp_kses($data->post_excerpt, array())) : wp_trim_words(strip_shortcodes(wp_kses($data->post_content, array())));
                }
                $tags['og:description'] = empty($tags['og:description']) ? ' ' : $tags['og:description'];
            }
        }
    }
    // Re-enable widont if we had disabled it
    if ($disable_widont) {
        add_filter('the_title', 'widont');
    }
    if (empty($tags)) {
        return;
    }
    $tags['og:site_name'] = get_bloginfo('name');
    $tags['og:image'] = jetpack_og_get_image($image_width, $image_height);
    // Facebook whines if you give it an empty title
    if (empty($tags['og:title'])) {
        $tags['og:title'] = __('(no title)', 'jetpack');
    }
    // Shorten the description if it's too long
    $tags['og:description'] = strlen($tags['og:description']) > $description_length ? mb_substr($tags['og:description'], 0, $description_length) . '...' : $tags['og:description'];
    // Add any additional tags here, or modify what we've come up with
    $tags = apply_filters('jetpack_open_graph_tags', $tags, compact('image_width', 'image_height'));
    foreach ((array) $tags as $tag_property => $tag_content) {
        // to accomodate multiple images
        $tag_content = (array) $tag_content;
        $tag_content = array_unique($tag_content);
        foreach ($tag_content as $tag_content_single) {
            if (empty($tag_content_single)) {
                continue;
            }
            // Don't ever output empty tags
            $og_tag = sprintf('<meta property="%s" content="%s" />', esc_attr($tag_property), esc_attr($tag_content_single));
            $og_output .= apply_filters('jetpack_open_graph_output', $og_tag);
            $og_output .= "\n";
        }
    }
    echo $og_output;
}
开发者ID:briancompton,项目名称:knightsplaza,代码行数:86,代码来源:functions.opengraph.php

示例5: jetpack_og_tags

function jetpack_og_tags()
{
    if (false === apply_filters('jetpack_enable_opengraph', true)) {
        _deprecated_function('jetpack_enable_opengraph', '2.0.3', 'jetpack_enable_open_graph');
        return;
    }
    // Disable the widont filter on WP.com to avoid stray &nbsps
    $disable_widont = remove_filter('the_title', 'widont');
    $og_output = "\n<!-- Jetpack Open Graph Tags -->\n";
    $tags = array();
    $image_width = absint(apply_filters('jetpack_open_graph_image_width', 200));
    $image_height = absint(apply_filters('jetpack_open_graph_image_height', 200));
    $description_length = 197;
    if (is_home() || is_front_page()) {
        $site_type = get_option('open_graph_protocol_site_type');
        $tags['og:type'] = !empty($site_type) ? $site_type : 'website';
        $tags['og:title'] = get_bloginfo('name');
        $tags['og:description'] = get_bloginfo('description');
        $front_page_id = get_option('page_for_posts');
        if ($front_page_id && is_home()) {
            $tags['og:url'] = get_permalink($front_page_id);
        } else {
            $tags['og:url'] = home_url('/');
        }
        // Associate a blog's root path with one or more Facebook accounts
        $facebook_admins = get_option('facebook_admins');
        if (!empty($facebook_admins)) {
            $tags['fb:admins'] = $facebook_admins;
        }
    } else {
        if (is_author()) {
            $tags['og:type'] = 'profile';
            $author = get_queried_object();
            $tags['og:title'] = $author->display_name;
            if (!empty($author->user_url)) {
                $tags['og:url'] = $author->user_url;
            } else {
                $tags['og:url'] = get_author_posts_url($author->ID);
            }
            $tags['og:description'] = $author->description;
            $tags['profile:first_name'] = get_the_author_meta('first_name', $author->ID);
            $tags['profile:last_name'] = get_the_author_meta('last_name', $author->ID);
        } else {
            if (is_singular()) {
                global $post;
                $data = $post;
                // so that we don't accidentally explode the global
                $tags['og:type'] = 'article';
                $tags['og:title'] = empty($data->post_title) ? ' ' : wp_kses($data->post_title, array());
                $tags['og:url'] = get_permalink($data->ID);
                if (!post_password_required()) {
                    $tags['og:description'] = !empty($data->post_excerpt) ? preg_replace('@https?://[\\S]+@', '', strip_shortcodes(wp_kses($data->post_excerpt, array()))) : wp_trim_words(preg_replace('@https?://[\\S]+@', '', strip_shortcodes(wp_kses($data->post_content, array()))));
                }
                if (empty($tags['og:description'])) {
                    $tags['og:description'] = __('Visit the post for more.', 'jetpack');
                }
                $tags['article:published_time'] = date('c', strtotime($data->post_date_gmt));
                $tags['article:modified_time'] = date('c', strtotime($data->post_modified_gmt));
                if (post_type_supports(get_post_type($data), 'author') && isset($data->post_author)) {
                    $publicize_facebook_user = get_post_meta($data->ID, '_publicize_facebook_user', true);
                    if (!empty($publicize_facebook_user)) {
                        $tags['article:author'] = esc_url($publicize_facebook_user);
                    } else {
                        $tags['article:author'] = get_author_posts_url($data->post_author);
                    }
                }
            }
        }
    }
    // Allow plugins to inject additional template-specific open graph tags
    $tags = apply_filters('jetpack_open_graph_base_tags', $tags, compact('image_width', 'image_height'));
    // Re-enable widont if we had disabled it
    if ($disable_widont) {
        add_filter('the_title', 'widont');
    }
    if (empty($tags) && apply_filters('jetpack_open_graph_return_if_empty', true)) {
        return;
    }
    $tags['og:site_name'] = get_bloginfo('name');
    if (!post_password_required()) {
        $tags['og:image'] = jetpack_og_get_image($image_width, $image_height);
    }
    // Facebook whines if you give it an empty title
    if (empty($tags['og:title'])) {
        $tags['og:title'] = __('(no title)', 'jetpack');
    }
    // Shorten the description if it's too long
    if (isset($tags['og:description'])) {
        $tags['og:description'] = strlen($tags['og:description']) > $description_length ? mb_substr($tags['og:description'], 0, $description_length) . '...' : $tags['og:description'];
    }
    // Add any additional tags here, or modify what we've come up with
    $tags = apply_filters('jetpack_open_graph_tags', $tags, compact('image_width', 'image_height'));
    // secure_urls need to go right after each og:image to work properly so we will abstract them here
    $secure = $tags['og:image:secure_url'] = empty($tags['og:image:secure_url']) ? '' : $tags['og:image:secure_url'];
    unset($tags['og:image:secure_url']);
    $secure_image_num = 0;
    foreach ((array) $tags as $tag_property => $tag_content) {
        // to accommodate multiple images
        $tag_content = (array) $tag_content;
        $tag_content = array_unique($tag_content);
//.........这里部分代码省略.........
开发者ID:aim-web-projects,项目名称:kobe-chuoh,代码行数:101,代码来源:functions.opengraph.php

示例6: jetpack_og_tags

function jetpack_og_tags()
{
    if (false === apply_filters('jetpack_enable_opengraph', true)) {
        _deprecated_function('jetpack_enable_opengraph', '2.0.3', 'jetpack_enable_open_graph');
        return;
    }
    $og_output = "\n<!-- Jetpack Open Graph Tags -->\n";
    $tags = array();
    $image_width = absint(apply_filters('jetpack_open_graph_image_width', 200));
    $image_height = absint(apply_filters('jetpack_open_graph_image_height', 200));
    $description_length = 197;
    if (is_home() || is_front_page()) {
        $site_type = get_option('open_graph_protocol_site_type');
        $tags['og:type'] = !empty($site_type) ? $site_type : 'blog';
        $tags['og:title'] = get_bloginfo('name');
        $tags['og:url'] = is_home() ? get_permalink(get_option('page_for_posts')) : home_url('/');
        $tags['og:description'] = get_bloginfo('description');
        // Associate a blog's root path with one or more Facebook accounts
        $facebook_admins = get_option('facebook_admins');
        if (!empty($facebook_admins)) {
            $tags['fb:admins'] = $facebook_admins;
        }
    } else {
        if (is_author()) {
            $tags['og:type'] = 'author';
            $author = get_queried_object();
            $tags['og:title'] = $author->display_name;
            $tags['og:url'] = get_author_posts_url($author->ID);
            $tags['og:description'] = $author->description;
        } else {
            if (is_singular()) {
                global $post;
                setup_postdata($post);
                $tags['og:type'] = 'article';
                $tags['og:title'] = get_the_title();
                $tags['og:url'] = get_permalink();
                $tags['og:description'] = strip_tags(get_the_excerpt());
                // Force a description, to avoid FB getting its own
                if (empty($tags['og:description'])) {
                    $tags['og:description'] = ' ';
                }
            }
        }
    }
    if (empty($tags)) {
        return;
    }
    $tags['og:site_name'] = get_bloginfo('name');
    $tags['og:image'] = jetpack_og_get_image($image_width, $image_height);
    // Facebook whines if you give it an empty title
    if (empty($tags['og:title'])) {
        $tags['og:title'] = __('(no title)', 'jetpack');
    }
    // Shorten the description if it's too long
    $tags['og:description'] = strlen($tags['og:description']) > $description_length ? mb_substr($tags['og:description'], 0, $description_length) . '...' : $tags['og:description'];
    // Add any additional tags here, or modify what we've come up with
    $tags = apply_filters('jetpack_open_graph_tags', $tags, compact('image_width', 'image_height'));
    foreach ((array) $tags as $tag_property => $tag_content) {
        // to accomodate multiple images
        $tag_content = (array) $tag_content;
        $tag_content = array_unique($tag_content);
        foreach ($tag_content as $tag_content_single) {
            if (empty($tag_content_single)) {
                continue;
            }
            // Don't ever output empty tags
            $og_tag = sprintf('<meta property="%s" content="%s" />', esc_attr($tag_property), esc_attr($tag_content_single));
            $og_output .= apply_filters('jetpack_open_graph_output', $og_tag);
            $og_output .= "\n";
        }
    }
    echo $og_output;
}
开发者ID:hscale,项目名称:webento,代码行数:73,代码来源:functions.opengraph.php


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