diff --git a/packages/block-editor/src/components/block-inspector/index.js b/packages/block-editor/src/components/block-inspector/index.js index c8ed85f2fd51bc..cab4037050c787 100644 --- a/packages/block-editor/src/components/block-inspector/index.js +++ b/packages/block-editor/src/components/block-inspector/index.js @@ -270,6 +270,7 @@ const BlockInspectorSingleBlock = ( { } } /> + { showTabs && ( { + if ( ! postType ) return null; + const newPostUrl = addQueryArgs( 'post-new.php', { + post_type: postType, + } ); + return ( +
+ { createInterpolateElement( + __( 'Create a new post for this feed.' ), + // eslint-disable-next-line jsx-a11y/anchor-has-content + { a: } + ) } +
+ ); +}; + +export default CreateNewPostLink; diff --git a/packages/block-library/src/query/edit/inspector-controls/index.js b/packages/block-library/src/query/edit/inspector-controls/index.js index ffe19060682d3f..eea4259bc8aff8 100644 --- a/packages/block-library/src/query/edit/inspector-controls/index.js +++ b/packages/block-library/src/query/edit/inspector-controls/index.js @@ -24,6 +24,7 @@ import AuthorControl from './author-control'; import ParentControl from './parent-control'; import { TaxonomyControls } from './taxonomy-controls'; import StickyControl from './sticky-control'; +import CreateNewPostLink from './create-new-post-link'; import { usePostTypes, useIsPostTypeHierarchical, @@ -32,11 +33,8 @@ import { useTaxonomies, } from '../../utils'; -export default function QueryInspectorControls( { - attributes, - setQuery, - setDisplayLayout, -} ) { +export default function QueryInspectorControls( props ) { + const { attributes, setQuery, setDisplayLayout } = props; const { query, displayLayout } = attributes; const { order, @@ -112,6 +110,9 @@ export default function QueryInspectorControls( { showStickyControl; return ( <> + + + { showSettingsPanel && ( diff --git a/packages/block-library/src/query/hooks.js b/packages/block-library/src/query/hooks.js deleted file mode 100644 index b2bb32a7be7b4e..00000000000000 --- a/packages/block-library/src/query/hooks.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { createInterpolateElement } from '@wordpress/element'; -import { addQueryArgs } from '@wordpress/url'; -import { createHigherOrderComponent } from '@wordpress/compose'; -import { InspectorControls } from '@wordpress/block-editor'; - -const CreateNewPostLink = ( { - attributes: { query: { postType } = {} } = {}, -} ) => { - if ( ! postType ) return null; - const newPostUrl = addQueryArgs( 'post-new.php', { - post_type: postType, - } ); - return ( -
- { createInterpolateElement( - __( 'Create a new post for this feed.' ), - // eslint-disable-next-line jsx-a11y/anchor-has-content - { a: } - ) } -
- ); -}; - -/** - * Override the default edit UI to include layout controls - * - * @param {Function} BlockEdit Original component - * @return {Function} Wrapped component - */ -const queryTopInspectorControls = createHigherOrderComponent( - ( BlockEdit ) => ( props ) => { - const { name, isSelected } = props; - if ( name !== 'core/query' || ! isSelected ) { - return ; - } - - return ( - <> - - - - - - ); - }, - 'withInspectorControls' -); - -export default queryTopInspectorControls; diff --git a/packages/block-library/src/query/index.js b/packages/block-library/src/query/index.js index baf58470b76ac0..8d82391923603e 100644 --- a/packages/block-library/src/query/index.js +++ b/packages/block-library/src/query/index.js @@ -2,7 +2,6 @@ * WordPress dependencies */ import { loop as icon } from '@wordpress/icons'; -import { addFilter } from '@wordpress/hooks'; /** * Internal dependencies @@ -13,7 +12,6 @@ import edit from './edit'; import save from './save'; import variations from './variations'; import deprecated from './deprecated'; -import queryInspectorControls from './hooks'; const { name } = metadata; export { metadata, name }; @@ -26,8 +24,4 @@ export const settings = { deprecated, }; -export const init = () => { - addFilter( 'editor.BlockEdit', 'core/query', queryInspectorControls ); - - return initBlock( { name, metadata, settings } ); -}; +export const init = () => initBlock( { name, metadata, settings } );