Last active
September 3, 2024 09:47
-
-
Save Zodiac1978/bb9a7192363864c3e2a73f74e7300542 to your computer and use it in GitHub Desktop.
Add line in robots.txt to disallow GPTBot. (WordPress plugin)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Disallow GPTBot | |
* Description: Add line in robots.txt to disallow GPTBot. | |
* Plugin URI: https://torstenlandsiedel.de | |
* Version: 1.0 | |
* Author: Torsten Landsiedel | |
* Author URI: http://torstenlandsiedel.de | |
* Licence: GPL 2 | |
* License URI: http://opensource.org/licenses/GPL-2.0 | |
* | |
* @package SEO/Must-Use | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} // Exit if accessed directly. | |
/** | |
* Add Disallow for GPTBot | |
* See: https://platform.openai.com/docs/gptbot | |
* More: https://core.trac.wordpress.org/ticket/60805 | |
* | |
* @param string $output The robots.txt output. | |
* @return string The modified robots.txt output. | |
*/ | |
function disallow_gptbot( $output ) { | |
$output .= "\nUser-agent: GPTBot\nDisallow: *\n"; | |
return $output; | |
} | |
add_filter( 'robots_txt', 'disallow_gptbot', 10 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment