Changeset 4997
- Timestamp:
- 02/24/2017 12:18:46 AM (8 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/class-plugin.php
r4995 r4997 125 125 GP::$router->prepend( '/projects/wp-plugins/?', array( __NAMESPACE__ . '\Routes\Redirector', 'redirect_index' ) ); 126 126 GP::$router->prepend( '/projects/wp-themes/?', array( __NAMESPACE__ . '\Routes\Redirector', 'redirect_index' ) ); 127 GP::$router->prepend( "/projects/wp/$path/$locale/$dir/glossary", array( __NAMESPACE__ . '\Routes\Redirector', 'redirect_old_glossary' ) ); 127 128 128 129 // Register custom routes. -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-redirector.php
r3002 r4997 3 3 namespace WordPressdotorg\GlotPress\Routes\Routes; 4 4 5 use GP; 5 6 use GP_Route; 7 use GP_Route_Glossary_Entry; 6 8 7 9 /** … … 23 25 $this->redirect( '/' ); 24 26 } 27 28 /** 29 * Redirects previous glossary paths from `/projects/wp/dev/$locale/$slug/glossary` 30 * to `/locale/$locale/$slug/glossary`. 31 * 32 * @param string $project_path Path of a project. 33 * @param string $locale Locale slug. 34 * @param string $slug Slug if a translation set. 35 */ 36 public function redirect_old_glossary( $project_path = '', $locale = '', $slug = '' ) { 37 $project_path = "wp/$project_path"; 38 39 $project = GP::$project->by_path( $project_path ); 40 if ( ! $project ) { 41 $route_glossary_entry = new GP_Route_Glossary_Entry(); 42 return $route_glossary_entry->glossary_entries_get( $project_path, $locale, $slug ); 43 } 44 45 $translation_set = GP::$translation_set->by_project_id_slug_and_locale( $project->id, $slug, $locale ); 46 if ( ! $translation_set ) { 47 $route_glossary_entry = new GP_Route_Glossary_Entry(); 48 return $route_glossary_entry->glossary_entries_get( $project_path, $locale, $slug ); 49 } 50 51 // If the current project has a glossary stop here and load it. 52 $glossary = GP::$glossary->by_set_id( $translation_set->id ); 53 if ( $glossary ) { 54 $route_glossary_entry = new GP_Route_Glossary_Entry(); 55 return $route_glossary_entry->glossary_entries_get( $project_path, $locale, $slug ); 56 } 57 58 // Otherwise redirect to the locale glossary. 59 $locale_glossary_translation_set = GP::$translation_set->by_project_id_slug_and_locale( 0, $slug, $locale ); 60 $locale_glossary = GP::$glossary->by_set_id( $locale_glossary_translation_set->id ); 61 $this->redirect( $locale_glossary->path() ); 62 } 25 63 }
Note: See TracChangeset
for help on using the changeset viewer.