is_local_attachment() - WordPress 函数参考中文文档

返回介绍

is_local_attachment()

发布于 2017-09-11 字数1424 浏览 919 评论 0

is_local_attachment( string $url )

Check if the attachment URI is local one and is really an attachment.


描述


参数

$url

(string)
(Required)
URL to check


返回值

(bool) True on success, false on failure.


源代码

File: wp-includes/post.php

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;
}

更新日志

Version 描述
2.0.0 Introduced.

相关函数

Uses

  • wp-includes/link-template.php:
    home_url()
  • wp-includes/post.php:
    get_post()
  • wp-includes/rewrite.php:
    url_to_postid()

Used By

  • wp-includes/comment.php:
    pingback()

User Contributed Notes

上一篇:switch_to_locale()

下一篇:is_main_blog()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!