Changeset 8920 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/functions.php
- Timestamp:
- 06/05/2019 05:21:36 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/functions.php
r8896 r8920 27 27 remove_action( 'template_redirect', 'wp_old_slug_redirect' ); 28 28 29 add_action( 'template_redirect', 'wporg_themes_ trailing_slashes' );29 add_action( 'template_redirect', 'wporg_themes_canonical_redirects' ); 30 30 31 31 add_theme_support( 'wp4-styles' ); … … 34 34 35 35 /** 36 * Handle the root-level redirect to trailing-slash'd uri which redirect_canonical() usually does. 37 */ 38 function wporg_themes_trailing_slashes() { 36 * Handle redirects which redirect_canonical() usually would (or should) do. 37 */ 38 function wporg_themes_canonical_redirects() { 39 // always include the trailing slash for the Site URL 39 40 if ( '/themes' === $_SERVER['REQUEST_URI'] ) { 40 41 wp_safe_redirect( '/themes/', 301 ); … … 42 43 } 43 44 45 // We don't need any urls such as /themes/index.php/twentyten/ working 44 46 if ( false !== stripos( $_SERVER['REQUEST_URI'], '/index.php' ) ) { 45 47 $url = str_ireplace( '/index.php', '/', $_SERVER['REQUEST_URI'] ); 48 wp_safe_redirect( $url, 301 ); 49 die(); 50 } 51 52 // Uppercase characters in URLs tend to lead to broken JS pages. 53 // This redirects any URLs that match /$slug or /browse/$section and have an uppercase URL to the lower-case variant. 54 if ( 55 preg_match( '![A-Z]!', $_SERVER['REQUEST_URI'] ) && 56 ( 57 preg_match( '!^/themes/[^/]*[A-Z]+!', $_SERVER['REQUEST_URI'] ) || 58 '/themes/browse/' === strtolower( substr( $_SERVER['REQUEST_URI'], 0, 15 ) ) 59 ) 60 ) { 61 $url = trailingslashit( strtolower( remove_query_arg( array_keys( $_GET ), $_SERVER['REQUEST_URI'] ) ) ); 62 wp_safe_redirect( $url, 301 ); 63 die(); 64 } 65 66 // add a trailing slash to /browse/ requests 67 if ( preg_match( '!^/themes/browse/([^/]+)$!i', $_SERVER['REQUEST_URI'] ) ) { 68 $url = trailingslashit( $_SERVER['REQUEST_URI'] ); 46 69 wp_safe_redirect( $url, 301 ); 47 70 die();
Note: See TracChangeset
for help on using the changeset viewer.