Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../js/dist
File: editor.js
if (errorMessages.size === 0) {
[25500] Fix | Delete
errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the posts.');
[25501] Fix | Delete
} else if (errorMessages.size === 1) {
[25502] Fix | Delete
errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
[25503] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the posts: %s'), [...errorMessages][0]);
[25504] Fix | Delete
} else {
[25505] Fix | Delete
errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
[25506] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('Some errors occurred while permanently deleting the posts: %s'), [...errorMessages].join(','));
[25507] Fix | Delete
}
[25508] Fix | Delete
}
[25509] Fix | Delete
createErrorNotice(errorMessage, {
[25510] Fix | Delete
type: 'snackbar'
[25511] Fix | Delete
});
[25512] Fix | Delete
}
[25513] Fix | Delete
}
[25514] Fix | Delete
}), [createSuccessNotice, createErrorNotice, deleteEntityRecord]);
[25515] Fix | Delete
return useCanUserEligibilityCheckPostType('delete', resource, permanentlyDeletePostAction);
[25516] Fix | Delete
}
[25517] Fix | Delete
function useRestorePostAction(resource) {
[25518] Fix | Delete
const {
[25519] Fix | Delete
createSuccessNotice,
[25520] Fix | Delete
createErrorNotice
[25521] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
[25522] Fix | Delete
const {
[25523] Fix | Delete
editEntityRecord,
[25524] Fix | Delete
saveEditedEntityRecord
[25525] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
[25526] Fix | Delete
const restorePostAction = (0,external_wp_element_namespaceObject.useMemo)(() => ({
[25527] Fix | Delete
id: 'restore',
[25528] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Restore'),
[25529] Fix | Delete
isPrimary: true,
[25530] Fix | Delete
icon: library_backup,
[25531] Fix | Delete
supportsBulk: true,
[25532] Fix | Delete
isEligible({
[25533] Fix | Delete
status
[25534] Fix | Delete
}) {
[25535] Fix | Delete
return status === 'trash';
[25536] Fix | Delete
},
[25537] Fix | Delete
async callback(posts, onActionPerformed) {
[25538] Fix | Delete
await Promise.allSettled(posts.map(post => {
[25539] Fix | Delete
return editEntityRecord('postType', post.type, post.id, {
[25540] Fix | Delete
status: 'draft'
[25541] Fix | Delete
});
[25542] Fix | Delete
}));
[25543] Fix | Delete
const promiseResult = await Promise.allSettled(posts.map(post => {
[25544] Fix | Delete
return saveEditedEntityRecord('postType', post.type, post.id, {
[25545] Fix | Delete
throwOnError: true
[25546] Fix | Delete
});
[25547] Fix | Delete
}));
[25548] Fix | Delete
if (promiseResult.every(({
[25549] Fix | Delete
status
[25550] Fix | Delete
}) => status === 'fulfilled')) {
[25551] Fix | Delete
let successMessage;
[25552] Fix | Delete
if (posts.length === 1) {
[25553] Fix | Delete
successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */
[25554] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('"%s" has been restored.'), getItemTitle(posts[0]));
[25555] Fix | Delete
} else if (posts[0].type === 'page') {
[25556] Fix | Delete
successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */
[25557] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('%d pages have been restored.'), posts.length);
[25558] Fix | Delete
} else {
[25559] Fix | Delete
successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */
[25560] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('%d posts have been restored.'), posts.length);
[25561] Fix | Delete
}
[25562] Fix | Delete
createSuccessNotice(successMessage, {
[25563] Fix | Delete
type: 'snackbar',
[25564] Fix | Delete
id: 'restore-post-action'
[25565] Fix | Delete
});
[25566] Fix | Delete
if (onActionPerformed) {
[25567] Fix | Delete
onActionPerformed(posts);
[25568] Fix | Delete
}
[25569] Fix | Delete
} else {
[25570] Fix | Delete
// If there was at lease one failure.
[25571] Fix | Delete
let errorMessage;
[25572] Fix | Delete
// If we were trying to move a single post to the trash.
[25573] Fix | Delete
if (promiseResult.length === 1) {
[25574] Fix | Delete
if (promiseResult[0].reason?.message) {
[25575] Fix | Delete
errorMessage = promiseResult[0].reason.message;
[25576] Fix | Delete
} else {
[25577] Fix | Delete
errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the post.');
[25578] Fix | Delete
}
[25579] Fix | Delete
// If we were trying to move multiple posts to the trash
[25580] Fix | Delete
} else {
[25581] Fix | Delete
const errorMessages = new Set();
[25582] Fix | Delete
const failedPromises = promiseResult.filter(({
[25583] Fix | Delete
status
[25584] Fix | Delete
}) => status === 'rejected');
[25585] Fix | Delete
for (const failedPromise of failedPromises) {
[25586] Fix | Delete
if (failedPromise.reason?.message) {
[25587] Fix | Delete
errorMessages.add(failedPromise.reason.message);
[25588] Fix | Delete
}
[25589] Fix | Delete
}
[25590] Fix | Delete
if (errorMessages.size === 0) {
[25591] Fix | Delete
errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the posts.');
[25592] Fix | Delete
} else if (errorMessages.size === 1) {
[25593] Fix | Delete
errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
[25594] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the posts: %s'), [...errorMessages][0]);
[25595] Fix | Delete
} else {
[25596] Fix | Delete
errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
[25597] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('Some errors occurred while restoring the posts: %s'), [...errorMessages].join(','));
[25598] Fix | Delete
}
[25599] Fix | Delete
}
[25600] Fix | Delete
createErrorNotice(errorMessage, {
[25601] Fix | Delete
type: 'snackbar'
[25602] Fix | Delete
});
[25603] Fix | Delete
}
[25604] Fix | Delete
}
[25605] Fix | Delete
}), [createSuccessNotice, createErrorNotice, editEntityRecord, saveEditedEntityRecord]);
[25606] Fix | Delete
return useCanUserEligibilityCheckPostType('update', resource, restorePostAction);
[25607] Fix | Delete
}
[25608] Fix | Delete
const viewPostAction = {
[25609] Fix | Delete
id: 'view-post',
[25610] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('View'),
[25611] Fix | Delete
isPrimary: true,
[25612] Fix | Delete
icon: library_external,
[25613] Fix | Delete
isEligible(post) {
[25614] Fix | Delete
return post.status !== 'trash';
[25615] Fix | Delete
},
[25616] Fix | Delete
callback(posts, onActionPerformed) {
[25617] Fix | Delete
const post = posts[0];
[25618] Fix | Delete
window.open(post.link, '_blank');
[25619] Fix | Delete
if (onActionPerformed) {
[25620] Fix | Delete
onActionPerformed(posts);
[25621] Fix | Delete
}
[25622] Fix | Delete
}
[25623] Fix | Delete
};
[25624] Fix | Delete
const postRevisionsAction = {
[25625] Fix | Delete
id: 'view-post-revisions',
[25626] Fix | Delete
context: 'list',
[25627] Fix | Delete
label(items) {
[25628] Fix | Delete
var _items$0$_links$versi;
[25629] Fix | Delete
const revisionsCount = (_items$0$_links$versi = items[0]._links?.['version-history']?.[0]?.count) !== null && _items$0$_links$versi !== void 0 ? _items$0$_links$versi : 0;
[25630] Fix | Delete
return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: number of revisions */
[25631] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('View revisions (%s)'), revisionsCount);
[25632] Fix | Delete
},
[25633] Fix | Delete
isEligible: post => {
[25634] Fix | Delete
var _post$_links$predeces, _post$_links$version;
[25635] Fix | Delete
if (post.status === 'trash') {
[25636] Fix | Delete
return false;
[25637] Fix | Delete
}
[25638] Fix | Delete
const lastRevisionId = (_post$_links$predeces = post?._links?.['predecessor-version']?.[0]?.id) !== null && _post$_links$predeces !== void 0 ? _post$_links$predeces : null;
[25639] Fix | Delete
const revisionsCount = (_post$_links$version = post?._links?.['version-history']?.[0]?.count) !== null && _post$_links$version !== void 0 ? _post$_links$version : 0;
[25640] Fix | Delete
return lastRevisionId && revisionsCount > 1;
[25641] Fix | Delete
},
[25642] Fix | Delete
callback(posts, onActionPerformed) {
[25643] Fix | Delete
const post = posts[0];
[25644] Fix | Delete
const href = (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
[25645] Fix | Delete
revision: post?._links?.['predecessor-version']?.[0]?.id
[25646] Fix | Delete
});
[25647] Fix | Delete
document.location.href = href;
[25648] Fix | Delete
if (onActionPerformed) {
[25649] Fix | Delete
onActionPerformed(posts);
[25650] Fix | Delete
}
[25651] Fix | Delete
}
[25652] Fix | Delete
};
[25653] Fix | Delete
const renamePostAction = {
[25654] Fix | Delete
id: 'rename-post',
[25655] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Rename'),
[25656] Fix | Delete
isEligible(post) {
[25657] Fix | Delete
if (post.status === 'trash') {
[25658] Fix | Delete
return false;
[25659] Fix | Delete
}
[25660] Fix | Delete
// Templates, template parts and patterns have special checks for renaming.
[25661] Fix | Delete
if (![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, ...Object.values(actions_PATTERN_TYPES)].includes(post.type)) {
[25662] Fix | Delete
return true;
[25663] Fix | Delete
}
[25664] Fix | Delete
// In the case of templates, we can only rename custom templates.
[25665] Fix | Delete
if (post.type === TEMPLATE_POST_TYPE) {
[25666] Fix | Delete
return isTemplateRemovable(post) && post.is_custom;
[25667] Fix | Delete
}
[25668] Fix | Delete
// Make necessary checks for template parts and patterns.
[25669] Fix | Delete
const isTemplatePart = post.type === TEMPLATE_PART_POST_TYPE;
[25670] Fix | Delete
const isUserPattern = post.type === actions_PATTERN_TYPES.user;
[25671] Fix | Delete
// In patterns list page we map the templates parts to a different object
[25672] Fix | Delete
// than the one returned from the endpoint. This is why we need to check for
[25673] Fix | Delete
// two props whether is custom or has a theme file.
[25674] Fix | Delete
const isCustomPattern = isUserPattern || isTemplatePart && (post.isCustom || post.source === TEMPLATE_ORIGINS.custom);
[25675] Fix | Delete
const hasThemeFile = isTemplatePart && (post.templatePart?.has_theme_file || post.has_theme_file);
[25676] Fix | Delete
return isCustomPattern && !hasThemeFile;
[25677] Fix | Delete
},
[25678] Fix | Delete
RenderModal: ({
[25679] Fix | Delete
items,
[25680] Fix | Delete
closeModal,
[25681] Fix | Delete
onActionPerformed
[25682] Fix | Delete
}) => {
[25683] Fix | Delete
const [item] = items;
[25684] Fix | Delete
const originalTitle = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(typeof item.title === 'string' ? item.title : item.title.rendered);
[25685] Fix | Delete
const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(() => originalTitle);
[25686] Fix | Delete
const {
[25687] Fix | Delete
editEntityRecord,
[25688] Fix | Delete
saveEditedEntityRecord
[25689] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
[25690] Fix | Delete
const {
[25691] Fix | Delete
createSuccessNotice,
[25692] Fix | Delete
createErrorNotice
[25693] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
[25694] Fix | Delete
async function onRename(event) {
[25695] Fix | Delete
event.preventDefault();
[25696] Fix | Delete
try {
[25697] Fix | Delete
await editEntityRecord('postType', item.type, item.id, {
[25698] Fix | Delete
title
[25699] Fix | Delete
});
[25700] Fix | Delete
// Update state before saving rerenders the list.
[25701] Fix | Delete
setTitle('');
[25702] Fix | Delete
closeModal();
[25703] Fix | Delete
// Persist edited entity.
[25704] Fix | Delete
await saveEditedEntityRecord('postType', item.type, item.id, {
[25705] Fix | Delete
throwOnError: true
[25706] Fix | Delete
});
[25707] Fix | Delete
createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Name updated'), {
[25708] Fix | Delete
type: 'snackbar'
[25709] Fix | Delete
});
[25710] Fix | Delete
onActionPerformed?.(items);
[25711] Fix | Delete
} catch (error) {
[25712] Fix | Delete
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while updating the name');
[25713] Fix | Delete
createErrorNotice(errorMessage, {
[25714] Fix | Delete
type: 'snackbar'
[25715] Fix | Delete
});
[25716] Fix | Delete
}
[25717] Fix | Delete
}
[25718] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
[25719] Fix | Delete
onSubmit: onRename,
[25720] Fix | Delete
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
[25721] Fix | Delete
spacing: "5",
[25722] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
[25723] Fix | Delete
__nextHasNoMarginBottom: true,
[25724] Fix | Delete
__next40pxDefaultSize: true,
[25725] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Name'),
[25726] Fix | Delete
value: title,
[25727] Fix | Delete
onChange: setTitle,
[25728] Fix | Delete
required: true
[25729] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
[25730] Fix | Delete
justify: "right",
[25731] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
[25732] Fix | Delete
__next40pxDefaultSize: true,
[25733] Fix | Delete
variant: "tertiary",
[25734] Fix | Delete
onClick: () => {
[25735] Fix | Delete
closeModal();
[25736] Fix | Delete
},
[25737] Fix | Delete
children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
[25738] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
[25739] Fix | Delete
__next40pxDefaultSize: true,
[25740] Fix | Delete
variant: "primary",
[25741] Fix | Delete
type: "submit",
[25742] Fix | Delete
children: (0,external_wp_i18n_namespaceObject.__)('Save')
[25743] Fix | Delete
})]
[25744] Fix | Delete
})]
[25745] Fix | Delete
})
[25746] Fix | Delete
});
[25747] Fix | Delete
}
[25748] Fix | Delete
};
[25749] Fix | Delete
function useRenamePostAction(resource) {
[25750] Fix | Delete
return useCanUserEligibilityCheckPostType('update', resource, renamePostAction);
[25751] Fix | Delete
}
[25752] Fix | Delete
const duplicatePostAction = {
[25753] Fix | Delete
id: 'duplicate-post',
[25754] Fix | Delete
label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
[25755] Fix | Delete
isEligible({
[25756] Fix | Delete
status
[25757] Fix | Delete
}) {
[25758] Fix | Delete
return status !== 'trash';
[25759] Fix | Delete
},
[25760] Fix | Delete
RenderModal: ({
[25761] Fix | Delete
items,
[25762] Fix | Delete
closeModal,
[25763] Fix | Delete
onActionPerformed
[25764] Fix | Delete
}) => {
[25765] Fix | Delete
const [item] = items;
[25766] Fix | Delete
const [isCreatingPage, setIsCreatingPage] = (0,external_wp_element_namespaceObject.useState)(false);
[25767] Fix | Delete
const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Existing item title */
[25768] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('%s (Copy)'), getItemTitle(item)));
[25769] Fix | Delete
const {
[25770] Fix | Delete
saveEntityRecord
[25771] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
[25772] Fix | Delete
const {
[25773] Fix | Delete
createSuccessNotice,
[25774] Fix | Delete
createErrorNotice
[25775] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
[25776] Fix | Delete
async function createPage(event) {
[25777] Fix | Delete
event.preventDefault();
[25778] Fix | Delete
if (isCreatingPage) {
[25779] Fix | Delete
return;
[25780] Fix | Delete
}
[25781] Fix | Delete
setIsCreatingPage(true);
[25782] Fix | Delete
try {
[25783] Fix | Delete
const newItem = await saveEntityRecord('postType', item.type, {
[25784] Fix | Delete
status: 'draft',
[25785] Fix | Delete
title,
[25786] Fix | Delete
slug: title || (0,external_wp_i18n_namespaceObject.__)('No title'),
[25787] Fix | Delete
author: item.author,
[25788] Fix | Delete
comment_status: item.comment_status,
[25789] Fix | Delete
content: typeof item.content === 'string' ? item.content : item.content.raw,
[25790] Fix | Delete
excerpt: item.excerpt.raw,
[25791] Fix | Delete
meta: item.meta,
[25792] Fix | Delete
parent: item.parent,
[25793] Fix | Delete
password: item.password,
[25794] Fix | Delete
template: item.template,
[25795] Fix | Delete
format: item.format,
[25796] Fix | Delete
featured_media: item.featured_media,
[25797] Fix | Delete
menu_order: item.menu_order,
[25798] Fix | Delete
ping_status: item.ping_status,
[25799] Fix | Delete
categories: item.categories,
[25800] Fix | Delete
tags: item.tags
[25801] Fix | Delete
}, {
[25802] Fix | Delete
throwOnError: true
[25803] Fix | Delete
});
[25804] Fix | Delete
createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
[25805] Fix | Delete
// translators: %s: Title of the created template e.g: "Category".
[25806] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('"%s" successfully created.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(newItem.title?.rendered || title)), {
[25807] Fix | Delete
id: 'duplicate-post-action',
[25808] Fix | Delete
type: 'snackbar'
[25809] Fix | Delete
});
[25810] Fix | Delete
if (onActionPerformed) {
[25811] Fix | Delete
onActionPerformed([newItem]);
[25812] Fix | Delete
}
[25813] Fix | Delete
} catch (error) {
[25814] Fix | Delete
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while duplicating the page.');
[25815] Fix | Delete
createErrorNotice(errorMessage, {
[25816] Fix | Delete
type: 'snackbar'
[25817] Fix | Delete
});
[25818] Fix | Delete
} finally {
[25819] Fix | Delete
setIsCreatingPage(false);
[25820] Fix | Delete
closeModal();
[25821] Fix | Delete
}
[25822] Fix | Delete
}
[25823] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
[25824] Fix | Delete
onSubmit: createPage,
[25825] Fix | Delete
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
[25826] Fix | Delete
spacing: 3,
[25827] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
[25828] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Title'),
[25829] Fix | Delete
onChange: setTitle,
[25830] Fix | Delete
placeholder: (0,external_wp_i18n_namespaceObject.__)('No title'),
[25831] Fix | Delete
value: title
[25832] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
[25833] Fix | Delete
spacing: 2,
[25834] Fix | Delete
justify: "end",
[25835] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
[25836] Fix | Delete
variant: "tertiary",
[25837] Fix | Delete
onClick: closeModal,
[25838] Fix | Delete
children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
[25839] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
[25840] Fix | Delete
variant: "primary",
[25841] Fix | Delete
type: "submit",
[25842] Fix | Delete
isBusy: isCreatingPage,
[25843] Fix | Delete
"aria-disabled": isCreatingPage,
[25844] Fix | Delete
children: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label')
[25845] Fix | Delete
})]
[25846] Fix | Delete
})]
[25847] Fix | Delete
})
[25848] Fix | Delete
});
[25849] Fix | Delete
}
[25850] Fix | Delete
};
[25851] Fix | Delete
const resetTemplateAction = {
[25852] Fix | Delete
id: 'reset-template',
[25853] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Reset'),
[25854] Fix | Delete
isEligible: item => {
[25855] Fix | Delete
return isTemplateRevertable(item);
[25856] Fix | Delete
},
[25857] Fix | Delete
icon: library_backup,
[25858] Fix | Delete
supportsBulk: true,
[25859] Fix | Delete
hideModalHeader: true,
[25860] Fix | Delete
RenderModal: ({
[25861] Fix | Delete
items,
[25862] Fix | Delete
closeModal,
[25863] Fix | Delete
onActionStart,
[25864] Fix | Delete
onActionPerformed
[25865] Fix | Delete
}) => {
[25866] Fix | Delete
const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
[25867] Fix | Delete
const {
[25868] Fix | Delete
revertTemplate
[25869] Fix | Delete
} = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
[25870] Fix | Delete
const {
[25871] Fix | Delete
saveEditedEntityRecord
[25872] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
[25873] Fix | Delete
const {
[25874] Fix | Delete
createSuccessNotice,
[25875] Fix | Delete
createErrorNotice
[25876] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
[25877] Fix | Delete
const onConfirm = async () => {
[25878] Fix | Delete
try {
[25879] Fix | Delete
for (const template of items) {
[25880] Fix | Delete
await revertTemplate(template, {
[25881] Fix | Delete
allowUndo: false
[25882] Fix | Delete
});
[25883] Fix | Delete
await saveEditedEntityRecord('postType', template.type, template.id);
[25884] Fix | Delete
}
[25885] Fix | Delete
createSuccessNotice(items.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of items. */
[25886] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('%s items reset.'), items.length) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */
[25887] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('"%s" reset.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(getItemTitle(items[0]))), {
[25888] Fix | Delete
type: 'snackbar',
[25889] Fix | Delete
id: 'revert-template-action'
[25890] Fix | Delete
});
[25891] Fix | Delete
} catch (error) {
[25892] Fix | Delete
let fallbackErrorMessage;
[25893] Fix | Delete
if (items[0].type === TEMPLATE_POST_TYPE) {
[25894] Fix | Delete
fallbackErrorMessage = items.length === 1 ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the templates.');
[25895] Fix | Delete
} else {
[25896] Fix | Delete
fallbackErrorMessage = items.length === 1 ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template part.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template parts.');
[25897] Fix | Delete
}
[25898] Fix | Delete
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : fallbackErrorMessage;
[25899] Fix | Delete
createErrorNotice(errorMessage, {
[25900] Fix | Delete
type: 'snackbar'
[25901] Fix | Delete
});
[25902] Fix | Delete
}
[25903] Fix | Delete
};
[25904] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
[25905] Fix | Delete
spacing: "5",
[25906] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
[25907] Fix | Delete
children: (0,external_wp_i18n_namespaceObject.__)('Reset to default and clear all customizations?')
[25908] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
[25909] Fix | Delete
justify: "right",
[25910] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
[25911] Fix | Delete
variant: "tertiary",
[25912] Fix | Delete
onClick: closeModal,
[25913] Fix | Delete
disabled: isBusy,
[25914] Fix | Delete
__experimentalIsFocusable: true,
[25915] Fix | Delete
children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
[25916] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
[25917] Fix | Delete
variant: "primary",
[25918] Fix | Delete
onClick: async () => {
[25919] Fix | Delete
setIsBusy(true);
[25920] Fix | Delete
if (onActionStart) {
[25921] Fix | Delete
onActionStart(items);
[25922] Fix | Delete
}
[25923] Fix | Delete
await onConfirm(items);
[25924] Fix | Delete
onActionPerformed?.(items);
[25925] Fix | Delete
setIsBusy(false);
[25926] Fix | Delete
closeModal();
[25927] Fix | Delete
},
[25928] Fix | Delete
isBusy: isBusy,
[25929] Fix | Delete
disabled: isBusy,
[25930] Fix | Delete
__experimentalIsFocusable: true,
[25931] Fix | Delete
children: (0,external_wp_i18n_namespaceObject.__)('Reset')
[25932] Fix | Delete
})]
[25933] Fix | Delete
})]
[25934] Fix | Delete
});
[25935] Fix | Delete
}
[25936] Fix | Delete
};
[25937] Fix | Delete
const duplicatePatternAction = {
[25938] Fix | Delete
id: 'duplicate-pattern',
[25939] Fix | Delete
label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
[25940] Fix | Delete
isEligible: item => item.type !== TEMPLATE_PART_POST_TYPE,
[25941] Fix | Delete
modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate pattern', 'action label'),
[25942] Fix | Delete
RenderModal: ({
[25943] Fix | Delete
items,
[25944] Fix | Delete
closeModal
[25945] Fix | Delete
}) => {
[25946] Fix | Delete
const [item] = items;
[25947] Fix | Delete
const isThemePattern = item.type === actions_PATTERN_TYPES.theme;
[25948] Fix | Delete
const duplicatedProps = useDuplicatePatternProps({
[25949] Fix | Delete
pattern: isThemePattern || !item.patternPost ? item : item.patternPost,
[25950] Fix | Delete
onSuccess: () => closeModal()
[25951] Fix | Delete
});
[25952] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreatePatternModalContents, {
[25953] Fix | Delete
onClose: closeModal,
[25954] Fix | Delete
confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
[25955] Fix | Delete
...duplicatedProps
[25956] Fix | Delete
});
[25957] Fix | Delete
}
[25958] Fix | Delete
};
[25959] Fix | Delete
const duplicateTemplatePartAction = {
[25960] Fix | Delete
id: 'duplicate-template-part',
[25961] Fix | Delete
label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
[25962] Fix | Delete
isEligible: item => item.type === TEMPLATE_PART_POST_TYPE,
[25963] Fix | Delete
modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate template part', 'action label'),
[25964] Fix | Delete
RenderModal: ({
[25965] Fix | Delete
items,
[25966] Fix | Delete
closeModal
[25967] Fix | Delete
}) => {
[25968] Fix | Delete
const [item] = items;
[25969] Fix | Delete
const {
[25970] Fix | Delete
createSuccessNotice
[25971] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
[25972] Fix | Delete
function onTemplatePartSuccess() {
[25973] Fix | Delete
createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
[25974] Fix | Delete
// translators: %s: The new template part's title e.g. 'Call to action (copy)'.
[25975] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('"%s" duplicated.'), item.title), {
[25976] Fix | Delete
type: 'snackbar',
[25977] Fix | Delete
id: 'edit-site-patterns-success'
[25978] Fix | Delete
});
[25979] Fix | Delete
closeModal();
[25980] Fix | Delete
}
[25981] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateTemplatePartModalContents, {
[25982] Fix | Delete
blocks: item.blocks,
[25983] Fix | Delete
defaultArea: item.templatePart?.area || item.area,
[25984] Fix | Delete
defaultTitle: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Existing template part title */
[25985] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('%s (Copy)'), item.title),
[25986] Fix | Delete
onCreate: onTemplatePartSuccess,
[25987] Fix | Delete
onError: closeModal,
[25988] Fix | Delete
confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label')
[25989] Fix | Delete
});
[25990] Fix | Delete
}
[25991] Fix | Delete
};
[25992] Fix | Delete
function usePostActions({
[25993] Fix | Delete
postType,
[25994] Fix | Delete
onActionPerformed,
[25995] Fix | Delete
context
[25996] Fix | Delete
}) {
[25997] Fix | Delete
const {
[25998] Fix | Delete
postTypeObject,
[25999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function