Plugins: Improve error messages on plugins screen.

This unifies the layout and wording of error messages on both the plugins screen and the themes screen.

Props tinkerbelly, juhise, Ankit K Gupta, m1tk00, swissspidy, mrahmadawais, danieltj.
Fixes #37430.

Built from https://develop.svn.wordpress.org/trunk@41608


git-svn-id: http://core.svn.wordpress.org/trunk@41443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler 2017-09-27 08:46:45 +00:00
parent e7beaa590f
commit 1f5c7470fb
9 changed files with 26 additions and 12 deletions

View File

@ -230,11 +230,10 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
*/ */
public function no_items() { public function no_items() {
if ( isset( $this->error ) ) { 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>'; echo '<div class="inline error"><p>' . $this->error->get_error_message() . '</p><p class="hide-if-no-js"><button class="button try-again">' . __( 'Try Again' ) . '</button></p></div>';
} else { } else {
$message = __( 'No plugins match your request.' ); echo '<div class="no-plugin-results">' . __( 'No plugins found. Try a different search query.' ) . '</div>';
} }
echo '<div class="no-plugin-results">' . $message . '</div>';
} }
/** /**

View File

@ -1603,7 +1603,11 @@ themes.view.Installer = themes.view.Appearance.extend({
this.listenTo( this.collection, 'query:fail', function() { this.listenTo( this.collection, 'query:fail', function() {
$( 'body' ).removeClass( 'loading-content' ); $( 'body' ).removeClass( 'loading-content' );
$( '.theme-browser' ).find( 'div.error' ).remove(); $( '.theme-browser' ).find( 'div.error' ).remove();
$( '.theme-browser' ).find( 'div.themes' ).before( '<div class="error"><p>' + l10n.error + '</p></div>' ); $( '.theme-browser' ).find( 'div.themes' ).before( '<div class="error"><p>' + l10n.error + '</p><p><button class="button try-again">' + l10n.tryAgain + '</button></p></div>' );
$( '.theme-browser .error .try-again' ).on( 'click', function( e ) {
e.preventDefault();
$( 'input.wp-filter-search' ).trigger( 'input' );
} );
}); });
if ( this.view ) { if ( this.view ) {

File diff suppressed because one or more lines are too long

View File

@ -2291,6 +2291,16 @@
$( 'input.wp-filter-search' ).trigger( 'input' ); $( 'input.wp-filter-search' ).trigger( 'input' );
} ); } );
/**
* Trigger a search event when the "Try Again" button is clicked.
*
* @since 4.8.0
*/
$document.on( 'click', '.try-again', function( event ) {
event.preventDefault();
$pluginInstallSearch.trigger( 'input' );
} );
/** /**
* Trigger a search event when the search type gets changed. * Trigger a search event when the search type gets changed.
* *

File diff suppressed because one or more lines are too long

View File

@ -58,8 +58,9 @@ wp_localize_script( 'theme', '_wpThemeSettings', array(
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ), __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
__( 'https://wordpress.org/support/' ) __( 'https://wordpress.org/support/' )
), ),
'tryAgain' => __( 'Try Again' ),
'themesFound' => __( 'Number of Themes found: %d' ), 'themesFound' => __( 'Number of Themes found: %d' ),
'noThemesFound' => __( 'No themes found. Try a different search.' ), 'noThemesFound' => __( 'No themes found. Try a different search query.' ),
'collapseSidebar' => __( 'Collapse Sidebar' ), 'collapseSidebar' => __( 'Collapse Sidebar' ),
'expandSidebar' => __( 'Expand Sidebar' ), 'expandSidebar' => __( 'Expand Sidebar' ),
/* translators: accessibility text */ /* translators: accessibility text */
@ -227,7 +228,7 @@ include(ABSPATH . 'wp-admin/admin-header.php');
<div class="theme-browser content-filterable"></div> <div class="theme-browser content-filterable"></div>
<div class="theme-install-overlay wp-full-overlay expanded"></div> <div class="theme-install-overlay wp-full-overlay expanded"></div>
<p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p> <p class="no-themes"><?php _e( 'No themes found. Try a different search query.' ); ?></p>
<span class="spinner"></span> <span class="spinner"></span>
<?php <?php

View File

@ -139,7 +139,7 @@ wp_localize_script( 'theme', '_wpThemeSettings', array(
'search' => __( 'Search Installed Themes' ), 'search' => __( 'Search Installed Themes' ),
'searchPlaceholder' => __( 'Search installed themes...' ), // placeholder (no ellipsis) 'searchPlaceholder' => __( 'Search installed themes...' ), // placeholder (no ellipsis)
'themesFound' => __( 'Number of Themes found: %d' ), 'themesFound' => __( 'Number of Themes found: %d' ),
'noThemesFound' => __( 'No themes found. Try a different search.' ), 'noThemesFound' => __( 'No themes found. Try a different search query.' ),
), ),
) ); ) );
@ -303,7 +303,7 @@ foreach ( $themes as $theme ) :
</div> </div>
<div class="theme-overlay"></div> <div class="theme-overlay"></div>
<p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p> <p class="no-themes"><?php _e( 'No themes found. Try a different search query.' ); ?></p>
<?php <?php
// List broken themes, if any. // List broken themes, if any.

View File

@ -812,7 +812,7 @@ function wp_default_scripts( &$scripts ) {
'connectionError' => __( 'Connection lost or the server is busy. Please try again later.' ), 'connectionError' => __( 'Connection lost or the server is busy. Please try again later.' ),
'nonceError' => __( 'An error has occurred. Please reload the page and try again.' ), 'nonceError' => __( 'An error has occurred. Please reload the page and try again.' ),
'pluginsFound' => __( 'Number of plugins found: %d' ), 'pluginsFound' => __( 'Number of plugins found: %d' ),
'noPluginsFound' => __( 'No plugins found. Try a different search.' ), 'noPluginsFound' => __( 'No plugins found. Try a different search query.' ),
), ),
) ); ) );

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.9-alpha-41607'; $wp_version = '4.9-alpha-41608';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.