user_agents as $user_agent) {
$output .= "User-agent: $user_agent\n";
$output .= "Disallow: /\n\n";
}
// Add end comment for the block
$output .= "# ---------------------------\n# END AI Scrape Protect block\n";
return $output;
}
}
class AISP_Add_Meta_Tags {
public function __construct() {
add_action('wp_head', [$this, 'add_ai_meta_tags'], 1);
}
public function add_ai_meta_tags() {
echo "\n\n\n";
// Prevents OpenAI's GPTBot from accessing and using the content for AI model training.
echo "\n";
echo '' . "\n";
// Instructs general AI bots to avoid indexing, summarizing, or using the content for AI purposes.
echo "\n";
echo '' . "\n";
// Prevents Bing's bot from using the content for AI-related purposes, such as training language models.
echo "\n";
echo '' . "\n";
// Adds a future-proof tag to prohibit AI training.
echo "\n";
echo '' . "\n";
// Prevents AI use of images.
echo "\n";
echo '' . "\n";
// Adds a dedicated meta tag for CCBot.
echo "\n";
echo '' . "\n\n";
echo "\n";
}
}
// Add icons to the WordPress Admin Bar
class AISP_Admin_Bar_Icons {
public function __construct() {
// Hook into WordPress admin bar to display icons
add_action('admin_bar_menu', [$this, 'add_admin_bar_icons'], 100);
}
public function add_admin_bar_icons($admin_bar) {
// Ensure the function is loaded and available
if ( !function_exists('is_plugin_active') ) {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
}
// Check if the plugin is active
$is_plugin_active = is_plugin_active('ai-scrape-protect/ai-scrape-protect.php');
// Define the icon URLs based on the plugin state
$icon_url = $is_plugin_active ? plugin_dir_url(__FILE__) . 'images/ai-scrape-protect-active.png' : '';
// Debug: Output for testing
// error_log('Plugin active: ' . ($is_plugin_active ? 'Yes' : 'No'));
// Add an item to the admin bar with the corresponding icon
$admin_bar->add_node([
'id' => 'ai-scrape-protect-icon',
'title' => '
',
'href' => 'https://codesurf.eu/wordpress-ai-scrape-protect-plugin/',
'meta' => [
'target' => '_blank'
]
]);
}
}
// Initialize all classes
new AISP_Manage_Robots_Txt();
new AISP_Add_Meta_Tags();
new AISP_Admin_Bar_Icons();