// ============================================ // ROBOTS.TXT - Allow AI Bots + Add Sitemap // ============================================ function patnetpro_robots_txt( $output, $public ) { $sitemap_url = home_url('/sitemap.xml'); $robots = "User-agent: *\n"; $robots .= "Disallow: /wp-admin/\n"; $robots .= "Allow: /wp-admin/admin-ajax.php\n\n"; $robots .= "# Allow AI Crawlers\n"; $robots .= "User-agent: GPTBot\n"; $robots .= "Allow: /\n\n"; $robots .= "User-agent: ChatGPT-User\n"; $robots .= "Allow: /\n\n"; $robots .= "User-agent: PerplexityBot\n"; $robots .= "Allow: /\n\n"; $robots .= "User-agent: Claude-Web\n"; $robots .= "Allow: /\n\n"; $robots .= "User-agent: ClaudeBot\n"; $robots .= "Allow: /\n\n"; $robots .= "User-agent: Gemini-Web-Crawler\n"; $robots .= "Allow: /\n\n"; $robots .= "User-agent: Bingbot\n"; $robots .= "Allow: /\n\n"; $robots .= "# Sitemap\n"; $robots .= "Sitemap: " . $sitemap_url . "\n"; return $robots; } add_filter( 'robots_txt', 'patnetpro_robots_txt', 10, 2 ); // Delete physical robots.txt to allow WordPress to manage it // Write robots.txt directly to override physical file add_action('init', function() { $sitemap_url = home_url('/sitemap.xml'); $robots_content = "User-agent: *\nDisallow: /wp-admin/\nAllow: /wp-admin/admin-ajax.php\n\n# Allow AI Crawlers\nUser-agent: GPTBot\nAllow: /\n\nUser-agent: ChatGPT-User\nAllow: /\n\nUser-agent: PerplexityBot\nAllow: /\n\nUser-agent: Claude-Web\nAllow: /\n\nUser-agent: ClaudeBot\nAllow: /\n\nUser-agent: Gemini-Web-Crawler\nAllow: /\n\nUser-agent: Bingbot\nAllow: /\n\n# Sitemap\nSitemap: " . $sitemap_url . "\n"; $robots_file = ABSPATH . 'robots.txt'; @file_put_contents($robots_file, $robots_content); }); // ===== ADMIN TOOL: Write robots.txt ===== add_action('admin_menu', function() { add_management_page('כתוב robots.txt', 'כתוב robots.txt', 'manage_options', 'write-robots', 'patnetpro_write_robots_page'); }); function patnetpro_write_robots_page() { if (isset($_POST['write_robots']) && current_user_can('manage_options')) { check_admin_referer('write_robots_nonce'); $sitemap_url = home_url('/sitemap.xml'); $content = "User-agent: *\nDisallow: /wp-admin/\nAllow: /wp-admin/admin-ajax.php\n\n# Allow AI Crawlers\nUser-agent: GPTBot\nAllow: /\n\nUser-agent: ChatGPT-User\nAllow: /\n\nUser-agent: PerplexityBot\nAllow: /\n\nUser-agent: Claude-Web\nAllow: /\n\nUser-agent: ClaudeBot\nAllow: /\n\nUser-agent: Gemini-Web-Crawler\nAllow: /\n\nUser-agent: Bingbot\nAllow: /\n\n# Sitemap\nSitemap: {$sitemap_url}\n"; $result = file_put_contents(ABSPATH . 'robots.txt', $content); if ($result !== false) { echo '
robots.txt נכתב בהצלחה!
שגיאה בכתיבת הקובץ.