Advertisements

do_robots

Definition:
function do_robots() {}

Display the robots.txt file content.
The echo content should be with usage of the permalinks or for creating the robots.txt file.

Defined filters

  • robots_txt
    apply_filters('robots_txt', $output, $public)

Defined actions

  • do_robotstxt
    do_action( 'do_robotstxt' );

Source code

function do_robots() {

	header( 'Content-Type: text/plain; charset=utf-8' );



	do_action( 'do_robotstxt' );



	$output = "User-agent: *\n";

	$public = get_option( 'blog_public' );

	if ( '0' == $public ) {

		$output .= "Disallow: /\n";

	} else {

		$site_url = parse_url( site_url() );

		$path = ( !empty( $site_url['path'] ) ) ? $site_url['path'] : '';

		$output .= "Disallow: $path/wp-admin/\n";

		$output .= "Disallow: $path/wp-includes/\n";

	}



	echo apply_filters('robots_txt', $output, $public);

}

968

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: