From 71f37fe636dcdf5b69f833fdafe636262c002127 Mon Sep 17 00:00:00 2001 From: whyisjake Date: Tue, 8 Jun 2021 22:38:58 +0000 Subject: [PATCH] Editor: Ensure that the block editor can be used on the page post type. Additionally, add a notice for when you are editing the "latest posts" page. Fixes #45537. Props cameronjonesweb, swissspidy, hannahmalcolm, Fantasy1125, ArnaudBan, grantmkin, youknowriad, knutsp, SergeyBiryukov, audrasjb, whyisjake. Built from https://develop.svn.wordpress.org/trunk@51116 git-svn-id: http://core.svn.wordpress.org/trunk@50725 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-blocks.php | 4 ++++ wp-admin/includes/post.php | 5 ----- wp-admin/includes/template.php | 17 +++++++++++++++++ wp-includes/version.php | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/wp-admin/edit-form-blocks.php b/wp-admin/edit-form-blocks.php index 71328d0ad5..408806b125 100644 --- a/wp-admin/edit-form-blocks.php +++ b/wp-admin/edit-form-blocks.php @@ -313,6 +313,10 @@ $script = sprintf( ); wp_add_inline_script( 'wp-edit-post', $script ); +if ( (int) get_option( 'page_for_posts' ) === (int) $post->ID ) { + add_action( 'admin_enqueue_scripts', '_wp_block_editor_posts_page_notice' ); +} + require_once ABSPATH . 'wp-admin/admin-header.php'; ?> diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index c208c3dae3..9b66f92d21 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -2134,11 +2134,6 @@ function use_block_editor_for_post( $post ) { return false; } - // The posts page can't be edited in the block editor. - if ( absint( get_option( 'page_for_posts' ) ) === $post->ID && empty( $post->post_content ) ) { - return false; - } - $use_block_editor = use_block_editor_for_post_type( $post->post_type ); /** diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 8e22630d6a..fedf3fcbc9 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -2674,3 +2674,20 @@ function wp_star_rating( $args = array() ) { function _wp_posts_page_notice() { echo '

' . __( 'You are currently editing the page that shows your latest posts.' ) . '

'; } + +/** + * Output a notice when editing the page for posts in the block editor (internal use only). + * + * @ignore + * @since 5.8.0 + */ +function _wp_block_editor_posts_page_notice() { + wp_add_inline_script( + 'wp-notices', + sprintf( + 'wp.data.dispatch( "core/notices" ).createWarningNotice( "%s", { isDismissible: false } )', + __( 'You are currently editing the page that shows your latest posts.' ) + ), + 'after' + ); +} diff --git a/wp-includes/version.php b/wp-includes/version.php index 6c0e8509e5..35de626733 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.8-alpha-51115'; +$wp_version = '5.8-alpha-51116'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.