Customizer: When a block theme is active, add an information about Site Editor in the Customizer.

This change adds an information notice to the customizer when a block theme is active and the customizer is also available (for example when a plugin activates it), to encourage people to use the Site Editor for the best full site customization experience.

Props ironprogrammer, antonvlasenko, Clorith, audrasjb, psmits1567, tobifjellner, costdev, webcommsat, joedolson, pbiron.
Merges [53024] and [53025] to the 5.9 branch.
Fixes #54939.

Built from https://develop.svn.wordpress.org/branches/5.9@53026


git-svn-id: http://core.svn.wordpress.org/branches/5.9@52615 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2022-03-29 20:18:17 +00:00
parent d5e8989d9b
commit 035d87d2a1
9 changed files with 59 additions and 6 deletions

View File

@ -1734,6 +1734,12 @@ p.customize-section-description {
font-weight: 400;
}
#customize-notifications-area .notification-message button.switch-to-editor {
display: block;
margin-top: 6px;
font-weight: 400;
}
#customize-theme-controls .control-panel-themes > .accordion-section-title:after {
display: none;
}

File diff suppressed because one or more lines are too long

View File

@ -1733,6 +1733,12 @@ p.customize-section-description {
font-weight: 400;
}
#customize-notifications-area .notification-message button.switch-to-editor {
display: block;
margin-top: 6px;
font-weight: 400;
}
#customize-theme-controls .control-panel-themes > .accordion-section-title:after {
display: none;
}

File diff suppressed because one or more lines are too long

View File

@ -222,7 +222,7 @@ do_action( 'customize_controls_head' );
<ul></ul>
</div>
<div class="wp-full-overlay-sidebar-content" tabindex="-1">
<div id="customize-info" class="accordion-section customize-info">
<div id="customize-info" class="accordion-section customize-info" data-block-theme="<?php echo (int) wp_is_block_theme(); ?>">
<div class="accordion-section-title">
<span class="preview-notice">
<?php
@ -235,7 +235,7 @@ do_action( 'customize_controls_head' );
<div class="customize-panel-description">
<p>
<?php
_e( 'The Customizer allows you to preview changes to your site before publishing them. You can navigate to different pages on your site within the preview. Edit shortcuts are shown for some editable elements.' );
_e( 'The Customizer allows you to preview changes to your site before publishing them. You can navigate to different pages on your site within the preview. Edit shortcuts are shown for some editable elements. The Customizer is intended for use with non-block themes.' );
?>
</p>
<p>

View File

@ -8334,6 +8334,33 @@
history.replaceState( {}, document.title, urlParser.href );
}
/**
* Displays a Site Editor notification when a block theme is activated.
*
* @since 4.9.0
*
* @param {string} [notification] - A notification to display.
* @return {void}
*/
function addSiteEditorNotification( notification ) {
api.notifications.add( new api.Notification( 'site_editor_block_theme_notice', {
message: notification,
type: 'info',
dismissible: false,
render: function() {
var notification = api.Notification.prototype.render.call( this ),
button = notification.find( 'button.switch-to-editor' );
button.on( 'click', function( event ) {
event.preventDefault();
location.assign( button.data( 'action' ) );
} );
return notification;
}
} ) );
}
/**
* Dismiss autosave.
*
@ -8408,6 +8435,10 @@
if ( api.settings.changeset.latestAutoDraftUuid || api.settings.changeset.hasAutosaveRevision ) {
addAutosaveRestoreNotification();
}
var shouldDisplayBlockThemeNotification = !! parseInt( $( '#customize-info' ).data( 'block-theme' ), 10 );
if (shouldDisplayBlockThemeNotification) {
addSiteEditorNotification( api.l10n.blockThemeNotification );
}
})();
// Check if preview url is valid and load the preview frame.

File diff suppressed because one or more lines are too long

View File

@ -1220,6 +1220,16 @@ function wp_default_scripts( $scripts ) {
'publishSettings' => __( 'Publish Settings' ),
'invalidDate' => __( 'Invalid date.' ),
'invalidValue' => __( 'Invalid value.' ),
'blockThemeNotification' => sprintf(
/* translators: 1: Link to Site Editor documentation on HelpHub, 2: HTML button. */
__( 'Hurray! Your theme supports Full Site Editing with blocks. <a href="%1$s">Tell me more</a>. %2$s' ),
__( 'https://wordpress.org/support/article/site-editor/' ),
sprintf(
'<button type="button" data-action="%1$s" class="button switch-to-editor">%2$s</button>',
esc_url( admin_url( 'site-editor.php' ) ),
__( 'Use Site Editor' )
)
),
)
);
$scripts->add( 'customize-selective-refresh', "/wp-includes/js/customize-selective-refresh$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 );

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9.3-alpha-53022';
$wp_version = '5.9.3-alpha-53026';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.