Make WordPress Core

Opened 11 years ago

Last modified 3 years ago

#23253 reopened enhancement

Lack of a do_settings_section (singular) function

Reported by: auniquename's profile auniquename Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Plugins Keywords: has-patch
Focuses: administration Cc:

Description

After considerable research I have found that plugin authors, including myself, have to go to great lengths to put options into tabs on a plugin settings page. The majority use JavaScript to modify the DOM in order to achieve this, others have broken their options into several settings arrays instead of the recommended single array to facilitate the creation of tabs using the traditional WordPress nav-tab-wrapper class approach.

To get my own options into tabs in a fully scoped css jquery ui theme I ended up adding my own hacky function to my plugin: myplugin_do_settings_section( $page, $sectionid ) - which is just a copy of the core function do_settings_sections( $page ) with an additional parameter for the section id and an added conditional to only output the section with the requested id.

This allows me to wrap each section in the appropriately classed tags for either jquery ui tabs or traditional WordPress nav-tabs. This however, is not an acceptable long-term solution as the core code will undoubtedly change, I already see tickets and revisions relating to the removal of those nasty tables...

This functionality should be in the core code. A settings section is a section and it should be possible to output them one at a time to allow for styling.

Thanks for considering my proposal.

(Also, the Iris color picker does not play nice with jquery-ui - it needs its own css scope or something - that will be a separate ticket once I have a better understanding of what is wrong with it and have searched for existing tickets on the subject.)

Attachments (1)

23253.diff (3.6 KB) - added by gazchap 3 years ago.
Suggested patch incorporating a do_settings_section() function

Download all attachments as: .zip

Change History (9)

#1 @nacin
10 years ago

  • Component changed from Plugins to Admin APIs
  • Focuses administration added

#2 @nacin
10 years ago

  • Component changed from Admin APIs to Plugins

Sorry for the noise.

#3 @chriscct7
8 years ago

  • Keywords needs-patch added
  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

Closing as maybelater. Complete lack of interest on the feature on the ticket over the last 2 years. Feel free to reopen when more interest re-emerges (particularly if there's a patch)

#4 @kg69design
8 years ago

  • Resolution maybelater deleted
  • Status changed from closed to reopened
  • Version set to 4.4

I agree that this functionality should be in the core code. Reasons:

  1. Many plugin and theme developers need it.
  2. This functionality can stop a large number of ugly and inconsistent settings pages.

#5 @SergeyBiryukov
8 years ago

  • Milestone set to Awaiting Review
  • Version 4.4 deleted

#6 @Will Brownsberger
8 years ago

Another vote for this from a plugin author. It's not a big function to add -- but best to have it standard.

#7 @komapeb
6 years ago

+1 from me too.

@gazchap
3 years ago

Suggested patch incorporating a do_settings_section() function

#8 @gazchap
3 years ago

  • Keywords has-patch added; needs-patch removed

I came across this ticket after searching for a "do_setting_section" function.

I've attached a suggestion for a patch, adding a do_setting_section() function, as well as a render_setting_section() function that is used by it - and also by a refactored version of do_setting_sections() to avoid code duplication.

render_settings_section() is not something I'd expect to be used outside of these circumstances, and this being my first patch, I wasn't sure on naming conventions for "private" functions.

Feedback appreciated!

Last edited 3 years ago by gazchap (previous) (diff)
Note: See TracTickets for help on using tickets.