Make WordPress Core

Opened 9 years ago

Closed 6 years ago

#34034 closed enhancement (fixed)

Hook for Page Attributes Metabox

Reported by: markcallen's profile markcallen Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.9 Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch
Focuses: administration Cc:

Description

The publish metabox provides two hooks to add additional information/elements to it.

post_submitbox_misc_actions
attachment_submitbox_misc_actions

It would be trivial to add a similar hook to the Page Attributes meta box - is there any reason why this can't be done?

Adding page related meta in an entirely new metabox isn't great for UX - two places for page attributes is silly.

There are several solutions touted in the wild ranging from hacking core to removing and recreating the metabox manually or inserting the elements with javascript - none good solutions.

The addition of a single hook would allow much better practice to be adopted in adding options to this metabox.

do_action( 'page_attributes_misc_actions' );

Attachments (3)

34034.diff (700 bytes) - added by MikeHansenMe 8 years ago.
34034.2.diff (983 bytes) - added by MikeHansenMe 8 years ago.
34034.3.diff (1017 bytes) - added by markcallen 7 years ago.
Updated for inclusion in 4.8

Download all attachments as: .zip

Change History (23)

@MikeHansenMe
8 years ago

#1 @MikeHansenMe
8 years ago

  • Keywords has-patch added

34034.diff adds a new hook that fires directly after post_submitbox_misc_actions. post_submitbox_misc_actions fires on pages and the post object is passed in so it could be targeted that way but this still seems beneficial for specific post types. This hook also works for other post_types besides pages that may use the same metabox, which could be a lot.

#2 @markcallen
8 years ago

  • Keywords has-patch removed

This adds a hook to the Publish (aka submitbox) - this ticket refers to the Page Attributes metabox.

The post_submitbox_misc_actions hook is sufficient because you can test for post types in the callback.

It just needs, in my opinion, do_action( 'page_attributes_misc_actions' ); adding in or around L777 of the wp-admin/meta-boxes.php file.

@MikeHansenMe
8 years ago

#3 @MikeHansenMe
8 years ago

Let me know if 34034.2.diff covers what you are looking for. I placed it after the default attributes.

#4 @markcallen
8 years ago

  • Keywords has-patch added

Works for me, thanks Mike.

#5 @markcallen
7 years ago

This has been sat here for well over a year - it's simple, it has a patch and it's ready to go.

Is there a good any reason for this not being committed - or even reviewed?

Be good to have some feedback at least.

#6 follow-up: @lukecavanagh
7 years ago

Last edited 7 years ago by lukecavanagh (previous) (diff)

#7 in reply to: ↑ 6 @markcallen
7 years ago

Replying to lukecavanagh:

@markcallen

Patch is valid and still applies cleanly.

https://core.trac.wordpress.org/browser/tags/4.7.2/src/wp-admin/includes/meta-boxes.php#L833

Thanks @lukecavanagh.

It's a very simple patch that makes WordPress more extensible. It just needs to be committed, or if there are any reasons for not (personally, I can't think of any), then the points need raising to be discussed.

#8 @SergeyBiryukov
7 years ago

  • Component changed from Options, Meta APIs to Posts, Post Types
  • Keywords needs-refresh added
  • Milestone changed from Awaiting Review to 4.8

page_attributes_misc_attributes might be a better name, as there are no actions in this box.

Last edited 7 years ago by SergeyBiryukov (previous) (diff)

@markcallen
7 years ago

Updated for inclusion in 4.8

#9 @markcallen
7 years ago

  • Keywords needs-refresh removed

Thanks @SergeyBiryukov.

Patch is refreshed.

#10 @jbpaul17
7 years ago

  • Keywords needs-testing added

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


7 years ago

#12 @Braad
7 years ago

Yes please! Patch looks good.

#13 @jbpaul17
7 years ago

  • Keywords needs-testing removed

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


7 years ago

#15 @jbpaul17
7 years ago

  • Milestone changed from 4.8 to 4.8.1

Punting to 4.8.1 per today's bug scrub.

#16 @SergeyBiryukov
7 years ago

  • Milestone changed from 4.8.1 to 4.9

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


7 years ago

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


6 years ago

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


6 years ago

#20 @SergeyBiryukov
6 years ago

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

In 41763:

Posts, Post Types: Introduce page_attributes_misc_attributes action that fires before the help hint text in the 'Page Attributes' meta box.

Props markcallen, MikeHansenMe.
Fixes #34034.

Note: See TracTickets for help on using tickets.