Install Plugins: Don't wp_die() if API can't be reached.

props johnbillion.
fixes #29361.

git-svn-id: https://develop.svn.wordpress.org/trunk@29594 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2014-08-25 15:01:50 +00:00
parent fa1b34ac78
commit fae5c2de6f
1 changed files with 10 additions and 3 deletions

View File

@ -168,8 +168,10 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
$api = plugins_api( 'query_plugins', $args );
if ( is_wp_error( $api ) )
wp_die( $api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a>' );
if ( is_wp_error( $api ) ) {
$this->error = $api;
return;
}
$this->items = $api->plugins;
@ -188,7 +190,12 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
}
public function no_items() {
echo '<div class="wp-filter-no-results">' . __( 'No plugins match your request.' ) . '</div>';
if ( isset( $this->error ) ) {
$message = $this->error->get_error_message() . '<p class="hide-if-no-js"><a href="#" class="button" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a></p>';
} else {
$message = __( 'No plugins match your request.' );
}
echo '<div class="wp-filter-no-results">' . $message . '</div>';
}
protected function get_views() {