Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#37495 closed defect (bug) (fixed)

Restore `install_plugins_upload` action to allow replacing plugin upload form

Reported by: davidanderson's profile DavidAnderson Owned by: ocean90's profile ocean90
Milestone: 4.6 Priority: normal
Severity: normal Version: 4.6
Component: Plugins Keywords: has-patch commit dev-reviewed
Focuses: administration Cc:

Description

In WP versions up to and including 4.5, the "upload plugin" form is output by WP calling the action 'install_plugins_upload'.

As such, it's possible to replace that form (as I do in this plugin with over 3,000 active users: https://wordpress.org/plugins/upload-larger-plugins/ ) with an alternative with a remove_action() on the default action, and add_action of your alternative.

That's gone in WP 4.6 RC 1; as part of the re-arrangement of the plugin upload experience (from a tab into a slide-down), the action call (which has been presented since WP 2.7) has been removed (apparently unintentionally), replaced with a direct call to the internal WP function.

The attached patch adds it back. Since the action call is to a very short function that only outputs the HTML fragment, it has no other impact.

Attachments (6)

uploader-filter.diff (1.2 KB) - added by DavidAnderson 9 years ago.
Re-add the install_plugins_upload action
uploader-filter2.diff (1.5 KB) - added by DavidAnderson 9 years ago.
Second version which prevents double-call of the action when visiting the uploads tab directly
uploader-filter3.diff (1.8 KB) - added by DavidAnderson 9 years ago.
Third version: Also restores the calling of install_plugins_pre_upload
37495.diff (5.0 KB) - added by ocean90 9 years ago.
37495.2.diff (5.1 KB) - added by ocean90 9 years ago.
37495.3.diff (5.3 KB) - added by ocean90 9 years ago.

Download all attachments as: .zip

Change History (18)

@DavidAnderson
9 years ago

Re-add the install_plugins_upload action

#1 @ocean90
9 years ago

  • Focuses administration added
  • Keywords has-patch added
  • Summary changed from Regression in WP 4.6 RC 1 - can no longer replace plugin upload form (removed action) to Restore `install_plugins_upload` action to allow replacing plugin upload form

#2 follow-up: @ocean90
9 years ago

  • Milestone changed from Awaiting Review to 4.6

Changed in [37221]. install_plugins_upload comes from the dynamic install_plugins_$tab action.

@DrewAPicture Should this action be documented as a duplicate hook?

#3 @afercia
9 years ago

Worth noting the "upload tab" is still accessible /plugin-install.php?tab=upload directly (there are also plugins that use it, I think) and for example when JS is off. This way, the upload tab will have 2 forms even if one of them is hidden with CSS.

@DavidAnderson
9 years ago

Second version which prevents double-call of the action when visiting the uploads tab directly

@DavidAnderson
9 years ago

Third version: Also restores the calling of install_plugins_pre_upload

#4 @DavidAnderson
9 years ago

Further investigation shows that the action call to install_plugins_pre_upload had also dropped out (I was relying on this action to perform remove_action() for the WP default action). The new version of the patch - uploader-filter3.diff - restores it also.

@ocean90
9 years ago

@ocean90
9 years ago

#5 @ocean90
9 years ago

37495.2.diff:

  • Removes $upload_tab_class and add a class of the current tab to .wrap
  • Provides the *_upload actions on non-upload tabs
  • Prevents two upload forms on the upload tab
  • Adds display:none to .upload-plugin-wrap. This adds support for plugins like Upload Larger Plugins which don't have a .upload-plugin container.

#6 @DavidAnderson
9 years ago

"This adds support for plugins like Upload Larger Plugins which don't have a .upload-plugin container" - omitting that (which was in the form in previous WP versions) might be considered a bug in the plugin; I spotted that at the same time you were doing this, and added it! The trunk version of that plugin now has it.

#7 in reply to: ↑ 2 @DrewAPicture
9 years ago

Replying to ocean90:

Changed in [37221]. install_plugins_upload comes from the dynamic install_plugins_$tab action.

@DrewAPicture Should this action be documented as a duplicate hook?

Yes. If it's an alias of a dynamic hook, it's a duplicate.

Last edited 9 years ago by DrewAPicture (previous) (diff)

#8 @DavidAnderson
9 years ago

I can confirm that with this patch - 37495.2.diff - all works as expected on the plugin I'm testing with.

@ocean90
9 years ago

#9 @ocean90
9 years ago

  • Keywords commit added

37495.3.diff adds a comment to install_plugins_pre_upload to explain why it's there.

#11 @ocean90
9 years ago

  • Keywords dev-reviewed added

#12 @ocean90
9 years ago

  • Owner set to ocean90
  • Resolution set to fixed
  • Status changed from new to closed

In 38172:

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.

Note: See TracTickets for help on using tickets.