Skip to content

Commit

Permalink
Beautify output of robots.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
rilwis committed May 10, 2024
1 parent 737cc3c commit c5ba7f9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/MetaTags/Robots.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,13 @@ public function set_link_nofollow( $link ) {
}

public function add_to_robots_txt( string $output ): string {
$content = [];
$content[] = 'Disallow: /?s=';
$content[] = 'Disallow: /page/*/?s=';
$content[] = 'Disallow: /search/';
$content = "Disallow: /?s=\n";
$content .= "Disallow: /page/*/?s=\n";
$content .= "Disallow: /search/\n";

$content = implode( "\n", $content );
$content = apply_filters( 'slim_seo_robots_txt', $content );
$output = str_replace( "Allow:", "{$content}Allow:", $output );

return $output . $content . "\n";
return $output;
}
}

0 comments on commit c5ba7f9

Please sign in to comment.