Making WordPress.org


Ignore:
Timestamp:
10/15/2019 06:53:44 AM (5 years ago)
Author:
dd32
Message:

WordPress.org, Plugin Directory, and Theme Directory: Sync the hreflang tag implementations. This prevents linking to non-existent sites.

Fixes #4713.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php

    r8913 r9180  
    11051105    wp_cache_add_global_groups( array( 'locale-associations' ) );
    11061106
     1107    // Google doesn't have support for a whole lot of languages and throws errors about it,
     1108    // so we exclude them, as we're otherwise outputting data that isn't used at all.
     1109    $unsupported_languages = array(
     1110        'arq',
     1111        'art',
     1112        'art-xemoji',
     1113        'ary',
     1114        'ast',
     1115        'az-ir',
     1116        'azb',
     1117        'bcc',
     1118        'ff-sn',
     1119        'frp',
     1120        'fuc',
     1121        'fur',
     1122        'haz',
     1123        'ido',
     1124        'io',
     1125        'kab',
     1126        'li',
     1127        'li-nl',
     1128        'lmo',
     1129        'me',
     1130        'me-me',
     1131        'rhg',
     1132        'rup',
     1133        'sah',
     1134        'sc-it',
     1135        'scn',
     1136        'skr',
     1137        'srd',
     1138        'szl',
     1139        'tah',
     1140        'twd',
     1141        'ty-tj',
     1142        'tzm',
     1143    );
     1144
     1145    // WARNING: for any changes below, check other uses of the `locale-assosciations` group as there's shared cache keys in use.
    11071146    if ( false === ( $sites = wp_cache_get( 'local-sites', 'locale-associations' ) ) ) {
    11081147        global $wpdb;
     
    11151154        require_once GLOTPRESS_LOCALES_PATH;
    11161155
    1117         foreach ( $sites as $site ) {
     1156        foreach ( $sites as $key => $site ) {
    11181157            $gp_locale = GP_Locales::by_field( 'wp_locale', $site->locale );
    11191158            if ( ! $gp_locale ) {
    1120                 unset( $sites[ $site->locale ] );
     1159                unset( $sites[ $key ] );
     1160                continue;
     1161            }
     1162
     1163            // Skip non-existing subdomains, e.g. 'de_CH_informal'.
     1164            if ( false !== strpos( $site->subdomain, '_' ) ) {
     1165                unset( $sites[ $key ] );
     1166                continue;
     1167            }
     1168
     1169            // Skip unsupported locales.
     1170            if ( in_array( $gp_locale->slug, $unsupported_languages ) ) {
     1171                unset( $sites[ $key ] );
    11211172                continue;
    11221173            }
     
    11351186            }
    11361187
    1137             if ( $hreflang && 'art' !== $hreflang ) {
    1138                 $sites[ $site->locale ]->hreflang = strtolower( $hreflang );
     1188            if ( $hreflang ) {
     1189                $sites[ $key ]->hreflang = strtolower( $hreflang );
    11391190            } else {
    1140                 unset( $sites[ $site->locale ] );
     1191                unset( $sites[ $key ] );
    11411192            }
    11421193        }
Note: See TracChangeset for help on using the changeset viewer.