is_local_attachment( string $url )
确定附件URI是否是本地的,是否是真正的附件。
Determines whether an attachment URI is local and really an attachment.
说明(Description)
有关此主题函数和类似主题函数的更多信息,请参阅主题开发人员手册中的条件标记文章。
参数(Parameters)
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
$url | (string) | 必需 | 要检查的URL |
返回(Return)
(bool)成功时正确,失败时错误。源码(Source)
/**
* Check if the attachment URI is local one and is really an attachment.
*
* @since 2.0.0
*
* @param string $url URL to check
* @return bool True on success, false on failure.
*/
function is_local_attachment($url) {
if (strpos($url, home_url()) === false)
return false;
if (strpos($url, home_url('/?attachment_id=')) !== false)
return true;
if ( $id = url_to_postid($url) ) {
$post = get_post($id);
if ( 'attachment' == $post->post_type )
return true;
}
return false;
}
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
2.0.0 | wp-includes/post.php:5525 | 1 function | 3 |