From c7fb3b36ea575ef423f6bd019f3ea08d3d5d35cf Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Mon, 7 Jan 2019 20:39:56 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@44437 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/css/common.css | 4 ++++ src/wp-admin/edit-form-blocks.php | 35 +++++++++++++++++++++++++------ src/wp-admin/post.php | 5 +++-- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/wp-admin/css/common.css b/src/wp-admin/css/common.css index cf9c7ffe43..a8c8e612b6 100644 --- a/src/wp-admin/css/common.css +++ b/src/wp-admin/css/common.css @@ -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 */ diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php index 7cf2fa3663..44cfec14a8 100644 --- a/src/wp-admin/edit-form-blocks.php +++ b/src/wp-admin/edit-form-blocks.php @@ -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' ); ?>
-

labels->edit_item ); ?>

-
+

+
+ + +
+

+
+

+ Classic Editor plugin.' ), + __( '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 ); + ?> +

+
+
diff --git a/src/wp-admin/post.php b/src/wp-admin/post.php index 8799008664..6f95adc17e 100644 --- a/src/wp-admin/post.php +++ b/src/wp-admin/post.php @@ -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' );