Changeset 9070
- Timestamp:
- 07/24/2019 03:44:31 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/class-plugin.php
r8553 r9070 46 46 add_filter( 'cron_schedules', [ $this, 'register_cron_schedules' ] ); 47 47 add_action( 'init', [ $this, 'register_cron_events' ] ); 48 add_action( 'init', [ $this, 'respect_robots_txt' ], 9 ); 48 49 add_action( 'wporg_translate_update_existing_locales_cache', [ $this, 'update_existing_locales_cache' ] ); 49 50 add_action( 'wporg_translate_update_translation_status_cache', [ $this, 'update_translation_status_cache' ] ); 50 51 add_action( 'wporg_translate_update_contributors_count_cache', [ $this, 'update_contributors_count_cache' ] ); 52 } 53 54 /** 55 * The GlotPress match-all route is prepended early before a lot of rules, including the robots.txt rules. 56 * 57 * gp_rewrite_rules() is called from gp_init() on init at priority 10, we need to insert before that. 58 */ 59 function respect_robots_txt() { 60 // ?robots=1 is here to trigger `is_robots()`, which prevents canonical. 61 // ?gp_route=robots.txt is here, as GlotPress ultimately is the router for the request. 62 add_rewrite_rule( '^robots\.txt$', 'index.php?robots=1&gp_route=robots.txt', 'top' ); 51 63 } 52 64 … … 79 91 * Adds: 80 92 * - / 93 * - /robots.txt 81 94 * - /locale/$locale 82 95 * - /locale/$locale/$path … … 156 169 GP::$router->prepend( "/projects/wp-themes/$project/language-packs", array( __NAMESPACE__ . '\Routes\WP_Themes', 'get_theme_language_packs' ) ); 157 170 171 // Add Robots.txt support 172 GP::$router->prepend( '/robots\.txt', 'do_robots' ); 173 158 174 if ( defined( 'TRANSLATE_MAINTENANCE_ACTIVE' ) ) { 159 175 GP::$router->prepend( '.*', array( __NAMESPACE__ . '\Routes\Maintenance', 'show_maintenance_message' ) );
Note: See TracChangeset
for help on using the changeset viewer.