Skip to content

Commit

Permalink
Editor: Add no-js fallback for site editor.
Browse files Browse the repository at this point in the history
Add a fallback condition with heading and error notice to handle a no JavaScript state for the site editor, comparable to what already exists in the post editor. 

Props afercia, joedolson, fencermonir, zebaafiashama, alexstine, rudlinkon.
Fixes #56228.

git-svn-id: https://develop.svn.wordpress.org/trunk@56025 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
joedolson committed Jun 25, 2023
1 parent ba4ada5 commit aef1cb9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/wp-admin/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,8 @@ code {
margin: 10px 20px 0 2px;
}

.wrap.block-editor-no-js {
.wrap.block-editor-no-js,
.wrap.site-editor-no-js {
padding-left: 20px;
}

Expand Down
25 changes: 24 additions & 1 deletion src/wp-admin/site-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,30 @@ static function( $classes ) {
require_once ABSPATH . 'wp-admin/admin-header.php';
?>

<div id="site-editor" class="edit-site"></div>
<div class="edit-site">
<div id="site-editor"></div>

<?php // JavaScript is disabled. ?>
<div class="wrap hide-if-js site-editor-no-js">
<h1 class="wp-heading-inline"><?php _e( 'Edit site' ); ?></h1>
<div class="notice notice-error notice-alt">
<p>
<?php
/**
* Filters the message displayed in the site editor interface when JavaScript is
* not enabled in the browser.
*
* @since 6.3.0
*
* @param string $message The message being displayed.
* @param WP_Post $post The post being edited.
*/
echo apply_filters( 'site_editor_no_javascript_message', __( 'The site editor requires JavaScript. Please enable JavaScript in your browser settings.' ), $post );
?>
</p>
</div>
</div>
</div>

<?php

Expand Down

0 comments on commit aef1cb9

Please sign in to comment.