本文整理汇总了PHP中get_post_embed_html函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_embed_html函数的具体用法?PHP get_post_embed_html怎么用?PHP get_post_embed_html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_post_embed_html函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_get_oembed_response_data_author
/**
* Test get_oembed_response_data with an author.
*/
function test_get_oembed_response_data_author()
{
$user_id = self::factory()->user->create(array('display_name' => 'John Doe'));
$post = self::factory()->post->create_and_get(array('post_title' => 'Some Post', 'post_author' => $user_id));
$data = get_oembed_response_data($post, 400);
$this->assertEqualSets(array('version' => '1.0', 'provider_name' => get_bloginfo('name'), 'provider_url' => get_home_url('/'), 'author_name' => 'John Doe', 'author_url' => get_author_posts_url($user_id), 'title' => 'Some Post', 'type' => 'rich', 'width' => 400, 'height' => 225, 'html' => get_post_embed_html(400, 225, $post)), $data);
}
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:10,代码来源:getResponseData.php
示例2: get_oembed_response
/**
* Callback for our API endpoint.
*
* Returns the JSON object for the post.
*
* @param WP_REST_Request $request Full details about the request.
*
* @return WP_Error|WP_REST_Response
*/
public function get_oembed_response(WP_REST_Request $request)
{
$post_id = url_to_postid($request['url']);
/**
* Filter the determined post id.
*
* @param int $post_id The post ID.
* @param string $url The requestd URL.
*/
$post_id = apply_filters('rest_oembed_request_post_id', $post_id, $request['url']);
if (0 === $post_id) {
return new WP_Error('rest_oembed_invalid_url', __('Invalid URL.', 'oembed-api'), array('status' => 404));
}
// Todo: Perhaps just default to json if something invalid is provided.
if (!in_array($request['format'], array('json', 'xml'))) {
return new WP_Error('rest_oembed_invalid_format', __('Invalid format.', 'oembed-api'), array('status' => 501));
}
/**
* Current post object.
*
* @var WP_Post $post
*/
$post = get_post($post_id);
/**
* User object for the post author.
*
* @var WP_User $author
*/
$author = get_userdata($post->post_author);
/**
* Filter the allowed minimum width for the oEmbed response.
*
* @param int $width The minimum width. Defaults to 200.
*/
$minwidth = apply_filters('rest_oembed_minwidth', 200);
/**
* Filter the allowed maximum width for the oEmbed response.
*
* @param int $width The maximum width. Defaults to 600.
*/
$maxwidth = apply_filters('rest_oembed_maxwidth', 600);
$width = $request['maxwidth'];
if ($width < $minwidth) {
$width = $minwidth;
} else {
if ($width > $maxwidth) {
$width = $maxwidth;
}
}
// Todo: this shouldn't be hardcoded.
$height = ceil($width / 16 * 9);
/**
* Filters the oEmbed response data.
*
* @param array $data The response data.
*/
$data = apply_filters('rest_oembed_response_data', array('version' => '1.0', 'provider_name' => get_bloginfo('name'), 'provider_url' => get_home_url(), 'author_name' => $author->display_name, 'author_url' => get_author_posts_url($author->ID, $author->user_nicename), 'title' => $post->post_title, 'type' => 'rich', 'width' => $width, 'height' => $height, 'html' => get_post_embed_html($post, $width, $height)));
return $data;
}
开发者ID:pfefferle,项目名称:oEmbed-API,代码行数:68,代码来源:endpoint.php
示例3: get_oembed_response_data_rich
/**
* Filters the oEmbed response data to return an iframe embed code.
*
* @since 4.4.0
*
* @param array $data The response data.
* @param WP_Post $post The post object.
* @param int $width The requested width.
* @param int $height The calculated height.
* @return array The modified response data.
*/
function get_oembed_response_data_rich($data, $post, $width, $height)
{
$data['width'] = absint($width);
$data['height'] = absint($height);
$data['type'] = 'rich';
$data['html'] = get_post_embed_html($width, $height, $post);
// Add post thumbnail to response if available.
$thumbnail_id = false;
if (has_post_thumbnail($post->ID)) {
$thumbnail_id = get_post_thumbnail_id($post->ID);
}
if ('attachment' === get_post_type($post)) {
if (wp_attachment_is_image($post)) {
$thumbnail_id = $post->ID;
} else {
if (wp_attachment_is('video', $post)) {
$thumbnail_id = get_post_thumbnail_id($post);
$data['type'] = 'video';
}
}
}
if ($thumbnail_id) {
list($thumbnail_url, $thumbnail_width, $thumbnail_height) = wp_get_attachment_image_src($thumbnail_id, array($width, 99999));
$data['thumbnail_url'] = $thumbnail_url;
$data['thumbnail_width'] = $thumbnail_width;
$data['thumbnail_height'] = $thumbnail_height;
}
return $data;
}
开发者ID:nxty2011,项目名称:WordPress,代码行数:40,代码来源:embed-functions.php
示例4: the_permalink
</ul>
<div id="wp-embed-share-tab-wordpress" class="wp-embed-share-tab" role="tabpanel" aria-labelledby="wp-embed-share-tab-button-wordpress" aria-hidden="false">
<input type="text" value="<?php
the_permalink();
?>
" class="wp-embed-share-input" tabindex="0" readonly/>
<p class="wp-embed-share-description">
<?php
_e('Copy and paste this URL into your WordPress site to embed');
?>
</p>
</div>
<div id="wp-embed-share-tab-html" class="wp-embed-share-tab" role="tabpanel" aria-labelledby="wp-embed-share-tab-button-html" aria-hidden="true">
<textarea class="wp-embed-share-input" tabindex="0" readonly><?php
echo esc_textarea(get_post_embed_html(null, 600, 400));
?>
</textarea>
<p class="wp-embed-share-description">
<?php
_e('Copy and paste this code into your site to embed');
?>
</p>
</div>
</div>
<button type="button" class="wp-embed-share-dialog-close" aria-label="<?php
esc_attr_e('Close sharing dialog');
?>
">
开发者ID:WenZhuang,项目名称:WordPress,代码行数:31,代码来源:embed-template.php
示例5: print_embed_sharing_dialog
/**
* Prints the necessary markup for the embed sharing dialog.
*
* @since 4.4.0
*/
function print_embed_sharing_dialog()
{
if (is_404()) {
return;
}
?>
<div class="wp-embed-share-dialog hidden" role="dialog" aria-label="<?php
esc_attr_e('Sharing options');
?>
">
<div class="wp-embed-share-dialog-content">
<div class="wp-embed-share-dialog-text">
<ul class="wp-embed-share-tabs" role="tablist">
<li class="wp-embed-share-tab-button wp-embed-share-tab-button-wordpress" role="presentation">
<button type="button" role="tab" aria-controls="wp-embed-share-tab-wordpress" aria-selected="true" tabindex="0"><?php
esc_html_e('WordPress Embed');
?>
</button>
</li>
<li class="wp-embed-share-tab-button wp-embed-share-tab-button-html" role="presentation">
<button type="button" role="tab" aria-controls="wp-embed-share-tab-html" aria-selected="false" tabindex="-1"><?php
esc_html_e('HTML Embed');
?>
</button>
</li>
</ul>
<div id="wp-embed-share-tab-wordpress" class="wp-embed-share-tab" role="tabpanel" aria-hidden="false">
<input type="text" value="<?php
the_permalink();
?>
" class="wp-embed-share-input" aria-describedby="wp-embed-share-description-wordpress" tabindex="0" readonly/>
<p class="wp-embed-share-description" id="wp-embed-share-description-wordpress">
<?php
_e('Copy and paste this URL into your WordPress site to embed');
?>
</p>
</div>
<div id="wp-embed-share-tab-html" class="wp-embed-share-tab" role="tabpanel" aria-hidden="true">
<textarea class="wp-embed-share-input" aria-describedby="wp-embed-share-description-html" tabindex="0" readonly><?php
echo esc_textarea(get_post_embed_html(600, 400));
?>
</textarea>
<p class="wp-embed-share-description" id="wp-embed-share-description-html">
<?php
_e('Copy and paste this code into your site to embed');
?>
</p>
</div>
</div>
<button type="button" class="wp-embed-share-dialog-close" aria-label="<?php
esc_attr_e('Close sharing dialog');
?>
">
<span class="dashicons dashicons-no"></span>
</button>
</div>
</div>
<?php
}
开发者ID:ntwb,项目名称:wordpress-travis,代码行数:67,代码来源: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: test_get_post_embed_html
function test_get_post_embed_html()
{
$post_id = self::factory()->post->create();
$title = esc_attr(sprintf(__('“%1$s” — %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
示例8: _e
">
<span class="dashicons dashicons-share"></span>
</button>
</div>
</div>
</div>
<div class="wp-embed-share-dialog hidden">
<div class="wp-embed-share-dialog-content">
<div class="wp-embed-share-dialog-text">
<p class="wp-embed-share-title">
<?php
_e('Copy and paste the HTML code below into your site to embed:', 'oembed-api');
?>
</p>
<input type="text" value="<?php
echo esc_attr(get_post_embed_html(null, 600, 400));
?>
" class="wp-embed-share-input"/>
<p class="wp-embed-share-title">
<?php
_e('If you use WordPress, copy and paste this URL instead:', 'oembed-api');
?>
</p>
<input type="text" value="<?php
the_permalink();
?>
" class="wp-embed-share-input"/>
</div>
<button type="button" class="wp-embed-share-dialog-close"
aria-label="<?php
开发者ID:kraftbj,项目名称:oEmbed-API,代码行数:31,代码来源:template.php
示例9: get_oembed_response_data
/**
* Get the oEmbed data for a given post.
*
* @param WP_Post|int $post Optional. Post object or ID. Defaults to the current post.
* @param int $width The requested width.
* @return array|false Response data on success, false if post doesn't exist.
*/
function get_oembed_response_data($post = null, $width)
{
/**
* Current post object.
*
* @var WP_Post $post
*/
$post = get_post($post);
if (!$post) {
return false;
}
/**
* User object for the post author.
*
* @var WP_User $author
*/
$author = get_userdata($post->post_author);
// If a post doesn't have an author, fall back to the site's name.
$author_name = get_bloginfo('name');
$author_url = get_home_url();
if ($author) {
$author_name = $author->display_name;
$author_url = get_author_posts_url($author->ID, $author->user_nicename);
}
/**
* Filter the allowed minimum width for the oEmbed response.
*
* @param int $width The minimum width. Defaults to 200.
*/
$minwidth = apply_filters('oembed_minwidth', 200);
/**
* Filter the allowed maximum width for the oEmbed response.
*
* @param int $width The maximum width. Defaults to 600.
*/
$maxwidth = apply_filters('oembed_maxwidth', 600);
if ($width < $minwidth) {
$width = $minwidth;
} else {
if ($width > $maxwidth) {
$width = $maxwidth;
}
}
$height = ceil($width / 16 * 9);
$data = array('version' => '1.0', 'provider_name' => get_bloginfo('name'), 'provider_url' => get_home_url(), 'author_name' => $author_name, 'author_url' => $author_url, 'title' => $post->post_title, 'type' => 'rich', 'width' => $width, 'height' => $height, 'html' => get_post_embed_html($post, $width, $height));
// Add post thumbnail to response if available.
$thumbnail_id = false;
if (has_post_thumbnail($post->ID)) {
$thumbnail_id = get_post_thumbnail_id($post->ID);
}
if ('attachment' === get_post_type($post) && wp_attachment_is_image($post->ID)) {
$thumbnail_id = $post->ID;
}
if ($thumbnail_id) {
list($thumbnail_url, $thumbnail_width, $thumbnail_height) = wp_get_attachment_image_src($thumbnail_id, array($width, 99999));
$data['thumbnail_url'] = $thumbnail_url;
$data['thumbnail_width'] = $thumbnail_width;
$data['thumbnail_height'] = $thumbnail_height;
}
/**
* Filters the oEmbed response data.
*
* @param array $data The response data.
* @param WP_Post $post The post object.
*/
return apply_filters('oembed_response_data', $data, $post);
}
开发者ID:kanenas,项目名称:oEmbed-API,代码行数:74,代码来源:functions.php
示例10: get_oembed_response_data
/**
* Fetch our oEmbed response data to return.
*
* A simplified version of {@link get_oembed_response_data()}.
*
* @since 2.6.0
*
* @link http://oembed.com/ View the 'Response parameters' section for more details.
*
* @param array $item Custom oEmbed response data.
* @param int $width The requested width.
* @return array
*/
protected function get_oembed_response_data($item, $width)
{
$data = wp_parse_args($item, array('version' => '1.0', 'provider_name' => get_bloginfo('name'), 'provider_url' => get_home_url(), 'author_name' => get_bloginfo('name'), 'author_url' => get_home_url(), 'title' => ucfirst($this->slug_endpoint), 'type' => 'rich'));
/** This filter is documented in /wp-includes/embed.php */
$min_max_width = apply_filters('oembed_min_max_width', array('min' => 200, 'max' => 600));
$width = min(max($min_max_width['min'], $width), $min_max_width['max']);
$height = max(ceil($width / 16 * 9), 200);
$data['width'] = absint($width);
$data['height'] = absint($height);
// Set 'html' parameter.
if ('video' === $data['type'] || 'rich' === $data['type']) {
// Fake a WP post so we can use get_post_embed_html().
$post = new stdClass();
$post->post_content = $data['content'];
$post->post_title = $data['title'];
$data['html'] = get_post_embed_html($data['width'], $data['height'], $post);
}
// Remove temporary parameters.
unset($data['content']);
return $data;
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:34,代码来源:class-bp-core-oembed-extension.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: update_embed_code
public function update_embed_code()
{
if (!isset($_POST['post_id']) || !$_POST['post_id']) {
return;
}
$post_id = (int) $_POST['post_id'];
$width = (int) $_POST['width'];
$height = (int) $_POST['height'];
echo get_post_embed_html($width, $height, $post_id);
exit;
}
开发者ID:hlashbrooke,项目名称:Easy-Post-Embed-Code,代码行数:11,代码来源:class-easy-post-embed-code.php
示例13: get_oembed_response_data
/**
* Get the oEmbed data for a given post.
*
* @param WP_Post|int $post Optional. Post object or ID. Defaults to the current post.
* @param int $width The requested width.
* @return array|false Response data on success, false if post doesn't exist.
*/
function get_oembed_response_data($post = null, $width)
{
$post = get_post($post);
if (!$post) {
return false;
}
/**
* Filter the allowed minimum width for the oEmbed response.
*
* @param int $width The minimum width. Defaults to 200.
*/
$minwidth = apply_filters('oembed_minwidth', 200);
/**
* Filter the allowed maximum width for the oEmbed response.
*
* @param int $width The maximum width. Defaults to 600.
*/
$maxwidth = apply_filters('oembed_maxwidth', 600);
if ($width < $minwidth) {
$width = $minwidth;
} else {
if ($width > $maxwidth) {
$width = $maxwidth;
}
}
$height = ceil($width / 16 * 9);
if (200 > $height) {
$height = 200;
}
$data = array('version' => '1.0', 'provider_name' => get_bloginfo('name'), 'provider_url' => get_home_url(), 'author_name' => get_bloginfo('name'), 'author_url' => get_home_url(), 'title' => $post->post_title, 'type' => 'rich', 'width' => $width, 'height' => $height, 'html' => get_post_embed_html($post, $width, $height));
/**
* Filter the oEmbed response data.
*
* @param array $data The response data.
* @param WP_Post $post The post object.
*/
return apply_filters('oembed_response_data', $data, $post);
}
开发者ID:rmccue,项目名称:oEmbed-API,代码行数:45,代码来源:functions.php
示例14: update_episode_embed_code
/**
* Update the epiaode embed code via ajax
* @return void
*/
public function update_episode_embed_code()
{
// Make sure we have a valid post ID
if (!isset($_POST['post_id']) || !$_POST['post_id']) {
return;
}
// Get info for embed code
$post_id = (int) $_POST['post_id'];
$width = (int) $_POST['width'];
$height = (int) $_POST['height'];
// Generate embed code
echo get_post_embed_html($width, $height, $post_id);
// Exit after ajax request
exit;
}
开发者ID:0aveRyan,项目名称:Seriously-Simple-Podcasting,代码行数:19,代码来源:class-ssp-admin.php
注:本文中的get_post_embed_html函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论