diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index bece4e7914..951020d387 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -1582,6 +1582,8 @@ function do_feed_atom( $for_comments ) {
* Displays the default robots.txt file content.
*
* @since 2.1.0
+ * @since 5.3.0 Remove the "Disallow: /" output if search engine visiblity is
+ * discouraged in favor of robots meta HTML tag in wp_no_robots().
*/
function do_robots() {
header( 'Content-Type: text/plain; charset=utf-8' );
@@ -1595,14 +1597,11 @@ function do_robots() {
$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 .= "Allow: $path/wp-admin/admin-ajax.php\n";
- }
+
+ $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.txt output.
diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php
index d6bcc019b1..614853860f 100644
--- a/wp-includes/general-template.php
+++ b/wp-includes/general-template.php
@@ -2986,12 +2986,18 @@ function noindex() {
* Display a noindex meta tag.
*
* Outputs a noindex meta tag that tells web robots not to index the page content.
- * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_no_robots' );
+ * Typical usage is as a {@see 'wp_head'} callback. add_action( 'wp_head', 'wp_no_robots' );
*
* @since 3.3.0
+ * @since 5.3.0 Echo "noindex,nofollow" if search engine visibility is discouraged.
*/
function wp_no_robots() {
- echo "\n";
+ if ( get_option( 'blog_public' ) ) {
+ echo "\n";
+ return;
+ }
+
+ echo "\n";
}
/**
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 8b6f0ac276..575b3f8220 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
-$wp_version = '5.3-alpha-45927';
+$wp_version = '5.3-alpha-45928';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.