From a6c26ca0f2e18a5a673aa7f3f5211fa4ad79deca Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Mon, 7 Jan 2019 20:58:09 +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. Merges [44437] to the 5.0 branch. Fixes #45453. git-svn-id: https://develop.svn.wordpress.org/branches/5.0@44440 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 1bfd133e4a..60785ea6d1 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 ac45596914..fc6ae19ece 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 42a44b5e2c..8fe57ae008 100644 --- a/src/wp-admin/post.php +++ b/src/wp-admin/post.php @@ -150,6 +150,8 @@ case 'edit': $post_new_file = "post-new.php?post_type=$post_type"; } + $title = $post_type_object->labels->edit_item; + /** * Allows replacement of the editor. * @@ -174,8 +176,7 @@ case 'edit': wp_enqueue_script('autosave'); } - $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');