diff --git a/lib/client-assets.php b/lib/client-assets.php index b68c2fa5c99036..d8792b5fa2e963 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -1602,14 +1602,18 @@ function gutenberg_editor_scripts_and_styles( $hook ) { 'maxUploadFileSize' => $max_upload_size, 'allowedMimeTypes' => get_allowed_mime_types(), 'styles' => $styles, - 'postLock' => $lock_details, // Ideally, we'd remove this and rely on a REST API endpoint. + 'postLock' => $lock_details, 'postLockUtils' => array( 'nonce' => wp_create_nonce( 'lock-post_' . $post->ID ), 'unlockNonce' => wp_create_nonce( 'update-post_' . $post->ID ), 'ajaxUrl' => admin_url( 'admin-ajax.php' ), ), + + // Whether or not to load the 'postcustom' meta box is stored as a user meta + // field so that we're not always loading its assets. + 'enableCustomFields' => (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ), ); $post_autosave = gutenberg_get_autosave_newer_than_post_save( $post ); diff --git a/lib/meta-box-partial-page.php b/lib/meta-box-partial-page.php index e50aaffb8c3a40..b77492bbbb87ac 100644 --- a/lib/meta-box-partial-page.php +++ b/lib/meta-box-partial-page.php @@ -113,7 +113,6 @@ function gutenberg_filter_meta_boxes( $meta_boxes ) { $core_normal_meta_boxes = array( 'revisionsdiv', 'postexcerpt', - 'postcustom', 'trackbacksdiv', 'commentstatusdiv', 'commentsdiv', @@ -121,6 +120,13 @@ function gutenberg_filter_meta_boxes( $meta_boxes ) { 'authordiv', ); + // Whether or not to load the 'postcustom' meta box is stored as a user meta + // field so that we're not always loading its assets. + $enable_custom_fields = (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ); + if ( ! $enable_custom_fields ) { + $core_normal_meta_boxes[] = 'postcustom'; + } + $taxonomy_callbacks_to_unset = array( 'post_tags_meta_box', 'post_categories_meta_box', @@ -298,6 +304,10 @@ function the_gutenberg_metaboxes() {
+
+ + +