Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add a check for singular content based on available post type
  • Loading branch information
mikachan committed Sep 18, 2024
commit 0f26b805ea0695c36466e16a3b5cbb85bca941e0
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ import { useToolsPanelDropdownMenuProps } from '../../../utils/hooks';
const { BlockInfo } = unlock( blockEditorPrivateApis );

export default function QueryInspectorControls( props ) {
const { attributes, setQuery, setDisplayLayout } = props;
const { attributes, setQuery, setDisplayLayout, postTypeFromContext } =
props;
const { query, displayLayout } = attributes;
const {
order,
Expand Down Expand Up @@ -126,11 +127,16 @@ export default function QueryInspectorControls( props ) {
return onChangeDebounced.cancel;
}, [ querySearch, onChangeDebounced ] );

const isTemplate = useSelect( ( select ) => {
const currentTemplate =
select( coreStore ).__experimentalGetTemplateForLink()?.type;
return 'wp_template' === currentTemplate;
}, [] );
const isTemplate = useSelect(
( select ) => {
const currentTemplate =
select( coreStore ).__experimentalGetTemplateForLink()?.type;
const isInTemplate = 'wp_template' === currentTemplate;
const isInSingularContent = postTypeFromContext !== undefined;
return isInTemplate && ! isInSingularContent;
},
[ postTypeFromContext ]
);

const showInheritControl =
isTemplate && isControlAllowed( allowedControls, 'inherit' );
Expand Down