get_post_embed_url
函数
get_post_embed_url ( $post = null )
- 参数
-
-
(int|WP_Post)
$post
Optional. Post ID or object. Defaults to the current post.- Required: 否
- Default: null
-
(int|WP_Post)
- 返回值
-
- (string|false) The post embed URL on success, false if the post doesn’t exist.
- 定义位置
-
-
wp-includes/embed.php
, line 407
-
wp-includes/embed.php
- 引入
- 4.4.0
- 弃用
- –
Retrieves the URL to embed a specific post in an iframe.
function get_post_embed_url( $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
}
$embed_url = trailingslashit( get_permalink( $post ) ) . user_trailingslashit( 'embed' );
$path_conflict = get_page_by_path( str_replace( home_url(), '', $embed_url ), OBJECT, get_post_types( array( 'public' => true ) ) );
if ( ! get_option( 'permalink_structure' ) || $path_conflict ) {
$embed_url = add_query_arg( array( 'embed' => 'true' ), get_permalink( $post ) );
}
/**
* Filters the URL to embed a specific post.
*
* @since 4.4.0
*
* @param string $embed_url The post embed URL.
* @param WP_Post $post The corresponding post object.
*/
return sanitize_url( apply_filters( 'post_embed_url', $embed_url, $post ) );
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。