UNPKG

@wordpress/editor

Version:
50 lines (47 loc) 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = PostURLCheck; var _data = require("@wordpress/data"); var _coreData = require("@wordpress/core-data"); var _store = require("../../store"); /** * WordPress dependencies */ /** * Internal dependencies */ /** * Check if the post URL is valid and visible. * * @param {Object} props The component props. * @param {Element} props.children The child components. * * @return {Component|null} The child components if the post URL is valid and visible, otherwise null. */ function PostURLCheck({ children }) { const isVisible = (0, _data.useSelect)(select => { const postTypeSlug = select(_store.store).getCurrentPostType(); const postType = select(_coreData.store).getPostType(postTypeSlug); if (!postType?.viewable) { return false; } const post = select(_store.store).getCurrentPost(); if (!post.link) { return false; } const permalinkParts = select(_store.store).getPermalinkParts(); if (!permalinkParts) { return false; } return true; }, []); if (!isVisible) { return null; } return children; } //# sourceMappingURL=check.js.map