diff --git a/src/wp-admin/css/themes.css b/src/wp-admin/css/themes.css index b611e3006c..eb99e23290 100644 --- a/src/wp-admin/css/themes.css +++ b/src/wp-admin/css/themes.css @@ -1056,13 +1056,16 @@ body.folded .theme-browser ~ .theme-overlay .theme-wrap { .theme-install-php a.browse-themes { cursor: pointer; } -.theme-install-php a.browse-themes, -.theme-install-php.show-upload-theme a.upload { + +.upload-view-toggle .browse, +.upload-view-toggle.upload-tab .upload { display: none; } -.theme-install-php.show-upload-theme a.browse-themes { + +.upload-view-toggle.upload-tab .browse { display: inline; } + .upload-theme, .upload-plugin { -webkit-box-sizing: border-box; @@ -1076,10 +1079,13 @@ body.folded .theme-browser ~ .theme-overlay .theme-wrap { position: relative; top: 10px; } -body.show-upload-theme .upload-theme, -.upload-plugin { + +.show-upload-view .upload-theme, +.show-upload-view .upload-plugin, +.upload-tab .upload-plugin { display: block; } + .upload-theme .wp-upload-form, .upload-plugin .wp-upload-form { background: #fafafa; diff --git a/src/wp-admin/includes/admin-filters.php b/src/wp-admin/includes/admin-filters.php index 38051e3947..bea7a25cc2 100644 --- a/src/wp-admin/includes/admin-filters.php +++ b/src/wp-admin/includes/admin-filters.php @@ -64,7 +64,6 @@ add_filter( 'whitelist_options', 'option_update_filter' ); // Plugin Install hooks. add_action( 'install_plugins_featured', 'install_dashboard' ); -add_action( 'install_plugins_upload', 'install_plugins_upload' ); add_action( 'install_plugins_search', 'display_plugins_table' ); add_action( 'install_plugins_popular', 'display_plugins_table' ); add_action( 'install_plugins_recommended', 'display_plugins_table' ); diff --git a/src/wp-admin/includes/class-wp-upgrader-skins.php b/src/wp-admin/includes/class-wp-upgrader-skins.php index c9d32cebe8..0d6b2737aa 100644 --- a/src/wp-admin/includes/class-wp-upgrader-skins.php +++ b/src/wp-admin/includes/class-wp-upgrader-skins.php @@ -579,6 +579,8 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin { $install_actions['importers_page'] = '' . __( 'Return to Importers' ) . ''; } elseif ( $this->type == 'web' ) { $install_actions['plugins_page'] = '' . __( 'Return to Plugin Installer' ) . ''; + } elseif ( 'upload' == $this->type && 'plugins' == $from ) { + $install_actions['plugins_page'] = '' . __( 'Return to Plugin Installer' ) . ''; } else { $install_actions['plugins_page'] = '' . __( 'Return to Plugins page' ) . ''; } diff --git a/src/wp-admin/includes/plugin-install.php b/src/wp-admin/includes/plugin-install.php index b1727a279e..48fef819f7 100644 --- a/src/wp-admin/includes/plugin-install.php +++ b/src/wp-admin/includes/plugin-install.php @@ -210,7 +210,7 @@ function install_popular_tags( $args = array() ) { */ function install_dashboard() { ?> -

WordPress Plugin Directory or upload a plugin in .zip format via this page.' ), 'https://wordpress.org/plugins/', self_admin_url( 'plugin-install.php?tab=upload' ) ); ?>

+

WordPress Plugin Directory or upload a plugin in .zip format by clicking the button at the top of this page.' ), 'https://wordpress.org/plugins/' ); ?>

diff --git a/src/wp-admin/js/plugin-install.js b/src/wp-admin/js/plugin-install.js index dc0f5a58d8..4cd1bb8eb4 100644 --- a/src/wp-admin/js/plugin-install.js +++ b/src/wp-admin/js/plugin-install.js @@ -1,6 +1,8 @@ /* global plugininstallL10n, tb_click, tb_remove */ -/* Plugin Browser Thickbox related JS*/ +/** + * Functionality for the plugin install screens. + */ var tb_position; jQuery( document ).ready( function( $ ) { @@ -174,4 +176,23 @@ jQuery( document ).ready( function( $ ) { $( '#section-holder div.section' ).hide(); // Hide 'em all. $( '#section-' + tab ).show(); }); + + /* + * When a user presses the "Upload Plugin" button, show the upload form in place + * rather than sending them to the devoted upload plugin page. + * @todo consider to abstract this in a generic, reusable, utility, see theme.js + */ + var uploadViewToggle = $( '.upload-view-toggle' ), + $body = $( document.body ); + + uploadViewToggle + .attr({ + role: 'button', + 'aria-expanded': 'false' + }) + .on( 'click', function( event ) { + event.preventDefault(); + $body.toggleClass( 'show-upload-view' ); + uploadViewToggle.attr( 'aria-expanded', $body.hasClass( 'show-upload-view' ) ); + }); }); diff --git a/src/wp-admin/js/theme.js b/src/wp-admin/js/theme.js index 9cd738a1c3..d08c9fe075 100644 --- a/src/wp-admin/js/theme.js +++ b/src/wp-admin/js/theme.js @@ -1604,17 +1604,24 @@ themes.view.Installer = themes.view.Appearance.extend({ // in new location searchContainer: $( '.wp-filter .search-form' ), + /* + * When a user presses the "Upload Theme" button, show the upload form in place. + * @todo consider to abstract this in a generic, reusable, utility, see plugin-install.js + */ uploader: function() { - $( 'a.upload' ).on( 'click', function( event ) { - event.preventDefault(); - $( 'body' ).addClass( 'show-upload-theme' ); - themes.router.navigate( themes.router.baseUrl( '?upload' ), { replace: true } ); - }); - $( 'a.browse-themes' ).on( 'click', function( event ) { - event.preventDefault(); - $( 'body' ).removeClass( 'show-upload-theme' ); - themes.router.navigate( themes.router.baseUrl( '' ), { replace: true } ); - }); + var uploadViewToggle = $( '.upload-view-toggle' ), + $body = $( document.body ); + + uploadViewToggle + .attr({ + role: 'button', + 'aria-expanded': 'false' + }) + .on( 'click', function( event ) { + event.preventDefault(); + $body.toggleClass( 'show-upload-view' ); + uploadViewToggle.attr( 'aria-expanded', $body.hasClass( 'show-upload-view' ) ); + }); }, // Toggle the full filters navigation diff --git a/src/wp-admin/plugin-install.php b/src/wp-admin/plugin-install.php index c9f2b50fcb..53919f4fed 100644 --- a/src/wp-admin/plugin-install.php +++ b/src/wp-admin/plugin-install.php @@ -106,16 +106,31 @@ include(ABSPATH . 'wp-admin/admin-header.php'); if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_plugins' ) ) { if ( $tab === 'upload' ) { $href = self_admin_url( 'plugin-install.php' ); - $text = _x( 'Browse', 'plugins' ); + $upload_tab_class = ' upload-tab'; } else { $href = self_admin_url( 'plugin-install.php?tab=upload' ); - $text = __( 'Upload Plugin' ); + $upload_tab_class = ''; } - echo ' ' . $text . ''; + + printf( ' %s%s', + $href, + $upload_tab_class, + __( 'Upload Plugin' ), + __( 'Browse Plugins' ) + ); } ?> +
+ +
+ views(); diff --git a/src/wp-admin/plugins.php b/src/wp-admin/plugins.php index 4530831bc8..3b9d334d2c 100644 --- a/src/wp-admin/plugins.php +++ b/src/wp-admin/plugins.php @@ -372,11 +372,9 @@ get_current_screen()->add_help_tab( array( 'content' => '

' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '

' . '

' . sprintf( - /* translators: 1: Plugin Browser/Installer URL, 2: WordPress Plugin Directory URL 3: local plugin directory */ - __( 'You can find additional plugins for your site by using the Plugin Browser/Installer functionality or by browsing the WordPress Plugin Directory directly and installing new plugins manually. To manually install a plugin you generally just need to upload the plugin file into your %3$s directory. Once a plugin has been installed, you can activate it here.' ), - 'plugin-install.php', - 'https://wordpress.org/plugins/', - '/wp-content/plugins' + /* translators: %s: WordPress Plugin Directory URL */ + __( 'If you would like to see more plugins to choose from, click on the “Add New” button and you will be able to browse or search for additional plugins from the WordPress.org Plugin Directory. Plugins in the WordPress.org Plugin Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they’re free!' ), + 'https://wordpress.org/plugins/' ) . '

' ) ); get_current_screen()->add_help_tab( array( diff --git a/src/wp-admin/theme-install.php b/src/wp-admin/theme-install.php index 97f42ce32a..48534ea4b9 100644 --- a/src/wp-admin/theme-install.php +++ b/src/wp-admin/theme-install.php @@ -127,8 +127,7 @@ include(ABSPATH . 'wp-admin/admin-header.php'); */ $tabs = apply_filters( 'install_themes_tabs', array( 'upload' => __( 'Upload Theme' ) ) ); if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_themes' ) ) { - echo ' ' . __( 'Upload Theme' ) . ''; - echo ' ' . _x( 'Browse', 'themes' ) . ''; + echo ' ' . __( 'Upload Theme' ) . ''; } ?>