#42635 closed enhancement (maybelater)
Customize: Add default value for customizeAction param for sections
| Reported by: | westonruter | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Customize | Version: | 4.3 |
| Severity: | normal | Keywords: | needs-patch |
| Cc: | Focuses: |
Description
Currently the customizeAction has to be explicitly provided when dynamically adding sections via JS. If not, then the section header has broken layout. There should be a default value provided so that this doesn't have to be provided each time (see #42083). Adding a default value for customizeAction is complicated a bit by the fact that it varies based on whether the section has a parent panel. The getContainer method of wp.customize.Section probably should check if customizeAction is empty and if so supply one: it could look to see if it has a panel parent, and if so, grab the title; otherwise, it can use the default “Customizing” value. A default value should have been originally provided in #30737.
Workaround for plugins to provide a default value in the mean time:
<?php add_action( 'customize_controls_enqueue_scripts', function() { wp_add_inline_script( 'customize-controls', sprintf( 'wp.customize.Section.prototype.defaults.customizeAction = %s;', wp_json_encode( __( 'Customizing' ) ) ) ); } );
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Switching milestone due to the focus on the new editor (Gutenberg) for WordPress 5.0.