: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Action that removes an array of templates, template parts or patterns.
* @param {Array} items An array of template,template part or pattern objects to remove.
const removeTemplates = items => async ({
const isResetting = items.every(item => !!item && (item.has_theme_file || item.templatePart && item.templatePart.has_theme_file));
const promiseResult = await Promise.allSettled(items.map(item => {
return registry.dispatch(external_wp_coreData_namespaceObject.store).deleteEntityRecord('postType', item.type, item.id, {
// If all the promises were fulfilled with sucess.
if (promiseResult.every(({
}) => status === 'fulfilled')) {
if (items.length === 1) {
// Depending on how the entity was retrieved its title might be
// an object or simple string.
const title = typeof items[0].title === 'string' ? items[0].title : items[0].title?.rendered;
successMessage = isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */
(0,external_wp_i18n_namespaceObject.__)('"%s" reset.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */
(0,external_wp_i18n_namespaceObject.__)('"%s" deleted.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title));
successMessage = isResetting ? (0,external_wp_i18n_namespaceObject.__)('Items reset.') : (0,external_wp_i18n_namespaceObject.__)('Items deleted.');
registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(successMessage, {
id: 'editor-template-deleted-success'
// If there was at lease one failure.
// If we were trying to delete a single template.
if (promiseResult.length === 1) {
if (promiseResult[0].reason?.message) {
errorMessage = promiseResult[0].reason.message;
errorMessage = isResetting ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the item.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the item.');
// If we were trying to delete a multiple templates
const errorMessages = new Set();
const failedPromises = promiseResult.filter(({
}) => status === 'rejected');
for (const failedPromise of failedPromises) {
if (failedPromise.reason?.message) {
errorMessages.add(failedPromise.reason.message);
if (errorMessages.size === 0) {
errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the items.');
} else if (errorMessages.size === 1) {
errorMessage = isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
(0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the items: %s'), [...errorMessages][0]) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
(0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the items: %s'), [...errorMessages][0]);
errorMessage = isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
(0,external_wp_i18n_namespaceObject.__)('Some errors occurred while reverting the items: %s'), [...errorMessages].join(',')) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
(0,external_wp_i18n_namespaceObject.__)('Some errors occurred while deleting the items: %s'), [...errorMessages].join(','));
registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
// EXTERNAL MODULE: ./node_modules/fast-deep-equal/index.js
var fast_deep_equal = __webpack_require__(5215);
var fast_deep_equal_default = /*#__PURE__*/__webpack_require__.n(fast_deep_equal);
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js
const symbol = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
xmlns: "http://www.w3.org/2000/svg",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z"
/* harmony default export */ const library_symbol = (symbol);
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/navigation.js
const navigation = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
xmlns: "http://www.w3.org/2000/svg",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14.5c-3.6 0-6.5-2.9-6.5-6.5S8.4 5.5 12 5.5s6.5 2.9 6.5 6.5-2.9 6.5-6.5 6.5zM9 16l4.5-3L15 8.4l-4.5 3L9 16z"
/* harmony default export */ const library_navigation = (navigation);
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/page.js
const page = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, {
xmlns: "http://www.w3.org/2000/svg",
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
d: "M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"
/* harmony default export */ const library_page = (page);
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/verse.js
const verse = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
xmlns: "http://www.w3.org/2000/svg",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
d: "M17.8 2l-.9.3c-.1 0-3.6 1-5.2 2.1C10 5.5 9.3 6.5 8.9 7.1c-.6.9-1.7 4.7-1.7 6.3l-.9 2.3c-.2.4 0 .8.4 1 .1 0 .2.1.3.1.3 0 .6-.2.7-.5l.6-1.5c.3 0 .7-.1 1.2-.2.7-.1 1.4-.3 2.2-.5.8-.2 1.6-.5 2.4-.8.7-.3 1.4-.7 1.9-1.2s.8-1.2 1-1.9c.2-.7.3-1.6.4-2.4.1-.8.1-1.7.2-2.5 0-.8.1-1.5.2-2.1V2zm-1.9 5.6c-.1.8-.2 1.5-.3 2.1-.2.6-.4 1-.6 1.3-.3.3-.8.6-1.4.9-.7.3-1.4.5-2.2.8-.6.2-1.3.3-1.8.4L15 7.5c.3-.3.6-.7 1-1.1 0 .4 0 .8-.1 1.2zM6 20h8v-1.5H6V20z"
/* harmony default export */ const library_verse = (verse);
;// CONCATENATED MODULE: ./node_modules/memize/dist/index.js
* @property {number} [maxSize] Maximum size of the cache.
* @typedef MemizeCacheNode
* @property {?MemizeCacheNode|undefined} [prev] Previous node.
* @property {?MemizeCacheNode|undefined} [next] Next node.
* @property {Array<*>} args Function arguments for cache
* @property {*} val Function result.
* Properties of the enhanced function for controlling cache.
* @typedef MemizeMemoizedFunction
* @property {()=>void} clear Clear the cache.
* Accepts a function to be memoized, and returns a new memoized function, with
* @template {(...args: any[]) => any} F
* @param {F} fn Function to memoize.
* @param {MemizeOptions} [options] Options object.
* @return {((...args: Parameters<F>) => ReturnType<F>) & MemizeMemoizedFunction} Memoized function.
function memize(fn, options) {
/** @type {?MemizeCacheNode|undefined} */
/** @type {?MemizeCacheNode|undefined} */
function memoized(/* ...args */) {
searchCache: while (node) {
// Perform a shallow equality test to confirm that whether the node
// under test is a candidate for the arguments passed. Two arrays
// are shallowly equal if their length matches and each entry is
// strictly equal between the two sets. Avoid abstracting to a
// function which could incur an arguments leaking deoptimization.
// Check whether node arguments match arguments length
if (node.args.length !== arguments.length) {
// Check whether node arguments match arguments values
for (i = 0; i < len; i++) {
if (node.args[i] !== arguments[i]) {
// At this point we can assume we've found a match
// Surface matched node to head if not already
// As tail, shift to previous. Must only shift if not also
// head, since if both head and tail, there is no previous.
// Adjust siblings to point to each other. If node was tail,
// this also handles new tail's empty `next` assignment.
/** @type {MemizeCacheNode} */ (node.prev).next = node.next;
node.next.prev = node.prev;
/** @type {MemizeCacheNode} */ (head).prev = node;
// No cached value found. Continue to insertion phase:
// Create a copy of arguments (avoid leaking deoptimization)
for (i = 0; i < len; i++) {
// Generate the result from original function
val: fn.apply(null, args),
// Don't need to check whether node is already head, since it would
// have been returned above already if it was
// Shift existing head down list
// If no head, follows that there's no tail (at initial or reset)
// Trim tail if we're reached max size and are pending cache insertion
if (size === /** @type {MemizeOptions} */ (options).maxSize) {
tail = /** @type {MemizeCacheNode} */ (tail).prev;
/** @type {MemizeCacheNode} */ (tail).next = null;
memoized.clear = function () {
// Ignore reason: There's not a clear solution to create an intersection of
// the function with additional properties, where the goal is to retain the
// function signature of the incoming argument and add control properties
;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/utils/get-filtered-template-parts.js
* Get a flattened and filtered list of template parts and the matching block for that template part.
* Takes a list of blocks defined within a template, and a list of template parts, and returns a
* flattened list of template parts and the matching block for that template part.
* @param {Array} blocks Blocks to flatten.
* @param {?Array} templateParts Available template parts.
* @return {Array} An array of template parts and their blocks.
function getFilteredTemplatePartBlocks(blocks = EMPTY_ARRAY, templateParts) {
const templatePartsById = templateParts ?
// Key template parts by their ID.
templateParts.reduce((newTemplateParts, part) => ({
// Iterate over all blocks, recursing into inner blocks.
// Output will be based on a depth-first traversal.
const stack = [...blocks];
// Place inner blocks at the beginning of the stack to preserve order.
stack.unshift(...innerBlocks);
if ((0,external_wp_blocks_namespaceObject.isTemplatePart)(block)) {
const templatePartId = `${theme}//${slug}`;
const templatePart = templatePartsById[templatePartId];
// Only add to output if the found template part block is in the list of available template parts.
const memoizedGetFilteredTemplatePartBlocks = memize(getFilteredTemplatePartBlocks);
;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/private-selectors.js
const EMPTY_INSERTION_POINT = {
insertionIndex: undefined,
* Get the insertion point for the inserter.
* @param {Object} state Global application state.
* @return {Object} The root client ID, index to insert at and starting filter value.
const getInsertionPoint = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)(state => {
if (typeof state.blockInserterPanel === 'object') {
return state.blockInserterPanel;
if (getRenderingMode(state) === 'template-locked') {
const [postContentClientId] = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/post-content');
if (postContentClientId) {
rootClientId: postContentClientId,
insertionIndex: undefined,
return EMPTY_INSERTION_POINT;
const [postContentClientId] = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/post-content');
return [state.blockInserterPanel, getRenderingMode(state), postContentClientId];
function getListViewToggleRef(state) {
return state.listViewToggleRef;
function getInserterSidebarToggleRef(state) {
return state.inserterSidebarToggleRef;
wp_block: library_symbol,
wp_navigation: library_navigation,
const getPostIcon = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, options) => {
if (postType === 'wp_template_part' || postType === 'wp_template') {
return __experimentalGetDefaultTemplatePartAreas(state).find(item => options.area === item.area)?.icon || library_layout;
if (CARD_ICONS[postType]) {
return CARD_ICONS[postType];
const postTypeEntity = select(external_wp_coreData_namespaceObject.store).getPostType(postType);
// `icon` is the `menu_icon` property of a post type. We
// only handle `dashicons` for now, even if the `menu_icon`
// also supports urls and svg as values.
if (typeof postTypeEntity?.icon === 'string' && postTypeEntity.icon.startsWith('dashicons-')) {
return postTypeEntity.icon.slice(10);
* Returns the template parts and their blocks for the current edited template.
* @param {Object} state Global application state.
* @return {Array} Template parts and their blocks in an array.
const getCurrentTemplateTemplateParts = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
const templateParts = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', TEMPLATE_PART_POST_TYPE, {
const clientIds = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/template-part');
const blocks = select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds);
return memoizedGetFilteredTemplatePartBlocks(blocks, templateParts);
* Returns true if there are unsaved changes to the
* post's meta fields, and false otherwise.
* @param {Object} state Global application state.
* @param {string} postType The post type of the post.
* @param {number} postId The ID of the post.
* @return {boolean} Whether there are edits or not in the meta fields of the relevant post.
const hasPostMetaChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, postId) => {
} = getCurrentPost(state);
// If no postType or postId is passed, use the current post.
const edits = select(external_wp_coreData_namespaceObject.store).getEntityRecordNonTransientEdits('postType', postType || currentPostType, postId || currentPostId);
// Compare if anything apart from `footnotes` has changed.
const originalPostMeta = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', postType || currentPostType, postId || currentPostId)?.meta;
return !fast_deep_equal_default()({