Plugin Install: show the upload form in place rather than sending users to the devoted upload plugin page.

Props Ipstenu, ericlewis, michaelarestad.

Fixes #35429.

git-svn-id: https://develop.svn.wordpress.org/trunk@37221 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrea Fercia 2016-04-16 16:42:48 +00:00
parent 745018d81a
commit e4b26366e4
9 changed files with 75 additions and 28 deletions

View File

@ -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;

View File

@ -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' );

View File

@ -579,6 +579,8 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
$install_actions['importers_page'] = '<a href="' . admin_url( 'import.php' ) . '" target="_parent">' . __( 'Return to Importers' ) . '</a>';
} elseif ( $this->type == 'web' ) {
$install_actions['plugins_page'] = '<a href="' . self_admin_url( 'plugin-install.php' ) . '" target="_parent">' . __( 'Return to Plugin Installer' ) . '</a>';
} elseif ( 'upload' == $this->type && 'plugins' == $from ) {
$install_actions['plugins_page'] = '<a href="' . self_admin_url( 'plugin-install.php' ) . '">' . __( 'Return to Plugin Installer' ) . '</a>';
} else {
$install_actions['plugins_page'] = '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>';
}

View File

@ -210,7 +210,7 @@ function install_popular_tags( $args = array() ) {
*/
function install_dashboard() {
?>
<p><?php printf( __( 'Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="%1$s">WordPress Plugin Directory</a> or upload a plugin in .zip format via <a href="%2$s">this page</a>.' ), 'https://wordpress.org/plugins/', self_admin_url( 'plugin-install.php?tab=upload' ) ); ?></p>
<p><?php printf( __( 'Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="%1$s">WordPress Plugin Directory</a> or upload a plugin in .zip format by clicking the button at the top of this page.' ), 'https://wordpress.org/plugins/' ); ?></p>
<?php display_plugins_table(); ?>

View File

@ -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' ) );
});
});

View File

@ -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

View File

@ -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 ' <a href="' . $href . '" class="upload page-title-action">' . $text . '</a>';
printf( ' <a href="%s" class="upload-view-toggle page-title-action%s"><span class="upload">%s</span><span class="browse">%s</span></a>',
$href,
$upload_tab_class,
__( 'Upload Plugin' ),
__( 'Browse Plugins' )
);
}
?>
</h1>
<div class="upload-plugin-wrap<?php echo $upload_tab_class; ?>">
<?php
/*
* Output the upload plugin form on every plugin install screen, so it can be
* displayed via JavaScript rather then opening up the devoted upload plugin page.
*/
install_plugins_upload(); ?>
</div>
<?php
if ( $tab !== 'upload' ) {
$wp_list_table->views();

View File

@ -372,11 +372,9 @@ get_current_screen()->add_help_tab( array(
'content' =>
'<p>' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '</p>' .
'<p>' . 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 <a href="%1$s">Plugin Browser/Installer</a> functionality or by browsing the <a href="%2$s" target="_blank">WordPress Plugin Directory</a> 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/',
'<code>/wp-content/plugins</code>'
/* translators: %s: WordPress Plugin Directory URL */
__( 'If you would like to see more plugins to choose from, click on the &#8220;Add New&#8221; button and you will be able to browse or search for additional plugins from the <a href="%s" target="_blank">WordPress.org Plugin Directory</a>. 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&#8217;re free!' ),
'https://wordpress.org/plugins/'
) . '</p>'
) );
get_current_screen()->add_help_tab( array(

View File

@ -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 ' <a href="#" class="upload page-title-action">' . __( 'Upload Theme' ) . '</a>';
echo ' <a href="#" class="browse-themes page-title-action">' . _x( 'Browse', 'themes' ) . '</a>';
echo ' <a href="#" class="upload-view-toggle page-title-action">' . __( 'Upload Theme' ) . '</a>';
}
?></h1>