Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment thread
imath marked this conversation as resolved.
Resolved

// Add "wp-hooks" as dependency of "heartbeat".
$heartbeat_script = $wp_scripts->query( 'heartbeat', 'registered' );
Expand Down Expand Up @@ -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 = <<<JS
( function() {
window._wpLoadGutenbergEditor = new Promise( function( resolve ) {
wp.domReady( function() {
resolve( wp.editPost.initializeEditor( 'editor', "%s", %d, %s, %s ) );
} );
} );
} )();
JS;
$current_screen = get_current_screen();
$core_meta_boxes = array();

// Make sure the current screen is set as well as the normal core metaboxes.
if ( isset( $current_screen->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.
Expand All @@ -1352,6 +1355,16 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
*/
$editor_settings = apply_filters( 'block_editor_settings', $editor_settings, $post );

$init_script = <<<JS
( function() {
window._wpLoadGutenbergEditor = new Promise( function( resolve ) {
wp.domReady( function() {
resolve( wp.editPost.initializeEditor( 'editor', "%s", %d, %s, %s ) );
} );
} );
} )();
JS;
Comment thread
imath marked this conversation as resolved.
Resolved

$script = sprintf(
$init_script,
$post->post_type,
Expand Down
29 changes: 21 additions & 8 deletions packages/edit-post/src/components/options-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -42,7 +42,9 @@ export function OptionsModal( { isModalActive, closeModal } ) {
<EnableTipsOption label={ __( 'Enable Tips' ) } />
</Section>
<Section title={ __( 'Document Panels' ) }>
<EnablePanelOption label={ __( 'Permalink' ) } panelName="post-link" />
{ isViewable && (
<EnablePanelOption label={ __( 'Permalink' ) } panelName="post-link" />
) }
<PostTaxonomies
taxonomyWrapper={ ( content, taxonomy ) => (
<EnablePanelOption
Expand All @@ -51,11 +53,15 @@ export function OptionsModal( { isModalActive, closeModal } ) {
/>
) }
/>
<EnablePanelOption label={ __( 'Featured Image' ) } panelName="featured-image" />
<PostFeaturedImageCheck>
<EnablePanelOption label={ __( 'Featured Image' ) } panelName="featured-image" />
</PostFeaturedImageCheck>
<PostExcerptCheck>
<EnablePanelOption label={ __( 'Excerpt' ) } panelName="post-excerpt" />
</PostExcerptCheck>
<EnablePanelOption label={ __( 'Discussion' ) } panelName="discussion-panel" />
<PostTypeSupportCheck supportKeys={ [ 'comments', 'trackbacks' ] }>
<EnablePanelOption label={ __( 'Discussion' ) } panelName="discussion-panel" />
</PostTypeSupportCheck>
<PageAttributesCheck>
<EnablePanelOption label={ __( 'Page Attributes' ) } panelName="page-attributes" />
</PageAttributesCheck>
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,34 @@ exports[`OptionsModal should match snapshot when the modal is active 1`] = `
<Section
title="Document Panels"
>
<WithSelect(IfCondition(WithDispatch(BaseOption)))
label="Permalink"
panelName="post-link"
/>
<WithSelect(PostTaxonomies)
taxonomyWrapper={[Function]}
/>
<WithSelect(IfCondition(WithDispatch(BaseOption)))
label="Featured Image"
panelName="featured-image"
/>
<PostFeaturedImageCheck>
<WithSelect(IfCondition(WithDispatch(BaseOption)))
label="Featured Image"
panelName="featured-image"
/>
</PostFeaturedImageCheck>
<PostExcerptCheck>
<WithSelect(IfCondition(WithDispatch(BaseOption)))
label="Excerpt"
panelName="post-excerpt"
/>
</PostExcerptCheck>
<WithSelect(IfCondition(WithDispatch(BaseOption)))
label="Discussion"
panelName="discussion-panel"
/>
<WithSelect(PostTypeSupportCheck)
supportKeys={
Array [
"comments",
"trackbacks",
]
}
>
<WithSelect(IfCondition(WithDispatch(BaseOption)))
label="Discussion"
panelName="discussion-panel"
/>
</WithSelect(PostTypeSupportCheck)>
<WithSelect(PageAttributesCheck)>
<WithSelect(IfCondition(WithDispatch(BaseOption)))
label="Page Attributes"
Expand Down