diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php
index 00fd098ec6..09d5d6f34b 100644
a
|
b
|
if ( ! defined( 'ABSPATH' ) ) { |
19 | 19 | * @global WP_Post $post |
20 | 20 | * @global string $title |
21 | 21 | * @global array $editor_styles |
| 22 | * @global array $wp_meta_boxes |
22 | 23 | */ |
23 | | global $post_type, $post_type_object, $post, $title, $editor_styles; |
| 24 | global $post_type, $post_type_object, $post, $title, $editor_styles, $wp_meta_boxes; |
24 | 25 | |
25 | 26 | if ( ! empty( $post_type_object ) ) { |
26 | 27 | $title = $post_type_object->labels->edit_item; |
… |
… |
$init_script = <<<JS |
341 | 342 | } )(); |
342 | 343 | JS; |
343 | 344 | |
344 | | |
345 | | /** |
346 | | * Filters the settings to pass to the block editor. |
347 | | * |
348 | | * @since 5.0.0 |
349 | | * |
350 | | * @param array $editor_settings Default editor settings. |
351 | | * @param WP_Post $post Post being edited. |
352 | | */ |
353 | | $editor_settings = apply_filters( 'block_editor_settings', $editor_settings, $post ); |
354 | | |
355 | | $script = sprintf( |
356 | | $init_script, |
357 | | $post->post_type, |
358 | | $post->ID, |
359 | | wp_json_encode( $editor_settings ), |
360 | | wp_json_encode( $initial_edits ) |
361 | | ); |
362 | | wp_add_inline_script( 'wp-edit-post', $script ); |
363 | | |
364 | 345 | /** |
365 | 346 | * Scripts |
366 | 347 | */ |
… |
… |
register_and_do_post_meta_boxes( $post ); |
397 | 378 | /** This action is documented in wp-admin/edit-form-advanced.php */ |
398 | 379 | do_action( 'edit_form_advanced', $post ); |
399 | 380 | |
| 381 | if ( ! isset( $wp_meta_boxes[ $current_screen->id ]['normal']['core']['postcustom'] ) || ( isset( $wp_meta_boxes[ $current_screen->id ]['normal']['core']['postcustom'] ) && ! $wp_meta_boxes[ $current_screen->id ]['normal']['core']['postcustom'] ) ) { |
| 382 | unset( $editor_settings['enableCustomFields'] ); |
| 383 | } |
| 384 | |
| 385 | /** |
| 386 | * Filters the settings to pass to the block editor. |
| 387 | * |
| 388 | * @since 5.0.0 |
| 389 | * |
| 390 | * @param array $editor_settings Default editor settings. |
| 391 | * @param WP_Post $post Post being edited. |
| 392 | */ |
| 393 | $editor_settings = apply_filters( 'block_editor_settings', $editor_settings, $post ); |
| 394 | |
| 395 | $script = sprintf( |
| 396 | $init_script, |
| 397 | $post->post_type, |
| 398 | $post->ID, |
| 399 | wp_json_encode( $editor_settings ), |
| 400 | wp_json_encode( $initial_edits ) |
| 401 | ); |
| 402 | wp_add_inline_script( 'wp-edit-post', $script ); |
| 403 | |
400 | 404 | require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
401 | 405 | ?> |
402 | 406 | |
diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php
index 50b871321c..97ca20a193 100644
a
|
b
|
function register_and_do_post_meta_boxes( $post ) { |
1361 | 1361 | add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); |
1362 | 1362 | |
1363 | 1363 | if ( post_type_supports($post_type, 'custom-fields') ) { |
1364 | | $screen = get_current_screen(); |
1365 | | if ( ! $screen || ! $screen->is_block_editor() || (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ) ) { |
1366 | | add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => false, '__block_editor_compatible_meta_box' => true ) ); |
1367 | | } |
| 1364 | $args = array( |
| 1365 | '__back_compat_meta_box' => ! (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ), |
| 1366 | '__block_editor_compatible_meta_box' => true |
| 1367 | ); |
| 1368 | add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', null, 'normal', 'core', $args ); |
1368 | 1369 | } |
1369 | 1370 | |
1370 | 1371 | /** |
diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php
index f9c2a799cc..5ab2b25fad 100644
a
|
b
|
function do_meta_boxes( $screen, $context, $object ) { |
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | $i++; |
1079 | | $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : ''; |
| 1079 | $hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden ) ) ? ' hide-if-js' : ''; |
1080 | 1080 | echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n"; |
1081 | 1081 | if ( 'dashboard_browser_nag' != $box['id'] ) { |
1082 | 1082 | $widget_title = $box[ 'title' ]; |