Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#21071 closed enhancement (fixed)

Do a load action in admin.php for importers

Reported by: simonwheatley Owned by: nacin
Milestone: 3.5 Priority: normal
Severity: normal Version:
Component: Import Keywords: has-patch commit
Focuses: Cc:


Every type of page in the admin area has an equivalent load-[whatever] type action, which is triggered before any HTML has been rendered. This is handy if a plugin needs to process some data which might require a redirect header to be set, or to affect HTML which is rendered before the admin screen main content (e.g. admin notices).

The exception to the rule is the importers. I propose adding an action which would allow plugins and themes to execute code at this point as easily as they can in other areas of WP admin.

Attachments (1)

21701-sw-1.diff (336 bytes) - added by simonwheatley 3 years ago.

Download all attachments as: .zip

Change History (8)

@simonwheatley3 years ago

comment:1 @simonwheatley3 years ago

Diff adds do_action("load-importer-$importer"); into admin.php within this block of the conditional where the other load actions are triggered. The use of "load-importer" rather than "load-" is to get around the possible problems of having a plugin page hook which clashes… but perhaps I'm wrong or overly concerned?

comment:2 @scribu3 years ago

  • Keywords commit added; dev-feedback removed
  • Milestone changed from Awaiting Review to 3.5

I think 'load-importer-' is a good precaution.

comment:3 @nacin3 years ago

I can go for something like this. Not sure if I like the idea of modeling it after "load-*", as those hooks are specifically acting on $hook_suffix, while in this case the hook suffix would be "admin.php". Either way, namespacing it so it is load-importer-$importer or "import_$importer" or "load_importer_$importer" seems good to me.

comment:4 @simonwheatley3 years ago

I chose load-importer-$importer as it indicates the similarity with the other load-$whatever hooks. Personally I favour dashes in hooks, and again this would be consistent with the other load-$whatever hooks.

comment:5 follow-up: @nacin3 years ago

I am satisfied with the use case presented here as well as 21701-sw-1.diff. Leaving this for duck_ and westi to weigh in.

comment:6 in reply to: ↑ 5 @westi3 years ago

Replying to nacin:

I am satisfied with the use case presented here as well as 21701-sw-1.diff. Leaving this for duck_ and westi to weigh in.

Looks good to me.

comment:7 @nacin3 years ago

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

In [21183]:

load-importer-$importer hook. props simonwheatley. fixes #21071.

Note: See TracTickets for help on using tickets.