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
This commit is contained in:
whyisjake 2021-06-08 22:38:58 +00:00
parent 1b7df89e93
commit 71f37fe636
4 changed files with 22 additions and 6 deletions

View File

@ -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';
?>

View File

@ -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 );
/**

View File

@ -2674,3 +2674,20 @@ function wp_star_rating( $args = array() ) {
function _wp_posts_page_notice() {
echo '<div class="notice notice-warning inline"><p>' . __( 'You are currently editing the page that shows your latest posts.' ) . '</p></div>';
}
/**
* 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'
);
}

View File

@ -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.