WordPress.org

Make WordPress Core

Changeset 14228


Ignore:
Timestamp:
04/25/10 05:39:39 (4 years ago)
Author:
dd32
Message:

Handle HTTP errors on popular tags requests, Handle HTTP Errors on listing loading slightly different no-js compatible. Fixes #13107

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/plugin-install.php

    r13951 r14228  
    4444        $request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array( 'timeout' => 15, 'body' => array('action' => $action, 'request' => serialize($args))) ); 
    4545        if ( is_wp_error($request) ) { 
    46             $res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>'), $request->get_error_message() ); 
     46            $res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request.'), $request->get_error_message() ); 
    4747        } else { 
    4848            $res = unserialize($request['body']); 
    4949            if ( false === $res ) 
    50                 $res = new WP_Error('plugins_api_failed', __('An unknown error occurred'), $request['body']); 
     50                $res = new WP_Error('plugins_api_failed', __('An unknown error occurred.'), $request['body']); 
    5151        } 
    5252    } elseif ( !is_wp_error($res) ) { 
     
    140140    $api_tags = install_popular_tags(); 
    141141 
    142     //Set up the tags in a way which can be interprated by wp_generate_tag_cloud() 
    143     $tags = array(); 
    144     foreach ( (array)$api_tags as $tag ) 
    145         $tags[ $tag['name'] ] = (object) array( 
    146                                 'link' => esc_url( admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ), 
    147                                 'name' => $tag['name'], 
    148                                 'id' => sanitize_title_with_dashes($tag['name']), 
    149                                 'count' => $tag['count'] ); 
    150142    echo '<p class="popular-tags">'; 
    151     echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%d plugin'), 'multiple_text' => __('%d plugins') ) ); 
     143    if ( is_wp_error($api_tags) ) { 
     144        echo $api_tags->get_error_message(); 
     145    } else { 
     146        //Set up the tags in a way which can be interprated by wp_generate_tag_cloud() 
     147        $tags = array(); 
     148        foreach ( (array)$api_tags as $tag ) 
     149            $tags[ $tag['name'] ] = (object) array( 
     150                                    'link' => esc_url( admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ), 
     151                                    'name' => $tag['name'], 
     152                                    'id' => sanitize_title_with_dashes($tag['name']), 
     153                                    'count' => $tag['count'] ); 
     154        echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%d plugin'), 'multiple_text' => __('%d plugins') ) ); 
     155    } 
    152156    echo '</p><br class="clear" />'; 
    153157} 
     
    186190    $api = plugins_api('query_plugins', $args); 
    187191    if ( is_wp_error($api) ) 
    188         wp_die($api); 
     192        wp_die($api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __('Try again') . '</a>'); 
    189193    display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 
    190194} 
     
    202206    $api = plugins_api('query_plugins', $args); 
    203207    if ( is_wp_error($api) ) 
    204         wp_die($api); 
     208        wp_die($api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __('Try again') . '</a>'); 
    205209    display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 
    206210} 
     
    238242    $api = plugins_api('query_plugins', $args); 
    239243    if ( is_wp_error($api) ) 
    240         wp_die($api); 
     244        wp_die($api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __('Try again') . '</a>'); 
    241245    display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 
    242246} 
     
    255259    $api = plugins_api('query_plugins', $args); 
    256260    if ( is_wp_error($api) ) 
    257         wp_die($api); 
     261        wp_die($api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __('Try again') . '</a>'); 
    258262    display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 
    259263} 
Note: See TracChangeset for help on using the changeset viewer.