do_feed_rss2()

描述

显示robot.txt文件内容。

回应的内容应该用于永久链接或用于创建robot.txt文件。

用法

<?php do_robots() ?>

注意

使用到 do_action() 调用 ‘do_robotstxt’ hook for displaying robots.txt rules.

历史

添加于 版本: 2.1.0

源文件

do_robots() 函数的代码位于 wp-includes/functions.php.

/**
* 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 );

}
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索