Make WordPress Core


Ignore:
Timestamp:
12/16/2018 11:23:38 PM (6 years ago)
Author:
SergeyBiryukov
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.
Merges [43885] to trunk.
See #45282.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-admin/includes/meta-boxes.php

    r44214 r44244  
    14641464
    14651465    if ( post_type_supports( $post_type, 'custom-fields' ) ) {
    1466         add_meta_box( 'postcustom', __( 'Custom Fields' ), 'post_custom_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
     1466        $args = array(
     1467            '__back_compat_meta_box'             => ! (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ),
     1468            '__block_editor_compatible_meta_box' => true,
     1469        );
     1470        add_meta_box( 'postcustom', __( 'Custom Fields' ), 'post_custom_meta_box', null, 'normal', 'core', $args );
    14671471    }
    14681472
Note: See TracChangeset for help on using the changeset viewer.