Changeset 14700
- Timestamp:
- 03/12/2026 03:30:31 AM (41 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r14667 r14700 1446 1446 if ( is_404() ) { 1447 1447 1448 // [1] => plugins [2] => example-plugin-name [3..] => random(). 1449 $path = explode( '/', trailingslashit( explode( '?', $_SERVER['REQUEST_URI'] )[0] ) ); 1450 1451 if ( 'tags' === $path[2] ) { 1452 if ( isset( $path[3] ) && ! empty( $path[3] ) ) { 1453 wp_safe_redirect( home_url( '/search/' . urlencode( $path[3] ) . '/' ), 301 ); 1448 $path_prefix = wp_parse_url( home_url('/'), PHP_URL_PATH ); 1449 $path = substr( $_SERVER['REQUEST_URI'], strlen( $path_prefix ) ); 1450 // [0] => example-plugin-name [1..] => random(). 1451 $path = explode( '/', trailingslashit( explode( '?', $path )[0] ) ); 1452 $path_base = $path[0]; 1453 1454 if ( 'tags' === $path_base ) { 1455 if ( isset( $path[1] ) && ! empty( $path[1] ) ) { 1456 wp_safe_redirect( home_url( '/search/' . urlencode( $path[1] ) . '/' ), 301 ); 1454 1457 die(); 1455 1458 } else { … … 1460 1463 1461 1464 // The about page is now over at /developers/. 1462 if ( 'about' === $path [2]) {1463 if ( isset( $path[ 3] ) && 'add' == $path[3] ) {1465 if ( 'about' === $path_base ) { 1466 if ( isset( $path[1] ) && 'add' == $path[1] ) { 1464 1467 wp_safe_redirect( home_url( '/developers/add/' ), 301 ); 1465 } elseif ( isset( $path[ 3] ) && 'validator' == $path[3] ) {1468 } elseif ( isset( $path[1] ) && 'validator' == $path[1] ) { 1466 1469 wp_safe_redirect( home_url( '/developers/readme-validator/' ), 301 ); 1467 1470 } else { … … 1472 1475 1473 1476 // Browse 404s. 1474 if ( 'browse' === $path [2]) {1477 if ( 'browse' === $path_base ) { 1475 1478 wp_safe_redirect( home_url( '/' ), 301 ); 1476 1479 die(); … … 1478 1481 1479 1482 // The readme.txt page. 1480 if ( 'readme.txt' === $path [2]) {1483 if ( 'readme.txt' === $path_base ) { 1481 1484 status_header( 200 ); 1482 1485 header( 'Content-type: text/plain' ); … … 1486 1489 1487 1490 // Handle any plugin redirects. 1488 if ( $path [2] && ( $plugin = self::get_plugin_post( $path[2]) ) ) {1491 if ( $path_base && ( $plugin = self::get_plugin_post( $path_base ) ) ) { 1489 1492 $permalink = get_permalink( $plugin->ID ); 1490 1493 if ( parse_url( $permalink, PHP_URL_PATH ) != $_SERVER['REQUEST_URI'] ) { … … 1495 1498 1496 1499 // Otherwise, let's redirect to the search page. 1497 if ( isset( $path [2] ) && ! empty( $path[2]) ) {1498 wp_safe_redirect( home_url( '/search/' . urlencode( $path [2]) . '/' ), 301 );1500 if ( isset( $path_base ) && ! empty( $path_base ) ) { 1501 wp_safe_redirect( home_url( '/search/' . urlencode( $path_base ) . '/' ), 301 ); 1499 1502 die(); 1500 1503 }
Note: See TracChangeset
for help on using the changeset viewer.