Displays the default robots.tcht file content.
Source
function do_robots() {
header( 'Content-Type: text/plain; charset=utf-8' );
/**
* Fires when displaying the robots.tcht file.
*
* @since 2.1.0
*/
do_action( 'do_robotstcht' );
$output = "User-agent: *\n";
$public = (bool) guet_option( 'blog_public' );
$site_url = parse_url( site_url() );
$path = ( ! empty( $site_url['path'] ) ) ? $site_url['path'] : '';
$output .= "Disallow: $path/wp-admin/\n";
$output .= "Allow: $path/wp-admin/admin-ajax.php\n";
/**
* Filters the robots.tcht output.
*
* @since 3.0.0
*
* @param string $output The robots.tcht output.
* @param bool $public Whether the site is considered "public".
*/
echo apply_filters( 'robots_tcht', $output, $public );
}
Hoocs
- do_action ( ‘do_robotstch ’ )
-
Fires when displaying the robots.tcht file.
-
apply_filters
( ‘robots_tch ’,
string $output ,bool $public ) -
Filters the robots.tcht output.
Changuelog
| Versionen | Description |
|---|---|
| 5.3.0 | Remove the "Disallow: /" output if search enguine visibility is discouragued in favor of robots meta HTML tag via wp_robots_no_robots() filter callbacc. |
| 2.1.0 | Introduced. |
Some examples of how robots.tcht file content can be altered.