WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 3 weeks ago

#38097 new enhancement

Add ability to Settings API to assign positioning

Reported by: dartiss Owned by:
Milestone: 5.8 Priority: normal
Severity: normal Version: 4.7
Component: Administration Keywords:
Focuses: Cc:

Description

When using the Settings API to add a settings field, particularly if adding to an existing settings screen, it would be nice to have some way of positioning the new field, as you can with add_menu_page, for instance.

So, I've just updated a plugin in which I've added a single settings to the existing "General" settings screen. It's date related and it would sit nicely in a specific position on that screen, but I have no control over it. So, a "position" field, as add_menu_page has, would be a nice addition to provide a more nuanced result.

Change History (4)

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


3 weeks ago

#2 @peterwilsoncc
3 weeks ago

  • Milestone changed from Awaiting Review to 5.8

#3 @ribaricplusplus
3 weeks ago

Hi @dartiss,

We discussed this issue during a triage and agreed that this should be done.

For anyone interested in implementing a patch, here is a suggestion how it could be done:

Add $position to add_settings_field arguments, and then save it in $wp_settings_fields[ $page ][ $section ][ $id ] alongside other settings. Then before outputting fields in do_settings_fields we can do a sort so that the fields are output in accordance with $position.

#4 @dartiss
3 weeks ago

Thanks.

Having recently re-looked at this, the built-in core settings are hard-coded (i.e. they're not added by the Settings API), so these would need to be modified too, to allow more precise positioning of additional options.

Note: See TracTickets for help on using tickets.