Make WordPress Core

Ticket #45282: 45282.diff

File 45282.diff, 4.0 KB (added by pento, 6 years ago)
  • src/wp-admin/edit-form-blocks.php

    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' ) ) { 
    1919 * @global WP_Post      $post
    2020 * @global string       $title
    2121 * @global array        $editor_styles
     22 * @global array        $wp_meta_boxes
    2223 */
    23 global $post_type, $post_type_object, $post, $title, $editor_styles;
     24global $post_type, $post_type_object, $post, $title, $editor_styles, $wp_meta_boxes;
    2425
    2526if ( ! empty( $post_type_object ) ) {
    2627        $title = $post_type_object->labels->edit_item;
    $init_script = <<<JS 
    341342} )();
    342343JS;
    343344
    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 
    364345/**
    365346 * Scripts
    366347 */
    register_and_do_post_meta_boxes( $post ); 
    397378/** This action is documented in wp-admin/edit-form-advanced.php */
    398379do_action( 'edit_form_advanced', $post );
    399380
     381if ( ! 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);
     402wp_add_inline_script( 'wp-edit-post', $script );
     403
    400404require_once( ABSPATH . 'wp-admin/admin-header.php' );
    401405?>
    402406
  • src/wp-admin/includes/meta-boxes.php

    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 ) { 
    13611361                add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
    13621362
    13631363        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 );
    13681369        }
    13691370
    13701371        /**
  • src/wp-admin/includes/template.php

    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 ) { 
    10761076                                        }
    10771077
    10781078                                        $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' : '';
    10801080                                        echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n";
    10811081                                        if ( 'dashboard_browser_nag' != $box['id'] ) {
    10821082                                                $widget_title = $box[ 'title' ];