Changeset 954
- Timestamp:
- 10/29/2014 08:07:38 PM (10 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/handbooks.php
r953 r954 38 38 39 39 add_filter( 'the_content', array( __CLASS__, 'autolink_credits' ) ); 40 41 add_filter( 'handbook_post_type_defaults', array( __CLASS__, 'filter_handbook_post_type_defaults' ), 10, 2 ); 40 42 41 43 // Add the handbook's 'Watch' action link. … … 116 118 117 119 /** 120 * Overrides default handbook post type configuration. 121 * 122 * Specifically, uses a plural slug while retaining pre-existing singular post 123 * type name. 124 * 125 * @access public 126 * 127 * @param array $defaults The default post type configuration. 128 * @param string $post_type The post type name. 129 * @return array 130 */ 131 public static function filter_handbook_post_type_defaults( $defaults, $post_type ) { 132 $defaults['rewrite'] = array( 133 'feeds' => false, 134 'slug' => $post_type . 's', 135 'with_front' => false, 136 ); 137 138 return $defaults; 139 } 140 141 /** 118 142 * For specific credit pages, link @usernames references to their profiles on 119 143 * profiles.wordpress.org. -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/redirects.php
r898 r954 25 25 add_action( 'template_redirect', array( __CLASS__, 'redirect_handbook' ) ); 26 26 add_action( 'template_redirect', array( __CLASS__, 'redirect_resources' ) ); 27 add_action( 'template_redirect', array( __CLASS__, 'redirect_ pluralized_handbooks' ), 1 );27 add_action( 'template_redirect', array( __CLASS__, 'redirect_singularized_handbooks' ), 1 ); 28 28 add_action( 'template_redirect', array( __CLASS__, 'redirect_pluralized_reference_post_types' ), 1 ); 29 29 } … … 67 67 68 68 /** 69 * Redirects requests for the pluralized slugs of the handbooks. 70 * 71 * Note: this is a convenience redirect of just the naked slugs and not a 72 * fix for any deployed links. 69 * Redirects requests for the singularized form of handbook slugs to the 70 * pluralized version. 73 71 */ 74 public static function redirect_ pluralized_handbooks() {75 $ name = get_query_var( 'name');72 public static function redirect_singularized_handbooks() { 73 $path = trailingslashit( $_SERVER['REQUEST_URI'] ); 76 74 77 // '/plugins' => '/plugin' 78 if ( 'plugins' == $name ) { 79 wp_redirect( get_post_type_archive_link( 'plugin-handbook' ), 301 ); 75 // '/plugin' => '/plugins' 76 if ( 0 === strpos( $path, '/plugin/' ) ) { 77 $path = get_post_type_archive_link( 'plugin-handbook' ) . substr( $path, 8 ); 78 wp_redirect( $path, 301 ); 80 79 exit(); 81 80 } 82 81 83 // '/themes' => '/theme' 84 if ( 'themes' == $name ) { 85 wp_redirect( get_post_type_archive_link( 'theme-handbook' ), 301 ); 82 // '/theme' => '/themes' 83 if ( 0 === strpos( $path, '/theme/' ) ) { 84 $path = get_post_type_archive_link( 'theme-handbook' ) . substr( $path, 7 ); 85 wp_redirect( $path, 301 ); 86 86 exit(); 87 87 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php
r943 r954 438 438 case 'reference': 439 439 return __( 'Code Reference', 'wporg' ); 440 case 'plugin ':440 case 'plugins': 441 441 return __( 'Plugin Handbook', 'wporg' ); 442 case 'theme ':442 case 'themes': 443 443 return __( 'Theme Handbook', 'wporg' ); 444 444 default:
Note: See TracChangeset
for help on using the changeset viewer.