Skip to content

Commit

Permalink
Allow OpenAI
Browse files Browse the repository at this point in the history
  • Loading branch information
jdevalk committed Nov 1, 2024
1 parent 33fed56 commit 939e9bc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions eco-friendly-robots-txt.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/**
* Plugin Name: Eco-Friendly Robots.txt
* Plugin URI: https://joost.blog/plugins/eco-friendly-robots-txt/
* GitHub Plugin URI: Emilia-Capital/eco-friendly-robots-txt
* Description: Optimizes your site's robots.txt to reduce server load and CO2 footprint by blocking unnecessary crawlers while allowing major search engines and specific tools.
* Version: 0.5
* Author: Joost de Valk
Expand Down
36 changes: 20 additions & 16 deletions src/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ public function modify_robots_txt( $output, $site_public ) {
$robots_txt .= "User-agent: *\n";
$robots_txt .= "Disallow: /\n";

$robots_txt .= "\n# Below are the crawlers that are allowed to crawl this site.\n";
$robots_txt .= "\n# Below are the crawlers that _are_ allowed to crawl this site.\n";
$robots_txt .= "# Below that list, you'll find paths that are blocked, even for them,\n";
$robots_txt .= "# and then paths within those blocked paths that are allowed.\n";
foreach ( $this->allowed_spiders as $crawler ) {
foreach ( $this->allowed_spiders as $crawler => $description ) {
$robots_txt .= "# $description\n";
$robots_txt .= "User-agent: $crawler\n";
$robots_txt .= "Allow: /\n";
foreach ( $this->blocked_paths as $path ) {
Expand Down Expand Up @@ -137,20 +138,23 @@ private function get_allowed_spiders() {
return apply_filters(
'emilia/ecofriendly_robots/allowed_spiders',
[
'Applebot', // Apple.
'ia_archiver', // Archive.org.
'Baiduspider', // Baidu.
'Bingbot', // Bing.
'DuckDuckBot', // DuckDuckGo.
'Googlebot', // Google.
'AdsBot-Google', // Google Ads.
'MediaPartners-Google', // Google AdSense.
'Yandex', // Yandex.
'Slurp', // Yahoo.
'FacebookExternalHit', // Facebook.
'LinkedInBot', // LinkedIn.
'WhatsApp', // WhatsApp.
'Twitterbot', // X.
'AdsBot-Google' => 'Google Ads',
'Applebot' => 'Apple',
'Baiduspider' => 'Baidu',
'Bingbot' => 'Bing',
'ChatGPT-User' => 'ChatGPT user requests',
'DuckDuckBot' => 'DuckDuckGo',
'FacebookExternalHit' => 'Facebook',
'GPTBot' => 'OpenAI models',
'Googlebot' => 'Google',
'LinkedInBot' => 'LinkedIn',
'MediaPartners-Google' => 'Google AdSense',
'OAI-SearchBot' => 'OpenAI Search',
'Slurp' => 'Yahoo',
'Twitterbot' => 'X',
'WhatsApp' => 'WhatsApp',
'Yandex' => 'Yandex',
'ia_archiver' => 'Archive.org',
]
);
}
Expand Down

0 comments on commit 939e9bc

Please sign in to comment.