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
};
[5000] Fix | Delete
[5001] Fix | Delete
/**
[5002] Fix | Delete
* Triggers an action used to switch editor mode.
[5003] Fix | Delete
*
[5004] Fix | Delete
* @param {string} mode The editor mode.
[5005] Fix | Delete
*/
[5006] Fix | Delete
const switchEditorMode = mode => ({
[5007] Fix | Delete
dispatch,
[5008] Fix | Delete
registry
[5009] Fix | Delete
}) => {
[5010] Fix | Delete
registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'editorMode', mode);
[5011] Fix | Delete
[5012] Fix | Delete
// Unselect blocks when we switch to a non visual mode.
[5013] Fix | Delete
if (mode !== 'visual') {
[5014] Fix | Delete
registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
[5015] Fix | Delete
}
[5016] Fix | Delete
if (mode === 'visual') {
[5017] Fix | Delete
(0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Visual editor selected'), 'assertive');
[5018] Fix | Delete
} else if (mode === 'text') {
[5019] Fix | Delete
const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree');
[5020] Fix | Delete
if (isDistractionFree) {
[5021] Fix | Delete
dispatch.toggleDistractionFree();
[5022] Fix | Delete
}
[5023] Fix | Delete
(0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Code editor selected'), 'assertive');
[5024] Fix | Delete
}
[5025] Fix | Delete
};
[5026] Fix | Delete
[5027] Fix | Delete
/**
[5028] Fix | Delete
* Returns an action object used in signalling that the user opened the publish
[5029] Fix | Delete
* sidebar.
[5030] Fix | Delete
*
[5031] Fix | Delete
* @return {Object} Action object
[5032] Fix | Delete
*/
[5033] Fix | Delete
function openPublishSidebar() {
[5034] Fix | Delete
return {
[5035] Fix | Delete
type: 'OPEN_PUBLISH_SIDEBAR'
[5036] Fix | Delete
};
[5037] Fix | Delete
}
[5038] Fix | Delete
[5039] Fix | Delete
/**
[5040] Fix | Delete
* Returns an action object used in signalling that the user closed the
[5041] Fix | Delete
* publish sidebar.
[5042] Fix | Delete
*
[5043] Fix | Delete
* @return {Object} Action object.
[5044] Fix | Delete
*/
[5045] Fix | Delete
function closePublishSidebar() {
[5046] Fix | Delete
return {
[5047] Fix | Delete
type: 'CLOSE_PUBLISH_SIDEBAR'
[5048] Fix | Delete
};
[5049] Fix | Delete
}
[5050] Fix | Delete
[5051] Fix | Delete
/**
[5052] Fix | Delete
* Returns an action object used in signalling that the user toggles the publish sidebar.
[5053] Fix | Delete
*
[5054] Fix | Delete
* @return {Object} Action object
[5055] Fix | Delete
*/
[5056] Fix | Delete
function togglePublishSidebar() {
[5057] Fix | Delete
return {
[5058] Fix | Delete
type: 'TOGGLE_PUBLISH_SIDEBAR'
[5059] Fix | Delete
};
[5060] Fix | Delete
}
[5061] Fix | Delete
[5062] Fix | Delete
/**
[5063] Fix | Delete
* Backward compatibility
[5064] Fix | Delete
*/
[5065] Fix | Delete
[5066] Fix | Delete
const getBlockEditorAction = name => (...args) => ({
[5067] Fix | Delete
registry
[5068] Fix | Delete
}) => {
[5069] Fix | Delete
external_wp_deprecated_default()("`wp.data.dispatch( 'core/editor' )." + name + '`', {
[5070] Fix | Delete
since: '5.3',
[5071] Fix | Delete
alternative: "`wp.data.dispatch( 'core/block-editor' )." + name + '`',
[5072] Fix | Delete
version: '6.2'
[5073] Fix | Delete
});
[5074] Fix | Delete
registry.dispatch(external_wp_blockEditor_namespaceObject.store)[name](...args);
[5075] Fix | Delete
};
[5076] Fix | Delete
[5077] Fix | Delete
/**
[5078] Fix | Delete
* @see resetBlocks in core/block-editor store.
[5079] Fix | Delete
*/
[5080] Fix | Delete
const resetBlocks = getBlockEditorAction('resetBlocks');
[5081] Fix | Delete
[5082] Fix | Delete
/**
[5083] Fix | Delete
* @see receiveBlocks in core/block-editor store.
[5084] Fix | Delete
*/
[5085] Fix | Delete
const receiveBlocks = getBlockEditorAction('receiveBlocks');
[5086] Fix | Delete
[5087] Fix | Delete
/**
[5088] Fix | Delete
* @see updateBlock in core/block-editor store.
[5089] Fix | Delete
*/
[5090] Fix | Delete
const updateBlock = getBlockEditorAction('updateBlock');
[5091] Fix | Delete
[5092] Fix | Delete
/**
[5093] Fix | Delete
* @see updateBlockAttributes in core/block-editor store.
[5094] Fix | Delete
*/
[5095] Fix | Delete
const updateBlockAttributes = getBlockEditorAction('updateBlockAttributes');
[5096] Fix | Delete
[5097] Fix | Delete
/**
[5098] Fix | Delete
* @see selectBlock in core/block-editor store.
[5099] Fix | Delete
*/
[5100] Fix | Delete
const selectBlock = getBlockEditorAction('selectBlock');
[5101] Fix | Delete
[5102] Fix | Delete
/**
[5103] Fix | Delete
* @see startMultiSelect in core/block-editor store.
[5104] Fix | Delete
*/
[5105] Fix | Delete
const startMultiSelect = getBlockEditorAction('startMultiSelect');
[5106] Fix | Delete
[5107] Fix | Delete
/**
[5108] Fix | Delete
* @see stopMultiSelect in core/block-editor store.
[5109] Fix | Delete
*/
[5110] Fix | Delete
const stopMultiSelect = getBlockEditorAction('stopMultiSelect');
[5111] Fix | Delete
[5112] Fix | Delete
/**
[5113] Fix | Delete
* @see multiSelect in core/block-editor store.
[5114] Fix | Delete
*/
[5115] Fix | Delete
const multiSelect = getBlockEditorAction('multiSelect');
[5116] Fix | Delete
[5117] Fix | Delete
/**
[5118] Fix | Delete
* @see clearSelectedBlock in core/block-editor store.
[5119] Fix | Delete
*/
[5120] Fix | Delete
const clearSelectedBlock = getBlockEditorAction('clearSelectedBlock');
[5121] Fix | Delete
[5122] Fix | Delete
/**
[5123] Fix | Delete
* @see toggleSelection in core/block-editor store.
[5124] Fix | Delete
*/
[5125] Fix | Delete
const toggleSelection = getBlockEditorAction('toggleSelection');
[5126] Fix | Delete
[5127] Fix | Delete
/**
[5128] Fix | Delete
* @see replaceBlocks in core/block-editor store.
[5129] Fix | Delete
*/
[5130] Fix | Delete
const replaceBlocks = getBlockEditorAction('replaceBlocks');
[5131] Fix | Delete
[5132] Fix | Delete
/**
[5133] Fix | Delete
* @see replaceBlock in core/block-editor store.
[5134] Fix | Delete
*/
[5135] Fix | Delete
const replaceBlock = getBlockEditorAction('replaceBlock');
[5136] Fix | Delete
[5137] Fix | Delete
/**
[5138] Fix | Delete
* @see moveBlocksDown in core/block-editor store.
[5139] Fix | Delete
*/
[5140] Fix | Delete
const moveBlocksDown = getBlockEditorAction('moveBlocksDown');
[5141] Fix | Delete
[5142] Fix | Delete
/**
[5143] Fix | Delete
* @see moveBlocksUp in core/block-editor store.
[5144] Fix | Delete
*/
[5145] Fix | Delete
const moveBlocksUp = getBlockEditorAction('moveBlocksUp');
[5146] Fix | Delete
[5147] Fix | Delete
/**
[5148] Fix | Delete
* @see moveBlockToPosition in core/block-editor store.
[5149] Fix | Delete
*/
[5150] Fix | Delete
const moveBlockToPosition = getBlockEditorAction('moveBlockToPosition');
[5151] Fix | Delete
[5152] Fix | Delete
/**
[5153] Fix | Delete
* @see insertBlock in core/block-editor store.
[5154] Fix | Delete
*/
[5155] Fix | Delete
const insertBlock = getBlockEditorAction('insertBlock');
[5156] Fix | Delete
[5157] Fix | Delete
/**
[5158] Fix | Delete
* @see insertBlocks in core/block-editor store.
[5159] Fix | Delete
*/
[5160] Fix | Delete
const insertBlocks = getBlockEditorAction('insertBlocks');
[5161] Fix | Delete
[5162] Fix | Delete
/**
[5163] Fix | Delete
* @see showInsertionPoint in core/block-editor store.
[5164] Fix | Delete
*/
[5165] Fix | Delete
const showInsertionPoint = getBlockEditorAction('showInsertionPoint');
[5166] Fix | Delete
[5167] Fix | Delete
/**
[5168] Fix | Delete
* @see hideInsertionPoint in core/block-editor store.
[5169] Fix | Delete
*/
[5170] Fix | Delete
const hideInsertionPoint = getBlockEditorAction('hideInsertionPoint');
[5171] Fix | Delete
[5172] Fix | Delete
/**
[5173] Fix | Delete
* @see setTemplateValidity in core/block-editor store.
[5174] Fix | Delete
*/
[5175] Fix | Delete
const setTemplateValidity = getBlockEditorAction('setTemplateValidity');
[5176] Fix | Delete
[5177] Fix | Delete
/**
[5178] Fix | Delete
* @see synchronizeTemplate in core/block-editor store.
[5179] Fix | Delete
*/
[5180] Fix | Delete
const synchronizeTemplate = getBlockEditorAction('synchronizeTemplate');
[5181] Fix | Delete
[5182] Fix | Delete
/**
[5183] Fix | Delete
* @see mergeBlocks in core/block-editor store.
[5184] Fix | Delete
*/
[5185] Fix | Delete
const mergeBlocks = getBlockEditorAction('mergeBlocks');
[5186] Fix | Delete
[5187] Fix | Delete
/**
[5188] Fix | Delete
* @see removeBlocks in core/block-editor store.
[5189] Fix | Delete
*/
[5190] Fix | Delete
const removeBlocks = getBlockEditorAction('removeBlocks');
[5191] Fix | Delete
[5192] Fix | Delete
/**
[5193] Fix | Delete
* @see removeBlock in core/block-editor store.
[5194] Fix | Delete
*/
[5195] Fix | Delete
const removeBlock = getBlockEditorAction('removeBlock');
[5196] Fix | Delete
[5197] Fix | Delete
/**
[5198] Fix | Delete
* @see toggleBlockMode in core/block-editor store.
[5199] Fix | Delete
*/
[5200] Fix | Delete
const toggleBlockMode = getBlockEditorAction('toggleBlockMode');
[5201] Fix | Delete
[5202] Fix | Delete
/**
[5203] Fix | Delete
* @see startTyping in core/block-editor store.
[5204] Fix | Delete
*/
[5205] Fix | Delete
const startTyping = getBlockEditorAction('startTyping');
[5206] Fix | Delete
[5207] Fix | Delete
/**
[5208] Fix | Delete
* @see stopTyping in core/block-editor store.
[5209] Fix | Delete
*/
[5210] Fix | Delete
const stopTyping = getBlockEditorAction('stopTyping');
[5211] Fix | Delete
[5212] Fix | Delete
/**
[5213] Fix | Delete
* @see enterFormattedText in core/block-editor store.
[5214] Fix | Delete
*/
[5215] Fix | Delete
const enterFormattedText = getBlockEditorAction('enterFormattedText');
[5216] Fix | Delete
[5217] Fix | Delete
/**
[5218] Fix | Delete
* @see exitFormattedText in core/block-editor store.
[5219] Fix | Delete
*/
[5220] Fix | Delete
const exitFormattedText = getBlockEditorAction('exitFormattedText');
[5221] Fix | Delete
[5222] Fix | Delete
/**
[5223] Fix | Delete
* @see insertDefaultBlock in core/block-editor store.
[5224] Fix | Delete
*/
[5225] Fix | Delete
const insertDefaultBlock = getBlockEditorAction('insertDefaultBlock');
[5226] Fix | Delete
[5227] Fix | Delete
/**
[5228] Fix | Delete
* @see updateBlockListSettings in core/block-editor store.
[5229] Fix | Delete
*/
[5230] Fix | Delete
const updateBlockListSettings = getBlockEditorAction('updateBlockListSettings');
[5231] Fix | Delete
[5232] Fix | Delete
;// CONCATENATED MODULE: external ["wp","htmlEntities"]
[5233] Fix | Delete
const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
[5234] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/utils/is-template-revertable.js
[5235] Fix | Delete
/**
[5236] Fix | Delete
* Internal dependencies
[5237] Fix | Delete
*/
[5238] Fix | Delete
[5239] Fix | Delete
[5240] Fix | Delete
// Copy of the function from packages/edit-site/src/utils/is-template-revertable.js
[5241] Fix | Delete
[5242] Fix | Delete
/**
[5243] Fix | Delete
* Check if a template or template part is revertable to its original theme-provided file.
[5244] Fix | Delete
*
[5245] Fix | Delete
* @param {Object} templateOrTemplatePart The entity to check.
[5246] Fix | Delete
* @return {boolean} Whether the entity is revertable.
[5247] Fix | Delete
*/
[5248] Fix | Delete
function isTemplateRevertable(templateOrTemplatePart) {
[5249] Fix | Delete
if (!templateOrTemplatePart) {
[5250] Fix | Delete
return false;
[5251] Fix | Delete
}
[5252] Fix | Delete
return templateOrTemplatePart.source === TEMPLATE_ORIGINS.custom && templateOrTemplatePart.has_theme_file;
[5253] Fix | Delete
}
[5254] Fix | Delete
[5255] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/private-actions.js
[5256] Fix | Delete
/**
[5257] Fix | Delete
* WordPress dependencies
[5258] Fix | Delete
*/
[5259] Fix | Delete
[5260] Fix | Delete
[5261] Fix | Delete
[5262] Fix | Delete
[5263] Fix | Delete
[5264] Fix | Delete
[5265] Fix | Delete
[5266] Fix | Delete
[5267] Fix | Delete
[5268] Fix | Delete
[5269] Fix | Delete
/**
[5270] Fix | Delete
* Internal dependencies
[5271] Fix | Delete
*/
[5272] Fix | Delete
[5273] Fix | Delete
[5274] Fix | Delete
/**
[5275] Fix | Delete
* Returns an action object used to set which template is currently being used/edited.
[5276] Fix | Delete
*
[5277] Fix | Delete
* @param {string} id Template Id.
[5278] Fix | Delete
*
[5279] Fix | Delete
* @return {Object} Action object.
[5280] Fix | Delete
*/
[5281] Fix | Delete
function setCurrentTemplateId(id) {
[5282] Fix | Delete
return {
[5283] Fix | Delete
type: 'SET_CURRENT_TEMPLATE_ID',
[5284] Fix | Delete
id
[5285] Fix | Delete
};
[5286] Fix | Delete
}
[5287] Fix | Delete
[5288] Fix | Delete
/**
[5289] Fix | Delete
* Create a block based template.
[5290] Fix | Delete
*
[5291] Fix | Delete
* @param {Object?} template Template to create and assign.
[5292] Fix | Delete
*/
[5293] Fix | Delete
const createTemplate = template => async ({
[5294] Fix | Delete
select,
[5295] Fix | Delete
dispatch,
[5296] Fix | Delete
registry
[5297] Fix | Delete
}) => {
[5298] Fix | Delete
const savedTemplate = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', 'wp_template', template);
[5299] Fix | Delete
registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', select.getCurrentPostType(), select.getCurrentPostId(), {
[5300] Fix | Delete
template: savedTemplate.slug
[5301] Fix | Delete
});
[5302] Fix | Delete
registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)("Custom template created. You're in template mode now."), {
[5303] Fix | Delete
type: 'snackbar',
[5304] Fix | Delete
actions: [{
[5305] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
[5306] Fix | Delete
onClick: () => dispatch.setRenderingMode(select.getEditorSettings().defaultRenderingMode)
[5307] Fix | Delete
}]
[5308] Fix | Delete
});
[5309] Fix | Delete
return savedTemplate;
[5310] Fix | Delete
};
[5311] Fix | Delete
[5312] Fix | Delete
/**
[5313] Fix | Delete
* Update the provided block types to be visible.
[5314] Fix | Delete
*
[5315] Fix | Delete
* @param {string[]} blockNames Names of block types to show.
[5316] Fix | Delete
*/
[5317] Fix | Delete
const showBlockTypes = blockNames => ({
[5318] Fix | Delete
registry
[5319] Fix | Delete
}) => {
[5320] Fix | Delete
var _registry$select$get;
[5321] Fix | Delete
const existingBlockNames = (_registry$select$get = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get !== void 0 ? _registry$select$get : [];
[5322] Fix | Delete
const newBlockNames = existingBlockNames.filter(type => !(Array.isArray(blockNames) ? blockNames : [blockNames]).includes(type));
[5323] Fix | Delete
registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', newBlockNames);
[5324] Fix | Delete
};
[5325] Fix | Delete
[5326] Fix | Delete
/**
[5327] Fix | Delete
* Update the provided block types to be hidden.
[5328] Fix | Delete
*
[5329] Fix | Delete
* @param {string[]} blockNames Names of block types to hide.
[5330] Fix | Delete
*/
[5331] Fix | Delete
const hideBlockTypes = blockNames => ({
[5332] Fix | Delete
registry
[5333] Fix | Delete
}) => {
[5334] Fix | Delete
var _registry$select$get2;
[5335] Fix | Delete
const existingBlockNames = (_registry$select$get2 = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : [];
[5336] Fix | Delete
const mergedBlockNames = new Set([...existingBlockNames, ...(Array.isArray(blockNames) ? blockNames : [blockNames])]);
[5337] Fix | Delete
registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', [...mergedBlockNames]);
[5338] Fix | Delete
};
[5339] Fix | Delete
[5340] Fix | Delete
/**
[5341] Fix | Delete
* Save entity records marked as dirty.
[5342] Fix | Delete
*
[5343] Fix | Delete
* @param {Object} options Options for the action.
[5344] Fix | Delete
* @param {Function} [options.onSave] Callback when saving happens.
[5345] Fix | Delete
* @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.
[5346] Fix | Delete
* @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.
[5347] Fix | Delete
* @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.
[5348] Fix | Delete
*/
[5349] Fix | Delete
const saveDirtyEntities = ({
[5350] Fix | Delete
onSave,
[5351] Fix | Delete
dirtyEntityRecords = [],
[5352] Fix | Delete
entitiesToSkip = [],
[5353] Fix | Delete
close
[5354] Fix | Delete
} = {}) => ({
[5355] Fix | Delete
registry
[5356] Fix | Delete
}) => {
[5357] Fix | Delete
const PUBLISH_ON_SAVE_ENTITIES = [{
[5358] Fix | Delete
kind: 'postType',
[5359] Fix | Delete
name: 'wp_navigation'
[5360] Fix | Delete
}];
[5361] Fix | Delete
const saveNoticeId = 'site-editor-save-success';
[5362] Fix | Delete
const homeUrl = registry.select(external_wp_coreData_namespaceObject.store).getUnstableBase()?.home;
[5363] Fix | Delete
registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(saveNoticeId);
[5364] Fix | Delete
const entitiesToSave = dirtyEntityRecords.filter(({
[5365] Fix | Delete
kind,
[5366] Fix | Delete
name,
[5367] Fix | Delete
key,
[5368] Fix | Delete
property
[5369] Fix | Delete
}) => {
[5370] Fix | Delete
return !entitiesToSkip.some(elt => elt.kind === kind && elt.name === name && elt.key === key && elt.property === property);
[5371] Fix | Delete
});
[5372] Fix | Delete
close?.(entitiesToSave);
[5373] Fix | Delete
const siteItemsToSave = [];
[5374] Fix | Delete
const pendingSavedRecords = [];
[5375] Fix | Delete
entitiesToSave.forEach(({
[5376] Fix | Delete
kind,
[5377] Fix | Delete
name,
[5378] Fix | Delete
key,
[5379] Fix | Delete
property
[5380] Fix | Delete
}) => {
[5381] Fix | Delete
if ('root' === kind && 'site' === name) {
[5382] Fix | Delete
siteItemsToSave.push(property);
[5383] Fix | Delete
} else {
[5384] Fix | Delete
if (PUBLISH_ON_SAVE_ENTITIES.some(typeToPublish => typeToPublish.kind === kind && typeToPublish.name === name)) {
[5385] Fix | Delete
registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord(kind, name, key, {
[5386] Fix | Delete
status: 'publish'
[5387] Fix | Delete
});
[5388] Fix | Delete
}
[5389] Fix | Delete
pendingSavedRecords.push(registry.dispatch(external_wp_coreData_namespaceObject.store).saveEditedEntityRecord(kind, name, key));
[5390] Fix | Delete
}
[5391] Fix | Delete
});
[5392] Fix | Delete
if (siteItemsToSave.length) {
[5393] Fix | Delete
pendingSavedRecords.push(registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalSaveSpecifiedEntityEdits('root', 'site', undefined, siteItemsToSave));
[5394] Fix | Delete
}
[5395] Fix | Delete
registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableMarkLastChangeAsPersistent();
[5396] Fix | Delete
Promise.all(pendingSavedRecords).then(values => {
[5397] Fix | Delete
return onSave ? onSave(values) : values;
[5398] Fix | Delete
}).then(values => {
[5399] Fix | Delete
if (values.some(value => typeof value === 'undefined')) {
[5400] Fix | Delete
registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Saving failed.'));
[5401] Fix | Delete
} else {
[5402] Fix | Delete
registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Site updated.'), {
[5403] Fix | Delete
type: 'snackbar',
[5404] Fix | Delete
id: saveNoticeId,
[5405] Fix | Delete
actions: [{
[5406] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('View site'),
[5407] Fix | Delete
url: homeUrl
[5408] Fix | Delete
}]
[5409] Fix | Delete
});
[5410] Fix | Delete
}
[5411] Fix | Delete
}).catch(error => registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(`${(0,external_wp_i18n_namespaceObject.__)('Saving failed.')} ${error}`));
[5412] Fix | Delete
};
[5413] Fix | Delete
[5414] Fix | Delete
/**
[5415] Fix | Delete
* Reverts a template to its original theme-provided file.
[5416] Fix | Delete
*
[5417] Fix | Delete
* @param {Object} template The template to revert.
[5418] Fix | Delete
* @param {Object} [options]
[5419] Fix | Delete
* @param {boolean} [options.allowUndo] Whether to allow the user to undo
[5420] Fix | Delete
* reverting the template. Default true.
[5421] Fix | Delete
*/
[5422] Fix | Delete
const revertTemplate = (template, {
[5423] Fix | Delete
allowUndo = true
[5424] Fix | Delete
} = {}) => async ({
[5425] Fix | Delete
registry
[5426] Fix | Delete
}) => {
[5427] Fix | Delete
const noticeId = 'edit-site-template-reverted';
[5428] Fix | Delete
registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(noticeId);
[5429] Fix | Delete
if (!isTemplateRevertable(template)) {
[5430] Fix | Delete
registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('This template is not revertable.'), {
[5431] Fix | Delete
type: 'snackbar'
[5432] Fix | Delete
});
[5433] Fix | Delete
return;
[5434] Fix | Delete
}
[5435] Fix | Delete
try {
[5436] Fix | Delete
const templateEntityConfig = registry.select(external_wp_coreData_namespaceObject.store).getEntityConfig('postType', template.type);
[5437] Fix | Delete
if (!templateEntityConfig) {
[5438] Fix | Delete
registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
[5439] Fix | Delete
type: 'snackbar'
[5440] Fix | Delete
});
[5441] Fix | Delete
return;
[5442] Fix | Delete
}
[5443] Fix | Delete
const fileTemplatePath = (0,external_wp_url_namespaceObject.addQueryArgs)(`${templateEntityConfig.baseURL}/${template.id}`, {
[5444] Fix | Delete
context: 'edit',
[5445] Fix | Delete
source: 'theme'
[5446] Fix | Delete
});
[5447] Fix | Delete
const fileTemplate = await external_wp_apiFetch_default()({
[5448] Fix | Delete
path: fileTemplatePath
[5449] Fix | Delete
});
[5450] Fix | Delete
if (!fileTemplate) {
[5451] Fix | Delete
registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
[5452] Fix | Delete
type: 'snackbar'
[5453] Fix | Delete
});
[5454] Fix | Delete
return;
[5455] Fix | Delete
}
[5456] Fix | Delete
const serializeBlocks = ({
[5457] Fix | Delete
blocks: blocksForSerialization = []
[5458] Fix | Delete
}) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
[5459] Fix | Delete
const edited = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', template.type, template.id);
[5460] Fix | Delete
[5461] Fix | Delete
// We are fixing up the undo level here to make sure we can undo
[5462] Fix | Delete
// the revert in the header toolbar correctly.
[5463] Fix | Delete
registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, template.id, {
[5464] Fix | Delete
content: serializeBlocks,
[5465] Fix | Delete
// Required to make the `undo` behave correctly.
[5466] Fix | Delete
blocks: edited.blocks,
[5467] Fix | Delete
// Required to revert the blocks in the editor.
[5468] Fix | Delete
source: 'custom' // required to avoid turning the editor into a dirty state
[5469] Fix | Delete
}, {
[5470] Fix | Delete
undoIgnore: true // Required to merge this edit with the last undo level.
[5471] Fix | Delete
});
[5472] Fix | Delete
const blocks = (0,external_wp_blocks_namespaceObject.parse)(fileTemplate?.content?.raw);
[5473] Fix | Delete
registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, fileTemplate.id, {
[5474] Fix | Delete
content: serializeBlocks,
[5475] Fix | Delete
blocks,
[5476] Fix | Delete
source: 'theme'
[5477] Fix | Delete
});
[5478] Fix | Delete
if (allowUndo) {
[5479] Fix | Delete
const undoRevert = () => {
[5480] Fix | Delete
registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, edited.id, {
[5481] Fix | Delete
content: serializeBlocks,
[5482] Fix | Delete
blocks: edited.blocks,
[5483] Fix | Delete
source: 'custom'
[5484] Fix | Delete
});
[5485] Fix | Delete
};
[5486] Fix | Delete
registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reset.'), {
[5487] Fix | Delete
type: 'snackbar',
[5488] Fix | Delete
id: noticeId,
[5489] Fix | Delete
actions: [{
[5490] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
[5491] Fix | Delete
onClick: undoRevert
[5492] Fix | Delete
}]
[5493] Fix | Delete
});
[5494] Fix | Delete
}
[5495] Fix | Delete
} catch (error) {
[5496] Fix | Delete
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('Template revert failed. Please reload.');
[5497] Fix | Delete
registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
[5498] Fix | Delete
type: 'snackbar'
[5499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function