Ticket #6015: 6015.6.diff
| File 6015.6.diff, 5.2 KB (added by DD32, 4 years ago) |
|---|
-
wp-admin/includes/plugin-install.php
37 37 38 38 if ( ! $res ) { 39 39 $request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array( 'body' => array('action' => $action, 'request' => serialize($args))) ); 40 $res = unserialize($request['body']); 41 if ( ! $res ) 42 $res = new WP_Error('plugins_api_failed', __('An unknown error occured'), $request['body']); 40 if ( is_wp_error($request) ) { 41 $res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occured during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>'), $request->get_error_message() ); 42 } else { 43 $res = unserialize($request['body']); 44 if ( ! $res ) 45 $res = new WP_Error('plugins_api_failed', __('An unknown error occured'), $request['body']); 46 } 43 47 } 44 48 45 49 return apply_filters('plugins_api_result', $res, $action, $args); … … 62 66 63 67 $tags = plugins_api('hot_tags', $args); 64 68 69 if ( is_wp_error($tags) ) 70 return $tags; 71 65 72 $cache = (object) array('timeout' => time(), 'cached' => $tags); 66 73 67 74 update_option('wporg_popular_tags', $cache); … … 100 107 101 108 $api = plugins_api('query_plugins', $args); 102 109 110 if ( is_wp_error($api) ) 111 wp_die($api); 112 103 113 add_action('install_plugins_table_header', 'install_search_form'); 104 114 105 115 display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); … … 173 183 function install_featured($page = 1) { 174 184 $args = array('browse' => 'featured', 'page' => $page); 175 185 $api = plugins_api('query_plugins', $args); 186 if ( is_wp_error($api) ) 187 wp_die($api); 176 188 display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 177 189 } 178 190 … … 201 213 function install_new($page = 1) { 202 214 $args = array('browse' => 'new', 'page' => $page); 203 215 $api = plugins_api('query_plugins', $args); 216 if ( is_wp_error($api) ) 217 wp_die($api); 204 218 display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); 205 219 } 206 220 add_action('install_plugins_updated', 'install_updated', 10, 1); … … 234 248 $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : ''; 235 249 $term = isset($_REQUEST['s']) ? $_REQUEST['s'] : ''; 236 250 237 $plugins_allowedtags = array('a' => array('href' => array(),'title' => array(), 'target' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); 251 $plugins_allowedtags = array('a' => array('href' => array(),'title' => array(), 'target' => array()), 252 'abbr' => array('title' => array()),'acronym' => array('title' => array()), 253 'code' => array(),'em' => array(),'strong' => array()); 238 254 239 255 ?> 240 256 <div class="tablenav"> … … 316 332 <td class="name"><?php echo $title; ?></td> 317 333 <td class="vers"><?php echo $version; ?></td> 318 334 <td class="vers"> 319 <div class="star-holder" title="<?php printf( __('based on %d ratings'), $plugin['num_ratings'] );?>">335 <div class="star-holder" title="<?php printf(__ngettext(__('based on %d rating'), __('based on %d ratings'), $plugin['num_ratings']), $plugin['num_ratings']) ?>"> 320 336 <div class="star star-rating" style="width: <?php echo attribute_escape($plugin['rating']) ?>px"></div> 321 337 <div class="star star5"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('5 stars') ?>" /></div> 322 338 <div class="star star4"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('4 stars') ?>" /></div> … … 355 371 356 372 $api = plugins_api('plugin_information', array('slug' => $_REQUEST['plugin'])); 357 373 374 if ( is_wp_error($api) ) 375 wp_die($api); 376 377 $plugins_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()), 378 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 379 'code' => array(), 'em' => array(), 'strong' => array(), 'div' => array(), 380 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array()); 381 //Sanitize HTML 382 foreach ( (array)$api->sections as $section_name => $content ) 383 $api->sections[$section_name] = wp_kses($content, $plugins_allowedtags); 384 foreach ( array('version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug') as $key ) 385 $api->$key = wp_kses($api->$key, $plugins_allowedtags); 386 358 387 $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : 'description'; //Default to the Description tab, Do not translate, API returns English. 359 388 if( empty($section) || ! isset($api->sections[ $section ]) ) 360 389 $section = array_shift( $section_titles = array_keys((array)$api->sections) ); … … 521 549 522 550 check_admin_referer('install-plugin_' . $plugin); 523 551 $api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth. 552 553 if ( is_wp_error($api) ) 554 wp_die($api); 524 555 525 556 echo '<div class="wrap">'; 526 557 echo '<h2>', sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version ), '</h2>'; … … 834 865 return $folder . '/' . $pluginfiles[0]; 835 866 } 836 867 837 838 839 868 ?>
