WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#29758 closed enhancement (fixed)

Contextual Customizer Panels and Sections

Reported by: celloexpressions Owned by:
Milestone: 4.1 Priority: normal
Severity: normal Version: 4.0
Component: Customize Keywords: has-patch
Focuses: javascript Cc:

Description

This is almost a bug, as most developers expect it to be present. The reason we haven't done it yet is that there is no JS API for sections or panels (which were based on sections). Now that #28709 is happening (probably in 4.1), we can complete the contextual Customizer objects API by adding support for active_callback to panels and sections.

I have a starter patch for the PHP side of the API, essentially porting the relevant sections from WP_Customize_Control to WP_Customize_Panel and WP_Customize_Section. Once #28709 happens, we can add the JS side in here as well. API-wise, contextual sections and panels should work identically to contextual controls, with the three means of adding them (note that custom panels and custom sections work, just like custom controls).

See #27993.

Attachments (2)

29758.php.diff (4.6 KB) - added by celloexpressions 3 years ago.
PHP side of the API only, not yet functional. Once JS API is in place, we can build out contextuality there as well.
29758.2.diff (10.0 KB) - added by westonruter 2 years ago.
https://github.com/xwpco/wordpress-develop/commit/1d2034b2205aa171e2c1d00c43749d002b42b244

Download all attachments as: .zip

Change History (9)

@celloexpressions
3 years ago

PHP side of the API only, not yet functional. Once JS API is in place, we can build out contextuality there as well.

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


2 years ago

#2 @westonruter
2 years ago

I've added the JS API in 29758.2.diff. Note that this patch is for the work being done on #28709, so it won't apply to trunk directly. It's all part of #28709.

#3 @ocean90
2 years ago

In 30102:

Improve/introduce Customizer JavaScript models for Controls, Sections, and Panels.

  • Introduce models for panels and sections.
  • Introduce API to expand and focus a control, section or panel.
  • Allow deep-linking to panels, sections, and controls inside of the Customizer.
  • Clean up accordion.js, removing all Customizer-specific logic.
  • Add initial unit tests for wp.customize.Class in customize-base.js.

https://make.wordpress.org/core/2014/10/27/toward-a-complete-javascript-api-for-the-customizer/ provides an overview of how to use the JavaScript API.

props westonruter, celloexpressions, ryankienstra.
see #28032, #28579, #28580, #28650, #28709, #29758.
fixes #29529.

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


2 years ago

#5 @celloexpressions
2 years ago

Looks like this works. See #29578 for implementing it in Twenty Fourteen as a bundled example.

#6 @celloexpressions
2 years ago

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

Working in trunk with Twenty Fourteen. Please reopen if any issues pop up. Testing is particularly needed for the various means of doing an active callback - via subclasses, the filter, etc. for both sections and panels.

#7 @westonruter
2 years ago

Customizer sections for widget areas (sidebars) are being updated in #30235 to take advantage of this new API to make the sections contextual based on whether or not a sidebar was used in the preview.

Note: See TracTickets for help on using tickets.