Make WordPress Core

Opened 7 years ago

Last modified 6 years ago

#42635 new enhancement

Customize: Add default value for customizeAction param for sections

Reported by: westonruter's profile westonruter Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.3
Component: Customize Keywords: needs-patch
Focuses: Cc:

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' ) )
                )
        );
} );

Change History (1)

#1 @peterwilsoncc
6 years ago

  • Milestone changed from 5.0 to Future Release

Switching milestone due to the focus on the new editor (Gutenberg) for WordPress 5.0.

Note: See TracTickets for help on using tickets.