Changeset 898
- Timestamp:
- 10/10/2014 10:24:46 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/redirects.php
r897 r898 26 26 add_action( 'template_redirect', array( __CLASS__, 'redirect_resources' ) ); 27 27 add_action( 'template_redirect', array( __CLASS__, 'redirect_pluralized_handbooks' ), 1 ); 28 add_action( 'template_redirect', array( __CLASS__, 'redirect_pluralized_reference_post_types' ), 1 ); 28 29 } 29 30 … … 87 88 } 88 89 90 /** 91 * Redirects requests for the pluralized slugs of the code reference parsed 92 * post types. 93 * 94 * Note: this is a convenience redirect and not a fix for any officially 95 * deployed links. 96 */ 97 public static function redirect_pluralized_reference_post_types() { 98 $path = trailingslashit( $_SERVER['REQUEST_URI'] ); 99 100 $post_types = array( 101 'class' => 'classes', 102 'function' => 'functions', 103 'hook' => 'hooks', 104 'method' => 'methods', 105 ); 106 107 // '/reference/$singular(/*)?' => '/reference/$plural(/*)?' 108 foreach ( $post_types as $post_type_slug_singular => $post_type_slug_plural ) { 109 if ( 0 === stripos( $path, "/reference/{$post_type_slug_singular}/" ) ) { 110 $path = "/reference/{$post_type_slug_plural}/" . substr( $path, strlen( "/reference/{$post_type_slug_singular}/" ) ); 111 wp_redirect( $path, 301 ); 112 exit(); 113 } 114 } 115 } 116 89 117 } // DevHub_Redirects 90 118
Note: See TracChangeset
for help on using the changeset viewer.