#38794 closed enhancement (fixed)
Customize: Allow panels and sections to have notifications just like controls can
Reported by: | westonruter | Owned by: | westonruter |
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | normal | Version: | 4.6 |
Component: | Customize | Keywords: | has-patch has-screenshots has-dev-note |
Focuses: | Cc: | ||
PR Number: |
Description (last modified by )
In #34893, the ability to show notifications on controls was added. In #35210 this is proposed to be extended at a global level to be able to show notifications at the root of the customizer. Between these two ends, there should also be the ability to show notifications at the panel and section level.
The Customize Posts plugin implements notifications for sections which could serve as a start for the patch here: https://github.com/xwp/wp-customize-posts/blob/0.8.2/js/customize-post-section.js#L825-L942
Once implemented, section notifications should be utilized for the Header Media section to show a notification when not previewing a URL that is eligible for a header video. See #38778. The section-level notification could be used in #40432 as well.
For more sample code, see:
- https://github.com/xwp/wp-customize-featured-content-demo/blob/8bf4d65/js/featured-items-panel.js#L45
- https://github.com/xwp/wp-customize-featured-content-demo/blob/8bf4d65/js/featured-items-panel.js#L69-L116
- https://github.com/xwp/wp-customize-featured-content-demo/blob/c748adf/php/class-featured-items-customize-panel.php#L47-L63
Attachments (5)
Change History (16)
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
3 years ago
#5
@
3 years ago
- Milestone changed from 4.8 to 4.8.1
Punting to 4.8.1 per bug scrub earlier this week.
#8
@
2 years ago
Handy reference to add a slew of notifications to all 4 contexts where they can appear (global, panel, section, control):
// Add global notifications. _( [ 'none', 'error', 'warning', 'info', 'success' ] ).each( function( type ) { var code = 'example-' + type; wp.customize.notifications.add( code, new wp.customize.Notification( code, { dismissible: true, message: 'This is a sample ' + type + ' message.', type: type } ) ); } ); // Add notifications to the Widgets panel. _( [ 'none', 'error', 'warning', 'info', 'success' ] ).each( function( type ) { var code = 'example-' + type; wp.customize.panel( 'widgets' ).notifications.add( code, new wp.customize.Notification( code, { dismissible: true, message: 'This is a sample ' + type + ' message.', type: type } ) ); } ); // Add notifications to the Site Identity section. _( [ 'none', 'error', 'warning', 'info', 'success' ] ).each( function( type ) { var code = 'example-' + type; wp.customize.section( 'title_tagline' ).notifications.add( code, new wp.customize.Notification( code, { dismissible: true, message: 'This is a sample ' + type + ' message.', type: type } ) ); } ); // Add notifications to the site title control. _( [ 'none', 'error', 'warning', 'info', 'success' ] ).each( function( type ) { var code = 'example-' + type; wp.customize.control( 'blogname' ).notifications.add( code, new wp.customize.Notification( code, { dismissible: true, message: 'This is a sample ' + type + ' message.', type: type } ) ); } );
#9
@
2 years ago
- Owner set to westonruter
- Resolution set to fixed
- Status changed from new to closed
In 41390:
While it's probably generally a better practice to use control-specific descriptions and notifications, header media is a good example of where it can make sense to do this for certain sections and panels. Another potential use case could be an info notification in the menus panel when there are no menus that invites users to create their first menu and assign it to their theme's locations.