WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 8 months ago

#17851 reviewing enhancement

Wrapping Sections with add_settings_section

Reported by: griffinjt Owned by: chriscct7
Milestone: Future Release Priority: normal
Severity: normal Version: 3.1.3
Component: Administration Keywords: has-patch needs-refresh good-first-bug
Focuses: Cc:

Description

This is my first time reporting, so excuse my ignorance. I just wanted to see about enhancing the add_settings_section function.

As of now, individual sections are not wrapper in any sort of container, which makes no sense to semantic sense to me. Sections should/need to be styled differently, but as of now, you really don't have much control of that.

I propose something similar to the register_sidebar function, looking like this:

add_settings_section( $id, $title, $callback, $page, $args )

$args would accept 3 parameters: before_section, after_section, and section_class.

This way you can style each individual section with relative ease. Just a thought and enhancement to the Settings API.

Thomas

Attachments (3)

17851.diff (1.1 KB) - added by scribu 5 years ago.
17851.2.diff (1.2 KB) - added by scribu 5 years ago.
Added settings-field class
template.php.patch (2.2 KB) - added by ross_ritchey 8 months ago.
Add new $args to add_settings_section. Update add_settings_section to include new $args in array. Add wrapper around printout in do_settings_section.

Download all attachments as: .zip

Change History (24)

#1 @nacin
5 years ago

The goal of the settings API is to relieve the developer of any choices of markup and style. Ideally, the core UI styles should be used wherever possible. It also keeps us flexible -- As an example, we plan to kill the table markup in 3.3.

#2 @griffinjt
5 years ago

I understand. I just thought it would be nice for UI (e.g. jQuery accordion to keep everything on one page and manageable for lots of options)

Last edited 5 years ago by griffinjt (previous) (diff)

#3 @nacin
5 years ago

If you need an accordion to keep your options visibly in check, then you probably have too many options :-)

#4 @griffinjt
5 years ago

Tushay. :)

#5 @nacin
5 years ago

This is something that might end up happening in #16413.

I think it would be fine to just have a wrapping div with an ID generated from the section ID.

#6 @griffinjt
5 years ago

Easy and functional. I'll look into that then :)

#7 @scribu
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

I like the idea of automatically adding an id attribute.

Closing as duplicate of #16413

#8 @scribu
5 years ago

  • Component changed from General to Administration
  • Keywords needs-patch 3.3-early added; ui-feedback removed
  • Milestone set to Future Release
  • Resolution duplicate deleted
  • Status changed from closed to reopened

On second thought, #16413 seems pretty messy.

Automatically wrapping sections in a div and adding id attributes to field rows is a piece of cake.

#9 @griffinjt
5 years ago

That would be perfect. Just something to differentiate between sections is all that is needed :)

@scribu
5 years ago

#10 @scribu
5 years ago

  • Keywords has-patch added; needs-patch removed

I figured that a "settings-field" class isn't necessary, since you can target fields using .form-table tr.

Version 0, edited 5 years ago by scribu (next)

#11 @nacin
5 years ago

They may not remain tables for long.

@scribu
5 years ago

Added settings-field class

#12 @scribu
5 years ago

Good point; updated patch.

#13 @scribu
5 years ago

  • Keywords 3.3-early removed
  • Milestone changed from Future Release to 3.3

If we make no progress on the settings api at all, we can at least do this and it will be a nice step forward.

#14 @griffinjt
5 years ago

Agreed. Simple and can let us have a little more control over appearances. :)

#15 @ryan
5 years ago

  • Milestone changed from 3.3 to Awaiting Review

Punting enhancements from 3.3.

#16 @ryan
5 years ago

  • Milestone changed from Awaiting Review to Future Release

#17 @chriscct7
22 months ago

  • Keywords dev-feedback added

#18 @DrewAPicture
22 months ago

  • Keywords needs-refresh added

#19 @chriscct7
8 months ago

  • Keywords good-first-bug added; dev-feedback removed

@ross_ritchey
8 months ago

Add new $args to add_settings_section. Update add_settings_section to include new $args in array. Add wrapper around printout in do_settings_section.

#20 @ross_ritchey
8 months ago

Just put a patch in. First-time patcher - not positive everything was done kosher.

Looking at the history - this looks like something that could be a good little enhancement. I kept backwards-compatibility while also pushing towards more logical handling. Not sure if there is a way to degrade the current add_settings_section arguments to a single $args array without breaking compatibility - but could be nice if there was.

#21 @chriscct7
8 months ago

  • Owner set to chriscct7
  • Status changed from reopened to reviewing
Note: See TracTickets for help on using tickets.