Block Editor: Display notice to the user when JavaScript is disabled.

Currently, when viewing the block editor with JavaScript disabled, the user sees a blank admin page with the admin menu sidebar. This adds an admin notice informing the user that JavaScript is required for the new block editor.

Props mkaz, pento, azaozz, ocean90, desrosj.
Fixes #45453.
Built from https://develop.svn.wordpress.org/trunk@44437


git-svn-id: http://core.svn.wordpress.org/trunk@44268 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
desrosj 2019-01-07 20:40:50 +00:00
parent 8917b0e89f
commit f082806afa
7 changed files with 43 additions and 11 deletions

View File

@ -560,6 +560,10 @@ code {
margin: 10px 2px 0 20px;
}
.wrap.block-editor-no-js {
padding-right: 20px;
}
.wrap > h2:first-child, /* Back-compat for pre-4.4 */
.wrap [class$="icon32"] + h2, /* Back-compat for pre-4.4 */
.postbox .inside h2, /* Back-compat for pre-4.4 */

File diff suppressed because one or more lines are too long

View File

@ -560,6 +560,10 @@ code {
margin: 10px 20px 0 2px;
}
.wrap.block-editor-no-js {
padding-left: 20px;
}
.wrap > h2:first-child, /* Back-compat for pre-4.4 */
.wrap [class$="icon32"] + h2, /* Back-compat for pre-4.4 */
.postbox .inside h2, /* Back-compat for pre-4.4 */

File diff suppressed because one or more lines are too long

View File

@ -23,10 +23,6 @@ if ( ! defined( 'ABSPATH' ) ) {
*/
global $post_type, $post_type_object, $post, $title, $editor_styles, $wp_meta_boxes;
if ( ! empty( $post_type_object ) ) {
$title = $post_type_object->labels->edit_item;
}
// Flag that we're loading the block editor.
$current_screen = get_current_screen();
$current_screen->is_block_editor( true );
@ -399,9 +395,36 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
?>
<div class="block-editor">
<h1 class="screen-reader-text"><?php echo esc_html( $post_type_object->labels->edit_item ); ?></h1>
<div id="editor" class="block-editor__container"></div>
<h1 class="screen-reader-text hide-if-no-js"><?php echo esc_html( $title ); ?></h1>
<div id="editor" class="block-editor__container hide-if-no-js"></div>
<div id="metaboxes" class="hidden">
<?php the_block_editor_meta_boxes(); ?>
</div>
<?php // JavaScript is disabled. ?>
<div class="wrap hide-if-js block-editor-no-js">
<h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
<div class="notice notice-error notice-alt">
<p>
<?php
$message = sprintf(
/* translators: %s: https://wordpress.org/plugins/classic-editor/ */
__( 'The block editor requires JavaScript. Please enable JavaScript in your browser settings, or try the <a href="%s">Classic Editor plugin</a>.' ),
__( 'https://wordpress.org/plugins/classic-editor/' )
);
/**
* Filters the message displayed in the block editor interface when JavaScript is
* not enabled in the browser.
*
* @since 5.0.3
*
* @param string $message The message being displayed.
* @param WP_Post $post The post being edited.
*/
echo apply_filters( 'block_editor_no_javascript_message', $message, $post );
?>
</p>
</div>
</div>
</div>

View File

@ -154,6 +154,8 @@ switch ( $action ) {
$post_new_file = "post-new.php?post_type=$post_type";
}
$title = $post_type_object->labels->edit_item;
/**
* Allows replacement of the editor.
*
@ -179,8 +181,7 @@ switch ( $action ) {
}
}
$title = $post_type_object->labels->edit_item;
$post = get_post( $post_id, OBJECT, 'edit' );
$post = get_post( $post_id, OBJECT, 'edit' );
if ( post_type_supports( $post_type, 'comments' ) ) {
wp_enqueue_script( 'admin-comments' );

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.1-alpha-44435';
$wp_version = '5.1-alpha-44437';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.