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


PHP get_post_embed_url函数代码示例

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


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

示例1: test_get_post_embed_url_with_ugly_permalinks

 function test_get_post_embed_url_with_ugly_permalinks()
 {
     $post_id = self::factory()->post->create();
     $permalink = get_permalink($post_id);
     $embed_url = get_post_embed_url($post_id);
     $this->assertEquals($permalink . '&embed=true', $embed_url);
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:7,代码来源:postEmbedUrl.php

示例2: test_static_front_page_conflicts_with_embed_slug

 /**
  * @ticket 34971
  */
 function test_static_front_page_conflicts_with_embed_slug()
 {
     $this->set_permalink_structure('/%postname%/');
     // Create a post with the 'embed' post_name
     add_filter('wp_unique_post_slug', array($this, 'filter_unique_post_slug'));
     $post_embed_slug = self::factory()->post->create(array('post_name' => 'embed'));
     remove_filter('wp_unique_post_slug', array($this, 'filter_unique_post_slug'));
     $page_front = self::factory()->post->create(array('post_type' => 'page'));
     update_option('show_on_front', 'page');
     update_option('page_on_front', $page_front);
     $this->assertSame(home_url() . '/embed/embed/', get_post_embed_url($post_embed_slug));
     $this->assertSame(home_url() . '/?embed=true', get_post_embed_url($page_front));
     update_option('show_on_front', 'posts');
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:17,代码来源:postEmbedUrl.php

示例3: data_template_requests

 public function data_template_requests()
 {
     $post = self::factory()->post->create_and_get(array('post_type' => 'post', 'post_name' => 'post-name'));
     set_post_format($post, 'quote');
     $page = self::factory()->post->create_and_get(array('post_type' => 'page', 'post_name' => 'page-name'));
     add_post_meta($page->ID, '_wp_page_template', 'templates/page.php');
     $data = array();
     // Single post embed
     $data[] = array(get_post_embed_url($post), array('embed-post-quote.php', 'embed-post.php', 'embed.php', 'single-post-post-name.php', 'single-post.php', 'single.php', 'singular.php'));
     // Search
     $data[] = array(add_query_arg('s', 'foo', home_url()), array('search.php'));
     // Single page
     $data[] = array(get_permalink($page), array('templates/page.php', 'page-page-name.php', "page-{$page->ID}.php", 'page.php', 'singular.php'));
     // Single post
     $data[] = array(get_permalink($post), array('single-post-post-name.php', 'single-post.php', 'single.php', 'singular.php'));
     return $data;
 }
开发者ID:inpsyde,项目名称:wordpress-dev,代码行数:17,代码来源:template.php

示例4: get_post_embed_html

/**
 * Retrieves the embed code for a specific post.
 *
 * @since 4.4.0
 *
 * @param int         $width  The width for the response.
 * @param int         $height The height for the response.
 * @param int|WP_Post $post   Optional. Post ID or object. Default is global `$post`.
 * @return string|false Embed code on success, false if post doesn't exist.
 */
function get_post_embed_html($width, $height, $post = null)
{
    $post = get_post($post);
    if (!$post) {
        return false;
    }
    $embed_url = get_post_embed_url($post);
    $output = '<blockquote class="wp-embedded-content"><a href="' . esc_url(get_permalink($post)) . '">' . get_the_title($post) . "</a></blockquote>\n";
    $output .= "<script type='text/javascript'>\n";
    $output .= "<!--//--><![CDATA[//><!--\n";
    if (SCRIPT_DEBUG) {
        $output .= file_get_contents(ABSPATH . WPINC . '/js/wp-embed.js');
    } else {
        /*
         * If you're looking at a src version of this file, you'll see an "include"
         * statement below. This is used by the `grunt build` process to directly
         * include a minified version of wp-embed.js, instead of using the
         * file_get_contents() method from above.
         *
         * If you're looking at a build version of this file, you'll see a string of
         * minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG
         * and edit wp-embed.js directly.
         */
        $output .= <<<JS
\t\t!function(a,b){"use strict";function c(){if(!e){e=!0;var a,c,d,f,g=-1!==navigator.appVersion.indexOf("MSIE 10"),h=!!navigator.userAgent.match(/Trident.*rv:11\\./),i=b.querySelectorAll("iframe.wp-embedded-content"),j=b.querySelectorAll("blockquote.wp-embedded-content");for(c=0;c<j.length;c++)j[c].style.display="none";for(c=0;c<i.length;c++)d=i[c],d.style.display="",d.getAttribute("data-secret")||(f=Math.random().toString(36).substr(2,10),d.src+="#?secret="+f,d.setAttribute("data-secret",f)),(g||h)&&d.getAttribute("security")&&(a=d.cloneNode(!0),a.removeAttribute("security"),d.parentNode.replaceChild(a,d))}}var d=b.querySelector&&a.addEventListener,e=!1;a.wp=a.wp||{},a.wp.receiveEmbedMessage||(a.wp.receiveEmbedMessage=function(c){var d=c.data;if(d.secret||d.message||d.value){var e,f,g,h,i,j=b.querySelectorAll('iframe[data-secret="'+d.secret+'"]'),k=b.querySelectorAll('blockquote[data-secret="'+d.secret+'"]');for(e=0;e<k.length;e++)k[e].style.display="none";for(e=0;e<j.length;e++)f=j[e],f.style.display="","height"===d.message&&(g=parseInt(d.value,10),g>1e3?g=1e3:200>~~g&&(g=200),f.height=g),"link"===d.message&&(h=b.createElement("a"),i=b.createElement("a"),h.href=f.getAttribute("src"),i.href=d.value,i.host===h.host&&b.activeElement===f&&(a.top.location.href=d.value))}},d&&(a.addEventListener("message",a.wp.receiveEmbedMessage,!1),b.addEventListener("DOMContentLoaded",c,!1),a.addEventListener("load",c,!1)))}(window,document);
JS;
    }
    $output .= "\n//--><!]]>";
    $output .= "\n</script>";
    $output .= sprintf('<iframe sandbox="allow-scripts" security="restricted" src="%1$s" width="%2$d" height="%3$d" title="%4$s" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>', esc_url($embed_url), absint($width), absint($height), esc_attr__('Embedded WordPress Post'));
    /**
     * Filter the embed HTML output for a given post.
     *
     * @since 4.4.0
     *
     * @param string  $output The default HTML.
     * @param WP_Post $post   Current post object.
     * @param int     $width  Width of the response.
     * @param int     $height Height of the response.
     */
    return apply_filters('embed_html', $output, $post, $width, $height);
}
开发者ID:nxty2011,项目名称:WordPress,代码行数:52,代码来源:embed-functions.php

示例5: get_post_embed_html

/**
 * Retrieves the embed code for a specific post.
 *
 * @since 4.4.0
 *
 * @param int         $width  The width for the response.
 * @param int         $height The height for the response.
 * @param int|WP_Post $post   Optional. Post ID or object. Default is global `$post`.
 * @return string|false Embed code on success, false if post doesn't exist.
 */
function get_post_embed_html($width, $height, $post = null)
{
    $post = get_post($post);
    if (!$post) {
        return false;
    }
    $embed_url = get_post_embed_url($post);
    $output = '<blockquote class="wp-embedded-content"><a href="' . esc_url(get_permalink($post)) . '">' . get_the_title($post) . "</a></blockquote>\n";
    $output .= "<script type='text/javascript'>\n";
    $output .= "<!--//--><![CDATA[//><!--\n";
    if (SCRIPT_DEBUG) {
        $output .= file_get_contents(ABSPATH . WPINC . '/js/wp-embed.js');
    } else {
        /*
         * If you're looking at a src version of this file, you'll see an "include"
         * statement below. This is used by the `grunt build` process to directly
         * include a minified version of wp-embed.js, instead of using the
         * file_get_contents() method from above.
         *
         * If you're looking at a build version of this file, you'll see a string of
         * minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG
         * and edit wp-embed.js directly.
         */
        $output .= <<<JS
\t\tinclude "js/wp-embed.min.js"
JS;
    }
    $output .= "\n//--><!]]>";
    $output .= "\n</script>";
    $output .= sprintf('<iframe sandbox="allow-scripts" security="restricted" src="%1$s" width="%2$d" height="%3$d" title="%4$s" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>', esc_url($embed_url), absint($width), absint($height), esc_attr(sprintf(__('&#8220;%1$s&#8221; &#8212; %2$s'), get_the_title($post), get_bloginfo('name'))));
    /**
     * Filters the embed HTML output for a given post.
     *
     * @since 4.4.0
     *
     * @param string  $output The default HTML.
     * @param WP_Post $post   Current post object.
     * @param int     $width  Width of the response.
     * @param int     $height Height of the response.
     */
    return apply_filters('embed_html', $output, $post, $width, $height);
}
开发者ID:ntwb,项目名称:wordpress-travis,代码行数:52,代码来源:embed.php

示例6: test_get_post_embed_html

 /**
  * Test the get_post_embed_html function.
  */
 function test_get_post_embed_html()
 {
     $post_id = $this->factory->post->create();
     $expected = '<iframe sandbox="allow-scripts" security="restricted" src="' . esc_url(get_post_embed_url($post_id)) . '" width="200" height="200" title="Embedded WordPress Post" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>';
     $this->assertEquals($expected, get_post_embed_html($post_id, 200, 200));
 }
开发者ID:johnbillion,项目名称:oEmbed-API,代码行数:9,代码来源:test-plugin.php

示例7: wp_oembed_old_slug_redirect

/**
 * Custom old slug redirection function.
 *
 * @SuppressWarnings(PHPMD.CyclomaticComplexity)
 * @SuppressWarnings(PHPMD.NPathComplexity)
 * @codeCoverageIgnore
 */
function wp_oembed_old_slug_redirect()
{
    global $wp_query, $wpdb;
    if (false === get_query_var('embed', false)) {
        return;
    }
    if (!is_404() || false === get_query_var('name', false)) {
        return;
    }
    // Guess the current post_type based on the query vars.
    $post_type = 'post';
    if (get_query_var('post_type')) {
        $post_type = get_query_var('post_type');
    } elseif (get_query_var('pagename', false)) {
        $post_type = 'page';
    }
    if (is_array($post_type)) {
        if (count($post_type) > 1) {
            return;
        }
        $post_type = reset($post_type);
    }
    // Do not attempt redirect for hierarchical post types.
    if (is_post_type_hierarchical($post_type)) {
        return;
    }
    $query = $wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta}, {$wpdb->posts} WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_slug' AND meta_value = %s", $post_type, $wp_query->query_vars['name']);
    if (get_query_var('year', false)) {
        $query .= $wpdb->prepare(' AND YEAR(post_date) = %d', $wp_query->query_vars['year']);
    }
    if (get_query_var('monthnum', false)) {
        $query .= $wpdb->prepare(' AND MONTH(post_date) = %d', $wp_query->query_vars['monthnum']);
    }
    if (get_query_var('day', false)) {
        $query .= $wpdb->prepare(' AND DAYOFMONTH(post_date) = %d', $wp_query->query_vars['day']);
    }
    $post_id = (int) $wpdb->get_var($query);
    if (!$post_id) {
        return;
    }
    wp_redirect(get_post_embed_url($post_id), 301);
    exit;
}
开发者ID:hinaloe,项目名称:oEmbed-API,代码行数:50,代码来源:functions.php

示例8: test_get_post_embed_html

 function test_get_post_embed_html()
 {
     $post_id = self::factory()->post->create();
     $title = esc_attr(sprintf(__('&#8220;%1$s&#8221; &#8212; %2$s'), get_the_title($post_id), get_bloginfo('name')));
     $expected = '<iframe sandbox="allow-scripts" security="restricted" src="' . esc_url(get_post_embed_url($post_id)) . '" width="200" height="200" title="' . $title . '" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>';
     $this->assertStringEndsWith($expected, get_post_embed_html(200, 200, $post_id));
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:7,代码来源:template.php

示例9: get_post_embed_html

/**
 * Get the embed code for a specific post.
 *
 * @param int|WP_Post $post   Optional. Post ID or object. Defaults to the current post.
 * @param int         $width  The width for the response.
 * @param int         $height The height for the response.
 * @return string|false Embed code on success, false if post doesn't exist.
 */
function get_post_embed_html($post = null, $width, $height)
{
    $post = get_post($post);
    if (!$post) {
        return false;
    }
    $embed_url = get_post_embed_url($post);
    $output = sprintf('<iframe sandbox="allow-scripts" security="restricted" src="%1$s" width="%2$d" height="%3$d" title="%4$s" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>', esc_url($embed_url), $width, $height, __('Embedded WordPress Post', 'oembed-api'));
    /**
     * Filters the oEmbed HTML output.
     *
     * @param string  $output The default HTML.
     * @param WP_Post $post   Current post object.
     * @param int     $width  Width of the response.
     * @param int     $height Height of the response.
     */
    return apply_filters('oembed_html', $output, $post, $width, $height);
}
开发者ID:kanenas,项目名称:oEmbed-API,代码行数:26,代码来源:functions.php

示例10: get_post_embed_html

/**
 * Retrieves the embed code for a specific post.
 *
 * @since 4.4.0
 *
 * @param int|WP_Post $post   Optional. Post ID or object. Default is global `$post`.
 * @param int         $width  The width for the response.
 * @param int         $height The height for the response.
 * @return string|false Embed code on success, false if post doesn't exist.
 */
function get_post_embed_html($post = null, $width, $height)
{
    $post = get_post($post);
    if (!$post) {
        return false;
    }
    $embed_url = get_post_embed_url($post);
    $output = "<script type='text/javascript'>\n";
    if (SCRIPT_DEBUG) {
        $output .= file_get_contents(ABSPATH . WPINC . '/js/wp-embed.js');
    } else {
        /*
         * If you're looking at a src version of this file, you'll see an "include"
         * statement below. This is used by the `grunt build` process to directly
         * include a minified version of wp-embed.js, instead of using the
         * file_get_contents() method from above.
         *
         * If you're looking at a build version of this file, you'll see a string of
         * minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG
         * and edit wp-embed.js directly.
         */
        $output .= <<<JS
\t\t!function(a,b){"use strict";function c(){var a=-1!==navigator.appVersion.indexOf("MSIE 10"),c=!!navigator.userAgent.match(/Trident.*rv\\:11\\./);if(a||c)for(var d,e=b.querySelectorAll(".wp-embedded-content[security]"),f=0;f<e.length;f++)d=e[f].cloneNode(!0),d.removeAttribute("security"),e[f].parentNode.insertBefore(d,e[f].nextSibling),e[f].parentNode.removeChild(e[f])}a.wp=a.wp||{},a.wp.receiveEmbedMessage||(a.wp.receiveEmbedMessage=function(c){var d=c.data;if(d.secret||d.message||d.value)for(var e=b.querySelectorAll('.wp-embedded-content[data-secret="'+d.secret+'"]'),f=0;f<e.length;f++){var g=e[f];if("height"===d.message){var h=d.value;h>1e3?h=1e3:200>h&&(h=200),g.height=h+"px"}if("link"===d.message){var i=b.createElement("a"),j=b.createElement("a");i.href=g.getAttribute("src"),j.href=d.value,j.host===i.host&&b.activeElement===g&&(a.top.location.href=d.value)}}},a.addEventListener("message",a.wp.receiveEmbedMessage,!1),b.addEventListener("DOMContentLoaded",c,!1))}(window,document);
JS;
    }
    $output .= "\n</script>";
    $output .= sprintf('<iframe sandbox="allow-scripts" security="restricted" src="%1$s" width="%2$d" height="%3$d" title="%4$s" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>', esc_url($embed_url), absint($width), absint($height), esc_attr__('Embedded WordPress Post'));
    /**
     * Filter the embed HTML output for a given post.
     *
     * @since 4.4.0
     *
     * @param string  $output The default HTML.
     * @param WP_Post $post   Current post object.
     * @param int     $width  Width of the response.
     * @param int     $height Height of the response.
     */
    return apply_filters('embed_html', $output, $post, $width, $height);
}
开发者ID:hanwoody,项目名称:WordPress,代码行数:49,代码来源:embed-functions.php

示例11: test_get_post_embed_html

 function test_get_post_embed_html()
 {
     $post_id = self::factory()->post->create();
     $expected = '<iframe sandbox="allow-scripts" security="restricted" src="' . esc_url(get_post_embed_url($post_id)) . '" width="200" height="200" title="Embedded WordPress Post" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>';
     $this->assertStringEndsWith($expected, get_post_embed_html(200, 200, $post_id));
 }
开发者ID:nkeat12,项目名称:dv,代码行数:6,代码来源:template.php

示例12: test_wp_oembed_excerpt_more

 /**
  * Test excerpt function.
  */
 function test_wp_oembed_excerpt_more()
 {
     $post_id = $this->factory->post->create(array('post_content' => 'Foo Bar'));
     $this->assertEquals('', wp_oembed_excerpt_more(''));
     $this->go_to(get_post_embed_url($post_id));
     $actual = wp_oembed_excerpt_more('');
     $expected = sprintf('&hellip; <a class="wp-embed-more" href="%s" target="_top">Read more</a>', get_the_permalink());
     $this->assertEquals($expected, $actual);
 }
开发者ID:rmccue,项目名称:oEmbed-API,代码行数:12,代码来源:test-frontend.php

示例13: test_is_embed

 /**
  * Test is_embed.
  */
 function test_is_embed()
 {
     $this->assertFalse(is_embed());
     $post_id = $this->factory->post->create();
     $this->go_to(get_post_embed_url($post_id));
     $this->assertTrue(is_embed());
     $file = DIR_TESTDATA . '/images/canola.jpg';
     $attachment_id = $this->factory->attachment->create_object($file, $post_id, array('post_mime_type' => 'image/jpeg'));
     $this->go_to(get_post_embed_url($attachment_id));
     $this->assertTrue(is_embed());
     $this->go_to(home_url('/?p=123&embed=true'));
     $this->assertTrue(is_embed());
 }
开发者ID:hinaloe,项目名称:oEmbed-API,代码行数:16,代码来源:test-plugin.php

示例14: test_embed_template_hierarchy_for_page

 public function test_embed_template_hierarchy_for_page()
 {
     $this->assertTemplateHierarchy(get_post_embed_url(self::$page), array('embed-page.php', 'embed.php', 'templates/page.php', 'page-page-name-😀.php', 'page-page-name-%f0%9f%98%80.php', 'page-' . self::$page->ID . '.php', 'page.php', 'singular.php'));
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:4,代码来源:template.php


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