Make WordPress Core

Ticket #39006: 39006.2.diff

File 39006.2.diff, 1.4 KB (added by rmccue, 10 years ago)

Include enum of available languages

  • src/wp-includes/option.php

     
    17981798                'description'  => __( 'A day number of the week that the week should start on.' ),
    17991799        ) );
    18001800
    1801         register_setting( 'general', 'WPLANG', array(
    1802                 'show_in_rest' => array(
    1803                         'name' => 'language',
    1804                 ),
    1805                 'type'         => 'string',
    1806                 'description'  => __( 'WordPress locale code.' ),
    1807                 'default'      => 'en_US',
    1808         ) );
     1801        require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
     1802        $languages = get_available_languages();
     1803        $translations = wp_get_available_translations();
     1804        if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages ) ) {
     1805                $languages[] = WPLANG;
     1806        }
     1807        if ( ! empty( $languages ) || ! empty( $translations ) ) {
     1808                register_setting( 'general', 'WPLANG', array(
     1809                        'show_in_rest' => array(
     1810                                'name' => 'language',
     1811                                'schema' => array(
     1812                                        'format' => 'string',
     1813                                        'enum' => array_merge( $languages, array_values( wp_list_pluck( $translations, 'language' ) ) ),
     1814                                ),
     1815                        ),
     1816                        'type'         => 'string',
     1817                        'description'  => __( 'WordPress locale code.' ),
     1818                        'default'      => 'en_US',
     1819                ) );
     1820        }
    18091821
    18101822        register_setting( 'writing', 'use_smilies', array(
    18111823                'show_in_rest' => true,