WordPress.org

Make WordPress Core

Changeset 25652


Ignore:
Timestamp:
09/30/2013 07:46:15 PM (8 years ago)
Author:
nacin
Message:

Send back core translation information to the API. Update wp_get_installed_translations() to work with core translations. see #18200.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/l10n.php

    r25586 r25652  
    746746 * @since 3.7.0
    747747 *
    748  * @param string $type What to search for. Accepts 'plugins', 'themes'.
     748 * @param string $type What to search for. Accepts 'plugins', 'themes', 'core'.
    749749 * @return array Array of language data.
    750750 */
    751751function wp_get_installed_translations( $type ) {
    752     if ( $type !== 'themes' && $type !== 'plugins' )
     752    if ( $type !== 'themes' && $type !== 'plugins' && $type !== 'core' )
    753753        return array();
    754754
    755     if ( ! is_dir( WP_LANG_DIR ) || ! is_dir( WP_LANG_DIR . "/$type" ) )
     755    $dir = 'core' === $type ? '' : "/$type";
     756
     757    if ( ! is_dir( WP_LANG_DIR ) )
    756758        return array();
    757759
    758     $files = scandir( WP_LANG_DIR . "/$type" );
     760    if ( $dir && ! is_dir( WP_LANG_DIR . $dir ) )
     761        return array();
     762
     763    $files = scandir( WP_LANG_DIR . $dir );
    759764    if ( ! $files )
    760765        return array();
     
    767772        if ( substr( $file, -3 ) !== '.po' )
    768773            continue;
    769         if ( ! preg_match( '/(.*)-([A-Za-z_]{2,6}).po/', $file, $match ) )
     774        if ( ! preg_match( '/(?:(.+)-)?([A-Za-z_]{2,6}).po/', $file, $match ) )
    770775            continue;
    771776
    772777        list( , $textdomain, $language ) = $match;
    773         $language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "/$type/$file" );
     778        if ( '' === $textdomain )
     779            $textdomain = 'default';
     780        $language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "$dir/$file" );
    774781    }
    775782    return $language_data;
  • trunk/src/wp-includes/update.php

    r25649 r25652  
    2929
    3030    $current = get_site_transient( 'update_core' );
     31    $translations = wp_get_installed_translations( 'core' );
     32
    3133    if ( ! is_object($current) ) {
    3234        $current = new stdClass;
     
    8688            'wp_install' => $wp_install,
    8789            'wp_blog' => home_url( '/' )
    88         )
     90        ),
     91        'body' => array(
     92            'translations' => json_encode( $translations ),
     93        ),
    8994    );
    9095
    91     $response = wp_remote_get($url, $options);
     96    $response = wp_remote_post( $url, $options );
    9297
    9398    if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
     
    120125    $updates->last_checked = time();
    121126    $updates->version_checked = $wp_version;
     127
     128    if ( isset( $body['translations'] ) )
     129        $updates->translations = $body['translations'];
     130
    122131    set_site_transient( 'update_core',  $updates);
    123132}
Note: See TracChangeset for help on using the changeset viewer.