Changeset 3447843
- Timestamp:
- 01/27/2026 12:29:16 PM (3 weeks ago)
- File:
-
- 1 edited
-
ezy-ai/trunk/includes/class-ezy-ai-robots.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ezy-ai/trunk/includes/class-ezy-ai-robots.php
r3445452 r3447843 80 80 81 81 if (!$robots_content) { 82 global $wp_query; 83 unset($wp_query->query_vars['ezy_robots_txt']); 84 $wp_query->is_robots = false; 82 85 return; 83 86 } … … 189 192 190 193 $this->cleanup_competing_robots_files(); 194 195 $this->ensure_rewrite_rule(); 191 196 192 197 return true; … … 194 199 195 200 public static function activate() { 196 add_rewrite_rule('^robots\.txt$', 'index.php?ezy_robots_txt=1', 'top'); 201 $robots_content = get_option(self::ROBOTS_OPTION); 202 if (!empty($robots_content)) { 203 add_rewrite_rule('^robots\.txt$', 'index.php?ezy_robots_txt=1', 'top'); 204 flush_rewrite_rules(false); 205 } 206 } 207 208 public static function deactivate() { 197 209 flush_rewrite_rules(false); 198 210 } 199 200 public static function deactivate() { 211 212 private function ensure_rewrite_rule() { 213 global $wp_rewrite; 214 $rules = get_option('rewrite_rules'); 215 $rule_key = '^robots\.txt$'; 216 217 if (!isset($rules[$rule_key])) { 218 add_rewrite_rule('^robots\.txt$', 'index.php?ezy_robots_txt=1', 'top'); 219 flush_rewrite_rules(false); 220 } 221 } 222 223 private function remove_rewrite_rule() { 224 flush_rewrite_rules(false); 201 225 } 202 226 … … 204 228 delete_option(self::ROBOTS_OPTION); 205 229 delete_option(self::ROBOTS_UPDATED_OPTION); 230 $this->remove_rewrite_rule(); 206 231 return true; 207 232 }
Note: See TracChangeset
for help on using the changeset viewer.