Plugins: Use `install_plugins_upload` action to print the upload form.

Since [37221] the upload form is added to every plugin install screen via `install_plugins_upload()`. Previously the form was added through the `install_plugins_upload` (alias of `install_plugins_$tab`) action which allowed plugin authors to replace the form. This restores the previous behaviour.

* Add the form only to non-upload plugin install screens.
* Replace `install_plugins_upload()` with the `install_plugins_upload` and `install_plugins_pre_upload` actions.
* Remove `$upload_tab_class` and add a CSS class for the current tab to `.wrap`
* Adjust CSS selectors and toggle the whole container to support upload without an `upload-plugin` class.

Props DavidAnderson, ocean90.
Fixes #37495.
Built from https://develop.svn.wordpress.org/trunk@38172


git-svn-id: http://core.svn.wordpress.org/trunk@38113 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2016-07-31 18:11:29 +00:00
parent f6e5d8db6c
commit 1abd5f0be7
9 changed files with 50 additions and 32 deletions

View File

@ -1026,11 +1026,11 @@ body.folded .theme-browser ~ .theme-overlay .theme-wrap {
}
.upload-view-toggle .browse,
.upload-view-toggle.upload-tab .upload {
.plugin-install-tab-upload .upload-view-toggle .upload {
display: none;
}
.upload-view-toggle.upload-tab .browse {
.plugin-install-tab-upload .upload-view-toggle .browse {
display: inline;
}
@ -1048,9 +1048,14 @@ body.folded .theme-browser ~ .theme-overlay .theme-wrap {
top: 10px;
}
.upload-plugin-wrap {
display: none;
}
.show-upload-view .upload-theme,
.show-upload-view .upload-plugin,
.upload-tab .upload-plugin {
.show-upload-view .upload-plugin-wrap,
.plugin-install-tab-upload .upload-plugin {
display: block;
}

File diff suppressed because one or more lines are too long

View File

@ -1026,11 +1026,11 @@ body.folded .theme-browser ~ .theme-overlay .theme-wrap {
}
.upload-view-toggle .browse,
.upload-view-toggle.upload-tab .upload {
.plugin-install-tab-upload .upload-view-toggle .upload {
display: none;
}
.upload-view-toggle.upload-tab .browse {
.plugin-install-tab-upload .upload-view-toggle .browse {
display: inline;
}
@ -1048,9 +1048,14 @@ body.folded .theme-browser ~ .theme-overlay .theme-wrap {
top: 10px;
}
.upload-plugin-wrap {
display: none;
}
.show-upload-view .upload-theme,
.show-upload-view .upload-plugin,
.upload-tab .upload-plugin {
.show-upload-view .upload-plugin-wrap,
.plugin-install-tab-upload .upload-plugin {
display: block;
}

File diff suppressed because one or more lines are too long

View File

@ -70,6 +70,7 @@ 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

@ -12,7 +12,8 @@ jQuery( document ).ready( function( $ ) {
$tabbables,
$firstTabbable,
$lastTabbable,
uploadViewToggle = $( '.upload-view-toggle' ),
$uploadViewToggle = $( '.upload-view-toggle' ),
$wrap = $ ( '.wrap' ),
$body = $( document.body );
tb_position = function() {
@ -183,12 +184,12 @@ jQuery( document ).ready( function( $ ) {
* When a user presses the "Upload Plugin" button, show the upload form in place
* rather than sending them to the devoted upload plugin page.
* The `?tab=upload` page still exists for no-js support and for plugins that
* might access it directly (?). When we're in this page, let the link behave
* might access it directly. When we're in this page, let the link behave
* like a link. Otherwise we're in the normal plugin installer pages and the
* link should behave like a toggle button.
*/
if ( ! uploadViewToggle.hasClass( 'upload-tab' ) ) {
uploadViewToggle
if ( ! $wrap.hasClass( 'plugin-install-tab-upload' ) ) {
$uploadViewToggle
.attr({
role: 'button',
'aria-expanded': 'false'
@ -196,7 +197,7 @@ jQuery( document ).ready( function( $ ) {
.on( 'click', function( event ) {
event.preventDefault();
$body.toggleClass( 'show-upload-view' );
uploadViewToggle.attr( 'aria-expanded', $body.hasClass( 'show-upload-view' ) );
$uploadViewToggle.attr( 'aria-expanded', $body.hasClass( 'show-upload-view' ) );
});
}
});

View File

@ -1 +1 @@
var tb_position;jQuery(document).ready(function(a){function b(){var b=e.find("#TB_iframeContent");g=b.contents().find("body"),c(),i.focus(),a("#plugin-information-tabs a",g).on("click",function(){c()}),g.on("keydown",function(a){27===a.which&&tb_remove()})}function c(){var b;h=a(":tabbable",g),i=e.find("#TB_closeWindowButton"),j=h.last(),b=i.add(j),b.off("keydown.wp-plugin-details"),b.on("keydown.wp-plugin-details",function(a){d(a)})}function d(a){9===a.which&&(j[0]!==a.target||a.shiftKey?i[0]===a.target&&a.shiftKey&&(a.preventDefault(),j.focus()):(a.preventDefault(),i.focus()))}var e,f,g,h,i,j,k=a(".upload-view-toggle"),l=a(document.body);tb_position=function(){var b=a(window).width(),c=a(window).height()-(b>792?60:20),d=b>792?772:b-20;return e=a("#TB_window"),e.length&&(e.width(d).height(c),a("#TB_iframeContent").width(d).height(c),e.css({"margin-left":"-"+parseInt(d/2,10)+"px"}),"undefined"!=typeof document.body.style.maxWidth&&e.css({top:"30px","margin-top":"0"})),a("a.thickbox").each(function(){var b=a(this).attr("href");b&&(b=b.replace(/&width=[0-9]+/g,""),b=b.replace(/&height=[0-9]+/g,""),a(this).attr("href",b+"&width="+d+"&height="+c))})},a(window).resize(function(){tb_position()}),l.on("thickbox:iframe:loaded",e,function(){b()}).on("thickbox:removed",function(){f.focus()}),a(".thickbox.open-plugin-details-modal").on("click",function(b){var c=a(this).data("title")?plugininstallL10n.plugin_information+" "+a(this).data("title"):plugininstallL10n.plugin_modal_label;b.preventDefault(),b.stopPropagation(),f=a(this),tb_click.call(this),e.attr({role:"dialog","aria-label":plugininstallL10n.plugin_modal_label}),e.find("#TB_iframeContent").attr("title",c)}),a("#plugin-information-tabs a").click(function(b){var c=a(this).attr("name");b.preventDefault(),a("#plugin-information-tabs a.current").removeClass("current"),a(this).addClass("current"),"description"!==c&&a(window).width()<772?a("#plugin-information-content").find(".fyi").hide():a("#plugin-information-content").find(".fyi").show(),a("#section-holder div.section").hide(),a("#section-"+c).show()}),k.hasClass("upload-tab")||k.attr({role:"button","aria-expanded":"false"}).on("click",function(a){a.preventDefault(),l.toggleClass("show-upload-view"),k.attr("aria-expanded",l.hasClass("show-upload-view"))})});
var tb_position;jQuery(document).ready(function(a){function b(){var b=e.find("#TB_iframeContent");g=b.contents().find("body"),c(),i.focus(),a("#plugin-information-tabs a",g).on("click",function(){c()}),g.on("keydown",function(a){27===a.which&&tb_remove()})}function c(){var b;h=a(":tabbable",g),i=e.find("#TB_closeWindowButton"),j=h.last(),b=i.add(j),b.off("keydown.wp-plugin-details"),b.on("keydown.wp-plugin-details",function(a){d(a)})}function d(a){9===a.which&&(j[0]!==a.target||a.shiftKey?i[0]===a.target&&a.shiftKey&&(a.preventDefault(),j.focus()):(a.preventDefault(),i.focus()))}var e,f,g,h,i,j,k=a(".upload-view-toggle"),l=a(".wrap"),m=a(document.body);tb_position=function(){var b=a(window).width(),c=a(window).height()-(b>792?60:20),d=b>792?772:b-20;return e=a("#TB_window"),e.length&&(e.width(d).height(c),a("#TB_iframeContent").width(d).height(c),e.css({"margin-left":"-"+parseInt(d/2,10)+"px"}),"undefined"!=typeof document.body.style.maxWidth&&e.css({top:"30px","margin-top":"0"})),a("a.thickbox").each(function(){var b=a(this).attr("href");b&&(b=b.replace(/&width=[0-9]+/g,""),b=b.replace(/&height=[0-9]+/g,""),a(this).attr("href",b+"&width="+d+"&height="+c))})},a(window).resize(function(){tb_position()}),m.on("thickbox:iframe:loaded",e,function(){b()}).on("thickbox:removed",function(){f.focus()}),a(".thickbox.open-plugin-details-modal").on("click",function(b){var c=a(this).data("title")?plugininstallL10n.plugin_information+" "+a(this).data("title"):plugininstallL10n.plugin_modal_label;b.preventDefault(),b.stopPropagation(),f=a(this),tb_click.call(this),e.attr({role:"dialog","aria-label":plugininstallL10n.plugin_modal_label}),e.find("#TB_iframeContent").attr("title",c)}),a("#plugin-information-tabs a").click(function(b){var c=a(this).attr("name");b.preventDefault(),a("#plugin-information-tabs a.current").removeClass("current"),a(this).addClass("current"),"description"!==c&&a(window).width()<772?a("#plugin-information-content").find(".fyi").hide():a("#plugin-information-content").find(".fyi").show(),a("#section-holder div.section").hide(),a("#section-"+c).show()}),l.hasClass("plugin-install-tab-upload")||k.attr({role:"button","aria-expanded":"false"}).on("click",function(a){a.preventDefault(),m.toggleClass("show-upload-view"),k.attr("aria-expanded",m.hasClass("show-upload-view"))})});

View File

@ -66,6 +66,15 @@ wp_enqueue_script( 'updates' );
*/
do_action( "install_plugins_pre_$tab" );
/*
* Call the pre upload action on every non-upload plugin install screen
* because the form is always displayed on these screens.
*/
if ( 'upload' !== $tab ) {
/** This action is documented in wp-admin/plugin-install.php */
do_action( 'install_plugins_pre_upload' );
}
get_current_screen()->add_help_tab( array(
'id' => 'overview',
'title' => __('Overview'),
@ -101,22 +110,13 @@ get_current_screen()->set_screen_reader_content( array(
*/
include(ABSPATH . 'wp-admin/admin-header.php');
?>
<div class="wrap">
<div class="wrap <?php echo esc_attr( "plugin-install-tab-$tab" ); ?>">
<h1>
<?php
echo esc_html( $title );
if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_plugins' ) ) {
if ( $tab === 'upload' ) {
$href = self_admin_url( 'plugin-install.php' );
$upload_tab_class = ' upload-tab';
} else {
$href = self_admin_url( 'plugin-install.php?tab=upload' );
$upload_tab_class = '';
}
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,
printf( ' <a href="%s" class="upload-view-toggle page-title-action"><span class="upload">%s</span><span class="browse">%s</span></a>',
( 'upload' === $tab ) ? self_admin_url( 'plugin-install.php' ) : self_admin_url( 'plugin-install.php?tab=upload' ),
__( 'Upload Plugin' ),
__( 'Browse Plugins' )
);
@ -124,16 +124,22 @@ include(ABSPATH . 'wp-admin/admin-header.php');
?>
</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
* Output the upload plugin form on every non-upload plugin install screen, so it can be
* displayed via JavaScript rather then opening up the devoted upload plugin page.
*/
install_plugins_upload(); ?>
</div>
if ( $tab !== 'upload' ) {
?>
<div class="upload-plugin-wrap">
<?php
/** This action is documented in wp-admin/plugin-install.php */
do_action( 'install_plugins_upload' );
?>
</div>
<?php
}
<?php
if ( $tab !== 'upload' ) {
$wp_list_table->views();
echo '<br class="clear" />';

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.6-RC1-38171';
$wp_version = '4.6-RC1-38172';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.