Make WordPress Core

Ticket #28303: 28303.patch

File 28303.patch, 4.9 KB (added by ocean90, 9 years ago)
  • src/wp-admin/customize.php

     
    8787if ( is_rtl() ) {
    8888        $body_class .= ' rtl';
    8989}
    90 $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
    9190
     91$language_code = wp_get_language_code_of_locale();
     92$body_class .= ' locale-' . sanitize_html_class( strtolower( $language_code ) );
     93
    9294if ( $wp_customize->is_theme_active() ) {
    9395        $document_title_tmpl = _x( 'Customize: %s', 'Placeholder is the document title from the preview' );
    9496} else {
  • src/wp-admin/includes/class-wp-press-this.php

     
    12781278        $admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( $wp_version ) );
    12791279        $admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', $wp_version ) );
    12801280        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
    1281         $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
     1281        $language_code = wp_get_language_code_of_locale();
     1282        $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( $language_code ) );
    12821283
    12831284        /** This filter is documented in wp-admin/admin-header.php */
    12841285        $admin_body_classes = apply_filters( 'admin_body_class', '' );
  • src/wp-admin/includes/template.php

     
    16471647/** This action is documented in wp-admin/admin-header.php */
    16481648do_action( 'admin_head' );
    16491649
    1650 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
     1650$language_code = wp_get_language_code_of_locale();
     1651$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( $language_code ) );
    16511652
    16521653if ( is_rtl() )
    16531654        $admin_body_class .= ' rtl';
  • src/wp-includes/class-wp-editor.php

     
    628628                                }
    629629                        }
    630630
    631                         $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
     631                        $language_code = wp_get_language_code_of_locale();
     632                        $body_class .= ' locale-' . sanitize_html_class( strtolower( $language_code ) );
    632633
    633634                        if ( !empty($set['tinymce']['body_class']) ) {
    634635                                $body_class .= ' ' . $set['tinymce']['body_class'];
  • src/wp-includes/general-template.php

     
    665665                        $output = $wp_version;
    666666                        break;
    667667                case 'language':
    668                         $output = get_locale();
    669                         $output = str_replace('_', '-', $output);
     668                        $output = wp_get_language_code_of_locale();
    670669                        break;
    671670                case 'text_direction':
    672671                        _deprecated_argument( __FUNCTION__, '2.2', sprintf(
  • src/wp-includes/l10n.php

     
    820820                if ( substr( $file, -3 ) !== '.po' ) {
    821821                        continue;
    822822                }
    823                 if ( ! preg_match( '/(?:(.+)-)?([A-Za-z_]{2,6}).po/', $file, $match ) ) {
     823                if ( ! preg_match( '/(?:(.+)-)?([a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z]+)?).po/', $file, $match ) ) {
    824824                        continue;
    825825                }
    826826                if ( ! in_array( substr( $file, 0, -3 ) . '.mo', $files ) )  {
     
    859859}
    860860
    861861/**
     862 * Extract the language code from a locale.
     863 *
     864 * @since 4.3.0
     865 *
     866 * @param string $locale Optional. Locale to parse.
     867 * @return string Language code.
     868 */
     869function wp_get_language_code_of_locale( $locale = '' ) {
     870        if ( ! $locale ) {
     871                $locale = get_locale();
     872        }
     873
     874        preg_match( '/^([a-z]{2,3}(_[A-Z]{2})?)/', $locale, $matches );
     875        if ( $matches && $matches[1] ) {
     876                return str_replace( '_', '-', $matches[1] );
     877        }
     878
     879        return '';
     880}
     881
     882/**
    862883 * Language selector.
    863884 *
    864885 * @since 4.0.0
  • src/wp-login.php

     
    133133                if ( 'success' ===  $interim_login )
    134134                        $classes[] = 'interim-login-success';
    135135        }
    136         $classes[] =' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
     136        $language_code = wp_get_language_code_of_locale();
     137        $classes[] =' locale-' . sanitize_html_class( strtolower( $language_code ) );
    137138
    138139        /**
    139140         * Filter the login page body classes.