diff --git a/lib/client-assets.php b/lib/client-assets.php index c1a6e847bba5e9..7d501fc6c263e6 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -1031,7 +1031,7 @@ function gutenberg_get_available_image_sizes() { function gutenberg_editor_scripts_and_styles( $hook ) { $is_demo = isset( $_GET['gutenberg-demo'] ); - global $wp_scripts; + global $wp_scripts, $wp_meta_boxes; // Add "wp-hooks" as dependency of "heartbeat". $heartbeat_script = $wp_scripts->query( 'heartbeat', 'registered' ); @@ -1332,15 +1332,18 @@ function gutenberg_editor_scripts_and_styles( $hook ) { $editor_settings['templateLock'] = ! empty( $post_type_object->template_lock ) ? $post_type_object->template_lock : false; } - $init_script = <<id ) && isset( $wp_meta_boxes[ $current_screen->id ]['normal']['core'] ) ) { + $core_meta_boxes = $wp_meta_boxes[ $current_screen->id ]['normal']['core']; + } + + // Check if the Custom Fields meta box has been removed at some point. + if ( ! isset( $core_meta_boxes['postcustom'] ) || ! $core_meta_boxes['postcustom'] ) { + unset( $editor_settings['enableCustomFields'] ); + } /** * Filters the settings to pass to the block editor. @@ -1352,6 +1355,16 @@ function gutenberg_editor_scripts_and_styles( $hook ) { */ $editor_settings = apply_filters( 'block_editor_settings', $editor_settings, $post ); + $init_script = <<post_type, diff --git a/packages/edit-post/src/components/options-modal/index.js b/packages/edit-post/src/components/options-modal/index.js index 51b40719eb4881..1d6528815b59ce 100644 --- a/packages/edit-post/src/components/options-modal/index.js +++ b/packages/edit-post/src/components/options-modal/index.js @@ -10,7 +10,7 @@ import { Modal } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { withSelect, withDispatch } from '@wordpress/data'; import { compose } from '@wordpress/compose'; -import { PostTaxonomies, PostExcerptCheck, PageAttributesCheck } from '@wordpress/editor'; +import { PostTaxonomies, PostExcerptCheck, PageAttributesCheck, PostFeaturedImageCheck, PostTypeSupportCheck } from '@wordpress/editor'; /** * Internal dependencies @@ -25,7 +25,7 @@ import MetaBoxesSection from './meta-boxes-section'; const MODAL_NAME = 'edit-post/options'; -export function OptionsModal( { isModalActive, closeModal } ) { +export function OptionsModal( { isModalActive, isViewable, closeModal } ) { if ( ! isModalActive ) { return null; } @@ -42,7 +42,9 @@ export function OptionsModal( { isModalActive, closeModal } ) {
- + { isViewable && ( + + ) } ( ) } /> - + + + - + + + @@ -66,9 +72,16 @@ export function OptionsModal( { isModalActive, closeModal } ) { } export default compose( - withSelect( ( select ) => ( { - isModalActive: select( 'core/edit-post' ).isModalActive( MODAL_NAME ), - } ) ), + withSelect( ( select ) => { + const { getEditedPostAttribute } = select( 'core/editor' ); + const { getPostType } = select( 'core' ); + const postType = getPostType( getEditedPostAttribute( 'type' ) ); + + return { + isModalActive: select( 'core/edit-post' ).isModalActive( MODAL_NAME ), + isViewable: get( postType, [ 'viewable' ], false ), + }; + } ), withDispatch( ( dispatch ) => { return { closeModal: () => dispatch( 'core/edit-post' ).closeModal(), diff --git a/packages/edit-post/src/components/options-modal/test/__snapshots__/index.js.snap b/packages/edit-post/src/components/options-modal/test/__snapshots__/index.js.snap index 1367ebd0834191..94d989e492e4a0 100644 --- a/packages/edit-post/src/components/options-modal/test/__snapshots__/index.js.snap +++ b/packages/edit-post/src/components/options-modal/test/__snapshots__/index.js.snap @@ -25,27 +25,34 @@ exports[`OptionsModal should match snapshot when the modal is active 1`] = `
- - + + + - + + +