Make WordPress Core

Changeset 25536


Ignore:
Timestamp:
09/21/2013 04:07:34 AM (11 years ago)
Author:
nacin
Message:

Accept and store translations data from the plugin and theme update check endpoints.

Send site locale. Rename wp_get_installed_language_data() to wp_get_installed_translations().

see #18200.

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

Legend:

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

    r25520 r25536  
    628628
    629629/**
    630  * Get installed language data.
     630 * Get installed translations.
    631631 *
    632632 * Looks in the wp-content/languages directory for translations of
     
    638638 * @return array Array of language data.
    639639 */
    640 function wp_get_installed_language_data( $type ) {
     640function wp_get_installed_translations( $type ) {
    641641    if ( $type !== 'themes' && $type !== 'plugins' )
    642642        return array();
  • trunk/src/wp-includes/update.php

    r25520 r25536  
    147147
    148148    $plugins = get_plugins();
    149     $languages = wp_get_installed_language_data( 'plugins' );
     149    $translations = wp_get_installed_translations( 'plugins' );
    150150
    151151    $active  = get_option( 'active_plugins', array() );
     
    203203    $options = array(
    204204        'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
    205         'body' => array( 'plugins' => json_encode( $to_send ), 'languages' => json_encode( $languages ) ),
     205        'body' => array(
     206            'plugins'      => json_encode( $to_send ),
     207            'translations' => json_encode( $translations ),
     208            'locale'       => json_encode( array( get_locale() ) ), // @todo filter.
     209        ),
    206210        'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
    207211    );
     
    216220        return false;
    217221
    218     $response = json_decode( wp_remote_retrieve_body( $raw_response ) );
    219 
    220     if ( is_object( $response ) )
    221         $new_option->response = (array) $response->plugins;
    222     else
     222    $response = json_decode( wp_remote_retrieve_body( $raw_response ), true );
     223    foreach ( $response['plugins'] as &$plugin ) {
     224        $plugin = (object) $plugin;
     225    }
     226    unset( $plugin );
     227
     228    if ( is_array( $response ) ) {
     229        $new_option->response = $response['plugins'];
     230        $new_option->translations = $response['translations'];
     231    } else {
    223232        $new_option->response = array();
     233    }
    224234
    225235    set_site_transient( 'update_plugins', $new_option );
     
    246256
    247257    $installed_themes = wp_get_themes();
    248     $languages = wp_get_installed_language_data( 'themes' );
     258    $translations = wp_get_installed_translations( 'themes' );
    249259
    250260    $last_update = get_site_transient( 'update_themes' );
     
    315325    $options = array(
    316326        'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
    317         'body'          => array( 'themes' => json_encode( $request ), 'languages' => json_encode( $languages ) ),
     327        'body' => array(
     328            'themes'       => json_encode( $request ),
     329            'translations' => json_encode( $translations ),
     330            'locale'       => json_encode( array( get_locale() ) ), // @todo filter.
     331        ),
    318332        'user-agent'    => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
    319333    );
     
    334348    $response = json_decode( wp_remote_retrieve_body( $raw_response ), true );
    335349
    336     if ( is_array( $response ) )
    337         $new_update->response = $response['themes'];
     350    if ( is_array( $response ) ) {
     351        $new_update->response     = $response['themes'];
     352        $new_update->translations = $response['translations'];
     353    }
    338354
    339355    set_site_transient( 'update_themes', $new_update );
Note: See TracChangeset for help on using the changeset viewer.