WordPress.org

Make WordPress Core

Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#51177 closed enhancement (invalid)

Add filters in the attachment_submitbox_metadata function

Reported by: Jean-David Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Media Keywords:
Focuses: template Cc:

Description

In wp-admin/includes/media.php line 3249, the function

function attachment_submitbox_metadata() {

this function has no filter, so it's not possible to hook into it without to copy the function, but doing so would miss on any upgrade made to this function.

I don't know why there is no filters in this function, maybe there is a good explanation I didn't think about ?

The goal for me is to add the same div

.misc-pub-section.mis-pub-filename

used by the admin but with my own html.

Change History (4)

#1 @Mista-Flo
15 months ago

Hi @Jean-David, welcome and thank you for your ticket :)

I'm not sure adding some hooks here would be a good idea. I checked, and it was the same for the submit metabox for posts. You still have an action hook. But usually, for this metabox, I used to just manually add some custom HTML with JS code.

I advise you to use the attachment_submitbox_misc_actions hook, which is used once by the core itself to add some elements.

Last edited 15 months ago by Mista-Flo (previous) (diff)

#2 @garrett-eclipse
15 months ago

  • Keywords close 2nd-opinion added

Going to mark this as close and 2nd-opinion. As @Mista-Flo mentioned you can add additional .misc-pub-section element by adding a custom hook onto the attachment_submitbox_misc_actions action. If you give it a priority less than 10 it'll place your custom items prior to the existing sections, if you give it a priority greater than 10 it'll place your custom items after the existing sections.

#3 @Jean-David
15 months ago

  • Resolution set to invalid
  • Status changed from new to closed

Actually you're right guys, I guess I didn't pay enough attention, thanks for your answers.
This ticket can be closed indeed.

#4 @SergeyBiryukov
15 months ago

  • Keywords close 2nd-opinion removed
  • Milestone Awaiting Review deleted

Thanks for the follow-up!

Note: See TracTickets for help on using tickets.