In addition to the ~35 defects that were fixed in this release, there were also ~17 features and enhancements that were made. What follows are some highlights, starting with some smaller enhancements and then listing out full posts that document the larger features.
Setting-less Controls (#35926)
Sometimes controls need to be added which don’t directly have associated settings. For example, there can be controls needed which manipulate some aspect of the Customizer interface or manage the behavior of other controls and their settings: consider a control for managing repeating controls, where the button only serves to create other controls and their settings. When nav menus were added in the Customizer in 4.3, the UI for creating a new menu involved two controls which had custom settings associated them (create_new_menu and new_menu_name) which served no purpose other than to make sure the control wouldn’t raise an error. The settings had custom types to prevent them from getting saved to the DB.
In 4.5, controls are no longer required to have associated settings. By default registering a control without an explicit settings
argument will result in the control’s own id
being supplied as the associated setting id
. To explicitly register a control without any associated settings, pass an empty array as the settings
:
$wp_customize->add_control( 'new-post', array( 'section' => 'title_tagline', 'settings' => array(), 'type' => 'button', 'input_attrs' => array( 'value' => __( 'Add Post' ), ), 'capability' => 'edit_posts', ) );
Because controls no longer require settings, controls now accept a capability
argument (as seen above) whereas previously a control’s capability would depend on the capabilities of its associated settings. A control will not be displayed if it has a defined capability
which the user doesn’t have, or if the user doesn’t have the capability
required for any of the associated settings. If you omit the capability
for a setting-less control, it will be displayed to all users (who can customize
).
Other Improvements
- Shift-click on nav menu items in preview to open corresponding control in Customizer pane (#26005).
- Shift-click on site title and tagline for Core themes and any that implement selective refresh partials for these settings. Focus on the control for any setting in the preview by sending a
focus-control-for-setting
message to the pane, passing the setting ID. This is used to focus on controls when a shift-click is done on a selective refresh partial. - Site title and tagline will be updated via selective refresh in core themes. (#33738)
WP_Customize_Manager::add_*()
methods now return the added instance. (#34596)WP_Customize_Manager::add_setting()
now applies the relevant dynamic setting filters. (#34597)- There is a new
customize_nav_menu_searched_items
filter for nav menu item searches. (#34947) - The
WP_Customize_Media_Control
now allows itsbutton_labels
to be overridden. (#35542) - The setting models in the preview now have a
id
property and_dirty
flag to correspond to the settings in the pane; dynamically created settings in the pane will be created in the preview. (#35616) - More config settings are exported to the preview to allow the preview to do more operations inline, including more nonces, the current theme, and the previewed URL. (#35617)
Dedicated Feature Posts
Device Preview (#31195)
Selective Refresh (#27355)
Custom Logo (#33755)
Customizer Improvements in 4.5 by Weston Ruter was originally posted at https://make.wordpress.org/core/2016/03/10/customizer-improvements-in-4-5/
No comments:
Post a Comment