WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 2 years ago

#34034 closed enhancement (fixed)

Hook for Page Attributes Metabox

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

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 4 years ago.
34034.2.diff (983 bytes) - added by MikeHansenMe 4 years ago.
34034.3.diff (1017 bytes) - added by markcallen 3 years ago.
Updated for inclusion in 4.8

Download all attachments as: .zip

Change History (23)

@MikeHansenMe
4 years ago

#1 @MikeHansenMe
4 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
4 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
4 years ago

#3 @MikeHansenMe
4 years ago

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

#4 @markcallen
4 years ago

  • Keywords has-patch added

Works for me, thanks Mike.

#5 @markcallen
3 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
3 years ago

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

#7 in reply to: ↑ 6 @markcallen
3 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
3 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 3 years ago by SergeyBiryukov (previous) (diff)

@markcallen
3 years ago

Updated for inclusion in 4.8

#9 @markcallen
3 years ago

  • Keywords needs-refresh removed

Thanks @SergeyBiryukov.

Patch is refreshed.

#10 @jbpaul17
3 years ago

  • Keywords needs-testing added

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


3 years ago

#12 @Braad
3 years ago

Yes please! Patch looks good.

#13 @jbpaul17
3 years ago

  • Keywords needs-testing removed

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


3 years ago

#15 @jbpaul17
3 years ago

  • Milestone changed from 4.8 to 4.8.1

Punting to 4.8.1 per today's bug scrub.

#16 @SergeyBiryukov
2 years ago

  • Milestone changed from 4.8.1 to 4.9

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


2 years ago

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


2 years ago

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


2 years ago

#20 @SergeyBiryukov
2 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.