do_robots()
do_robots() 显示默认值robots.txt文件文件内容。Displays the default …
do_robots()
显示默认值robots.txt文件文件内容。
Displays the default robots.txt file content.
显示默认值robots.txt文件文件内容。
Displays the default robots.txt file content.
目录锚点:#返回#源码
返回(Return)
无返回值
源码(Source)
/**
* Display the robots.txt file content.
*
* The echo content should be with usage of the permalinks or for creating the
* robots.txt file.
*
* @since 2.1.0
*/
function do_robots() {
header( 'Content-Type: text/plain; charset=utf-8' );
/**
* Fires when displaying the robots.txt file.
*
* @since 2.1.0
*/
do_action( 'do_robotstxt' );
$output = "User-agent: *
";
$public = get_option( 'blog_public' );
if ( '0' == $public ) {
$output .= "Disallow: /
";
} else {
$site_url = parse_url( site_url() );
$path = ( !empty( $site_url['path'] ) ) ? $site_url['path'] : '';
$output .= "Disallow: $path/wp-admin/
";
}
/**
* Filter the robots.txt output.
*
* @since 3.0.0
*
* @param string $output Robots.txt output.
* @param bool $public Whether the site is considered "public".
*/
echo apply_filters( 'robots_txt', $output, $public );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 5.3.0 | wp-includes/functions.php:1628 | 0 | 6 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!