M_WordPress_Routing

The NextGEN Gallery M WordPress Routing class.

Defined (1)

The class is defined in the following location(s).

/products/photocrati_nextgen/modules/wordpress_routing/module.wordpress_routing.php  
  1. class M_WordPress_Routing extends C_Base_Module 
  2. static $_use_canonical_redirect = TRUE; 
  3. static $_use_old_slugs = TRUE; 
  4.  
  5. function define($id = 'pope-module',  
  6. $name = 'Pope Module',  
  7. $description = '',  
  8. $version = '',  
  9. $uri = '',  
  10. $author = '',  
  11. $author_uri = '',  
  12. $context = FALSE) 
  13. parent::define( 
  14. 'photocrati-wordpress_routing',  
  15. 'WordPress Routing',  
  16. "Integrates the MVC module's routing implementation with WordPress",  
  17. '0.8',  
  18. 'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/',  
  19. 'Imagely',  
  20. 'https://www.imagely.com' 
  21. ); 
  22.  
  23. function _register_adapters() 
  24. $this->get_registry()->add_adapter('I_Router', 'A_WordPress_Base_Url'); 
  25. $this->get_registry()->add_adapter('I_Router', 'A_WordPress_Router'); 
  26. $this->get_registry()->add_adapter('I_Routing_App', 'A_WordPress_Routing_App'); 
  27.  
  28. function _register_hooks() 
  29. add_action('template_redirect', array(&$this, 'restore_request_uri'), 1); 
  30.  
  31. // These two things cause conflicts in NGG. So we temporarily 
  32. // disable them and then reactivate them, if they were used,  
  33. // in the restore_request_uri() method 
  34. if (has_action('template_redirect', 'wp_old_slug_redirect')) { 
  35. remove_action( 'template_redirect', 'wp_old_slug_redirect'); 
  36. if (has_action('template_redirect', 'redirect_canonical')) { 
  37. remove_action( 'template_redirect', 'redirect_canonical'); 
  38.  
  39. /** 
  40. * When WordPress sees a url like http://foobar.com/nggallery/page/2/, it thinks that it is an 
  41. * invalid url. Therefore, we modify the request uri before WordPress parses the request, and then 
  42. * restore the request uri afterwards 
  43. */ 
  44. function restore_request_uri() 
  45. if (isset($_SERVER['ORIG_REQUEST_URI'])) 
  46. $request_uri = $_SERVER['ORIG_REQUEST_URI']; 
  47. $_SERVER['UNENCODED_URL'] = $_SERVER['HTTP_X_ORIGINAL_URL'] = $_SERVER['REQUEST_URI'] = $request_uri; 
  48.  
  49. if (isset($_SERVER['ORIG_PATH_INFO'])) { 
  50. $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; 
  51. // this is the proper behavior but it causes problems with WPML 
  52. else { 
  53. if (self::$_use_old_slugs) wp_old_slug_redirect(); 
  54. if (self::$_use_canonical_redirect) redirect_canonical(); 
  55.  
  56. function get_type_list() 
  57. return array( 
  58. 'A_WordPress_Base_Url' => 'adapter.wordpress_base_url.php',  
  59. 'A_Wordpress_Router' => 'adapter.wordpress_router.php',  
  60. 'A_Wordpress_Routing_App' => 'adapter.wordpress_routing_app.php' 
  61. );