@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
41 lines (38 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = PostTaxonomiesCheck;
var _data = require("@wordpress/data");
var _coreData = require("@wordpress/core-data");
var _store = require("../../store");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Renders the children components only if the current post type has taxonomies.
*
* @param {Object} props The component props.
* @param {Element} props.children The children components to render.
*
* @return {Component|null} The rendered children components or null if the current post type has no taxonomies.
*/
function PostTaxonomiesCheck({
children
}) {
const hasTaxonomies = (0, _data.useSelect)(select => {
const postType = select(_store.store).getCurrentPostType();
const taxonomies = select(_coreData.store).getTaxonomies({
per_page: -1
});
return taxonomies?.some(taxonomy => taxonomy.types.includes(postType));
}, []);
if (!hasTaxonomies) {
return null;
}
return children;
}
//# sourceMappingURL=check.js.map