Opened 10 years ago
Closed 10 years ago
#29324 closed enhancement (fixed)
Customizer Panels should have render_content to facilitate subclasses
Reported by: | celloexpressions | Owned by: | 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.
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 :)