WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/21/2013 04:07:34 AM (8 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.