Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#29324 closed enhancement (fixed)

Customizer Panels should have render_content to facilitate subclasses

Reported by: celloexpressions's profile celloexpressions Owned by: ocean90's profile ocean90
Milestone: 4.1 Priority: low
Severity: normal Version: 4.0
Component: Customize Keywords: has-patch commit
Focuses: Cc:

Description

Like everything else in the Customizer, panels can be subclassed. This allows developers to override the behavior of a panel, or even to completely replace its contents with something other than controls or sections.

Customizer Controls have two functions for rendering the control: render, which renders the control container markup with all of the classes and ids that controls should (almost) always have, and render_content, which renders the contents of the control markup. Most custom controls only need to override render_content, allowing the required core markup added by render to continue functioning without duplicating code.

Panels should similarly use separate functions to render their containers and their contents. The container, in this case, would be the panel title in the top-level controls, the back button, and the container for the different control sections that would normally be added to a panel. The contents would be the in-panel panel heading (section that says "you are customizing..." and has the description as its contents) and the code that renders all sections in the panel.

It doesn't really make sense to do this with sections, as the contents consists only of controls, and custom controls can be created to completely alter the contents of sections. But we should add it to panels, where it may be necessary to do things differently in some instances.

While it would be best if this were in 4.0, I think it should actually be back-compat if we introduce it in 4.1, as anyone overriding the panel's contents would have been overriding the render function, so they wouldn't be calling render_content anyway.

Attachments (1)

29324.diff (2.4 KB) - added by celloexpressions 10 years ago.

Download all attachments as: .zip

Change History (7)

#1 @helen
10 years ago

  • Type changed from defect (bug) to enhancement

#2 @celloexpressions
10 years ago

  • Milestone changed from Awaiting Review to 4.1

Noting that it's likely that few people if any will make custom panels, although that's largely because custom sections (and panels) are undocumented. I'm going to be changing that in the near future, so it would be nice to clean up our API a bit here.

I do think that this is more of a bug/oversight, and think @helen changed the type mostly for 4.0-triaging, but I'll let someone else change that if they agree :)

#3 @celloexpressions
10 years ago

  • Priority changed from normal to low

#4 @celloexpressions
10 years ago

  • Keywords commit added

This should be ready for commit.

This ticket was mentioned in IRC in #wordpress-dev by celloexpressions. View the logs.


10 years ago

#6 @ocean90
10 years ago

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

In 29950:

Customizer: Extract content markup for panels to its own method, WP_Customize_Panel::render_content().

This allows to override the behavior of a panel, or even to completely replace its contents with something other than controls or sections.

props celloexpressions.
fixes #29324.

Note: See TracTickets for help on using tickets.