WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/12/2018 03:37:41 AM (2 years ago)
Author:
pento
Message:

Block Editor: Hide the Custom Fields meta box option if that meta box has been removed.

Some plugins remove the Custom Fields meta box, particularly when they provide functionality that replaces it. The block editor would correctly not display this meta box in these circumstances, but it still showed the option to display or hide it.

Props pento, noisysocks.
See #45282.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-admin/includes/meta-boxes.php

    r43863 r43885  
    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
Note: See TracChangeset for help on using the changeset viewer.