Make WordPress Core

Changeset 51116


Ignore:
Timestamp:
06/08/2021 10:37:34 PM (3 years ago)
Author:
whyisjake
Message:

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.

Location:
trunk/src/wp-admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-blocks.php

    r51090 r51116  
    314314wp_add_inline_script( 'wp-edit-post', $script );
    315315
     316if ( (int) get_option( 'page_for_posts' ) === (int) $post->ID ) {
     317    add_action( 'admin_enqueue_scripts', '_wp_block_editor_posts_page_notice' );
     318}
     319
    316320require_once ABSPATH . 'wp-admin/admin-header.php';
    317321?>
  • trunk/src/wp-admin/includes/post.php

    r51027 r51116  
    21352135    }
    21362136
    2137     // The posts page can't be edited in the block editor.
    2138     if ( absint( get_option( 'page_for_posts' ) ) === $post->ID && empty( $post->post_content ) ) {
    2139         return false;
    2140     }
    2141 
    21422137    $use_block_editor = use_block_editor_for_post_type( $post->post_type );
    21432138
  • trunk/src/wp-admin/includes/template.php

    r51011 r51116  
    26752675    echo '<div class="notice notice-warning inline"><p>' . __( 'You are currently editing the page that shows your latest posts.' ) . '</p></div>';
    26762676}
     2677
     2678/**
     2679 * Output a notice when editing the page for posts in the block editor (internal use only).
     2680 *
     2681 * @ignore
     2682 * @since 5.8.0
     2683 */
     2684function _wp_block_editor_posts_page_notice() {
     2685    wp_add_inline_script(
     2686        'wp-notices',
     2687        sprintf(
     2688            'wp.data.dispatch( "core/notices" ).createWarningNotice( "%s", { isDismissible: false } )',
     2689            __( 'You are currently editing the page that shows your latest posts.' )
     2690        ),
     2691        'after'
     2692    );
     2693}
Note: See TracChangeset for help on using the changeset viewer.