Index: /sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
===================================================================
--- /sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php (revision 7897)
+++ /sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php (revision 7898)
@@ -783,4 +783,11 @@
);
+ // Add x-default to the list of sites.
+ $sites['x-default'] = (object) array(
+ 'locale' => 'x-default',
+ 'hreflang' => 'x-default',
+ 'subdomain' => '',
+ );
+
uasort( $sites, function( $a, $b ) {
return strcasecmp( $a->hreflang, $b->hreflang );
@@ -788,4 +795,14 @@
wp_cache_set( 'local-sites-' . get_post()->post_name, $sites, 'locale-associations', DAY_IN_SECONDS );
+ }
+
+ if ( is_singular() ) {
+ $path = parse_url( get_permalink(), PHP_URL_PATH );
+ if ( get_query_var( 'plugin_advanced' ) ) {
+ $path .= 'advanced/';
+ }
+ } else {
+ // WordPress doesn't have a good way to get the canonical version of non-singular urls.
+ $path = $_SERVER['REQUEST_URI']; // phpcs:ignore
}
@@ -794,5 +811,5 @@
'https://%swordpress.org%s',
$site->subdomain ? "{$site->subdomain}." : '',
- $_SERVER['REQUEST_URI']
+ $path
);
Index: /sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php
===================================================================
--- /sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php (revision 7897)
+++ /sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php (revision 7898)
@@ -1090,4 +1090,8 @@
*/
function wporg_themes_add_hreflang_link_attributes() {
+ if ( is_404() ) {
+ return;
+ }
+
wp_cache_add_global_groups( array( 'locale-associations' ) );
@@ -1136,4 +1140,11 @@
);
+ // Add x-default to the list of sites.
+ $sites['x-default'] = (object) array(
+ 'locale' => 'x-default',
+ 'hreflang' => 'x-default',
+ 'subdomain' => '',
+ );
+
uasort( $sites, function( $a, $b ) {
return strcasecmp( $a->hreflang, $b->hreflang );
@@ -1141,4 +1152,11 @@
wp_cache_set( 'local-sites', $sites, 'locale-associations' );
+ }
+
+ if ( is_singular() ) {
+ $path = parse_url( get_permalink(), PHP_URL_PATH );
+ } else {
+ // WordPress doesn't have a good way to get the canonical version of non-singular urls.
+ $path = $_SERVER['REQUEST_URI']; // phpcs:ignore
}
@@ -1147,5 +1165,5 @@
'https://%swordpress.org%s',
$site->subdomain ? "{$site->subdomain}." : '',
- $_SERVER[ 'REQUEST_URI' ]
+ $path
);
Index: /sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg/functions.php
===================================================================
--- /sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg/functions.php (revision 7897)
+++ /sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg/functions.php (revision 7898)
@@ -191,4 +191,9 @@
*/
function hreflang_link_attributes() {
+ // No hreflangs on 404 pages.
+ if ( is_404() ) {
+ return;
+ }
+
wp_cache_add_global_groups( array( 'locale-associations' ) );
@@ -265,4 +270,11 @@
);
+ // Add x-default to the list of sites.
+ $sites['x-default'] = (object) array(
+ 'locale' => 'x-default',
+ 'hreflang' => 'x-default',
+ 'subdomain' => '',
+ );
+
uasort( $sites, function( $a, $b ) {
return strcasecmp( $a->hreflang, $b->hreflang );
@@ -270,4 +282,11 @@
wp_cache_set( 'local-sites', $sites, 'locale-associations' );
+ }
+
+ if ( is_singular() ) {
+ $path = parse_url( get_permalink(), PHP_URL_PATH );
+ } else {
+ // WordPress doesn't have a good way to get the canonical version of non-singular urls.
+ $path = $_SERVER['REQUEST_URI']; // phpcs:ignore
}
@@ -276,5 +295,5 @@
'https://%swordpress.org%s',
$site->subdomain ? "{$site->subdomain}." : '',
- $_SERVER['REQUEST_URI'] // phpcs:ignore
+ $path
);