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: core-data.js
selectorName: 'getEntityRecord',
[6000] Fix | Delete
args: resolutionsArgs
[6001] Fix | Delete
});
[6002] Fix | Delete
}
[6003] Fix | Delete
dispatch.__unstableReleaseStoreLock(lock);
[6004] Fix | Delete
});
[6005] Fix | Delete
} catch (e) {
[6006] Fix | Delete
dispatch.__unstableReleaseStoreLock(lock);
[6007] Fix | Delete
}
[6008] Fix | Delete
};
[6009] Fix | Delete
resolvers_getEntityRecords.shouldInvalidate = (action, kind, name) => {
[6010] Fix | Delete
return (action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS') && action.invalidateCache && kind === action.kind && name === action.name;
[6011] Fix | Delete
};
[6012] Fix | Delete
[6013] Fix | Delete
/**
[6014] Fix | Delete
* Requests the current theme.
[6015] Fix | Delete
*/
[6016] Fix | Delete
const resolvers_getCurrentTheme = () => async ({
[6017] Fix | Delete
dispatch,
[6018] Fix | Delete
resolveSelect
[6019] Fix | Delete
}) => {
[6020] Fix | Delete
const activeThemes = await resolveSelect.getEntityRecords('root', 'theme', {
[6021] Fix | Delete
status: 'active'
[6022] Fix | Delete
});
[6023] Fix | Delete
dispatch.receiveCurrentTheme(activeThemes[0]);
[6024] Fix | Delete
};
[6025] Fix | Delete
[6026] Fix | Delete
/**
[6027] Fix | Delete
* Requests theme supports data from the index.
[6028] Fix | Delete
*/
[6029] Fix | Delete
const resolvers_getThemeSupports = forward_resolver('getCurrentTheme');
[6030] Fix | Delete
[6031] Fix | Delete
/**
[6032] Fix | Delete
* Requests a preview from the Embed API.
[6033] Fix | Delete
*
[6034] Fix | Delete
* @param {string} url URL to get the preview for.
[6035] Fix | Delete
*/
[6036] Fix | Delete
const resolvers_getEmbedPreview = url => async ({
[6037] Fix | Delete
dispatch
[6038] Fix | Delete
}) => {
[6039] Fix | Delete
try {
[6040] Fix | Delete
const embedProxyResponse = await external_wp_apiFetch_default()({
[6041] Fix | Delete
path: (0,external_wp_url_namespaceObject.addQueryArgs)('/oembed/1.0/proxy', {
[6042] Fix | Delete
url
[6043] Fix | Delete
})
[6044] Fix | Delete
});
[6045] Fix | Delete
dispatch.receiveEmbedPreview(url, embedProxyResponse);
[6046] Fix | Delete
} catch (error) {
[6047] Fix | Delete
// Embed API 404s if the URL cannot be embedded, so we have to catch the error from the apiRequest here.
[6048] Fix | Delete
dispatch.receiveEmbedPreview(url, false);
[6049] Fix | Delete
}
[6050] Fix | Delete
};
[6051] Fix | Delete
[6052] Fix | Delete
/**
[6053] Fix | Delete
* Checks whether the current user can perform the given action on the given
[6054] Fix | Delete
* REST resource.
[6055] Fix | Delete
*
[6056] Fix | Delete
* @param {string} requestedAction Action to check. One of: 'create', 'read', 'update',
[6057] Fix | Delete
* 'delete'.
[6058] Fix | Delete
* @param {string} resource REST resource to check, e.g. 'media' or 'posts'.
[6059] Fix | Delete
* @param {?string} id ID of the rest resource to check.
[6060] Fix | Delete
*/
[6061] Fix | Delete
const resolvers_canUser = (requestedAction, resource, id) => async ({
[6062] Fix | Delete
dispatch,
[6063] Fix | Delete
registry
[6064] Fix | Delete
}) => {
[6065] Fix | Delete
const {
[6066] Fix | Delete
hasStartedResolution
[6067] Fix | Delete
} = registry.select(STORE_NAME);
[6068] Fix | Delete
const resourcePath = id ? `${resource}/${id}` : resource;
[6069] Fix | Delete
const retrievedActions = ['create', 'read', 'update', 'delete'];
[6070] Fix | Delete
if (!retrievedActions.includes(requestedAction)) {
[6071] Fix | Delete
throw new Error(`'${requestedAction}' is not a valid action.`);
[6072] Fix | Delete
}
[6073] Fix | Delete
[6074] Fix | Delete
// Prevent resolving the same resource twice.
[6075] Fix | Delete
for (const relatedAction of retrievedActions) {
[6076] Fix | Delete
if (relatedAction === requestedAction) {
[6077] Fix | Delete
continue;
[6078] Fix | Delete
}
[6079] Fix | Delete
const isAlreadyResolving = hasStartedResolution('canUser', [relatedAction, resource, id]);
[6080] Fix | Delete
if (isAlreadyResolving) {
[6081] Fix | Delete
return;
[6082] Fix | Delete
}
[6083] Fix | Delete
}
[6084] Fix | Delete
let response;
[6085] Fix | Delete
try {
[6086] Fix | Delete
response = await external_wp_apiFetch_default()({
[6087] Fix | Delete
path: `/wp/v2/${resourcePath}`,
[6088] Fix | Delete
method: 'OPTIONS',
[6089] Fix | Delete
parse: false
[6090] Fix | Delete
});
[6091] Fix | Delete
} catch (error) {
[6092] Fix | Delete
// Do nothing if our OPTIONS request comes back with an API error (4xx or
[6093] Fix | Delete
// 5xx). The previously determined isAllowed value will remain in the store.
[6094] Fix | Delete
return;
[6095] Fix | Delete
}
[6096] Fix | Delete
[6097] Fix | Delete
// Optional chaining operator is used here because the API requests don't
[6098] Fix | Delete
// return the expected result in the native version. Instead, API requests
[6099] Fix | Delete
// only return the result, without including response properties like the headers.
[6100] Fix | Delete
const allowHeader = response.headers?.get('allow');
[6101] Fix | Delete
const allowedMethods = allowHeader?.allow || allowHeader || '';
[6102] Fix | Delete
const permissions = {};
[6103] Fix | Delete
const methods = {
[6104] Fix | Delete
create: 'POST',
[6105] Fix | Delete
read: 'GET',
[6106] Fix | Delete
update: 'PUT',
[6107] Fix | Delete
delete: 'DELETE'
[6108] Fix | Delete
};
[6109] Fix | Delete
for (const [actionName, methodName] of Object.entries(methods)) {
[6110] Fix | Delete
permissions[actionName] = allowedMethods.includes(methodName);
[6111] Fix | Delete
}
[6112] Fix | Delete
for (const action of retrievedActions) {
[6113] Fix | Delete
dispatch.receiveUserPermission(`${action}/${resourcePath}`, permissions[action]);
[6114] Fix | Delete
}
[6115] Fix | Delete
};
[6116] Fix | Delete
[6117] Fix | Delete
/**
[6118] Fix | Delete
* Checks whether the current user can perform the given action on the given
[6119] Fix | Delete
* REST resource.
[6120] Fix | Delete
*
[6121] Fix | Delete
* @param {string} kind Entity kind.
[6122] Fix | Delete
* @param {string} name Entity name.
[6123] Fix | Delete
* @param {string} recordId Record's id.
[6124] Fix | Delete
*/
[6125] Fix | Delete
const resolvers_canUserEditEntityRecord = (kind, name, recordId) => async ({
[6126] Fix | Delete
dispatch
[6127] Fix | Delete
}) => {
[6128] Fix | Delete
const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
[6129] Fix | Delete
const entityConfig = configs.find(config => config.name === name && config.kind === kind);
[6130] Fix | Delete
if (!entityConfig) {
[6131] Fix | Delete
return;
[6132] Fix | Delete
}
[6133] Fix | Delete
const resource = entityConfig.__unstable_rest_base;
[6134] Fix | Delete
await dispatch(resolvers_canUser('update', resource, recordId));
[6135] Fix | Delete
};
[6136] Fix | Delete
[6137] Fix | Delete
/**
[6138] Fix | Delete
* Request autosave data from the REST API.
[6139] Fix | Delete
*
[6140] Fix | Delete
* @param {string} postType The type of the parent post.
[6141] Fix | Delete
* @param {number} postId The id of the parent post.
[6142] Fix | Delete
*/
[6143] Fix | Delete
const resolvers_getAutosaves = (postType, postId) => async ({
[6144] Fix | Delete
dispatch,
[6145] Fix | Delete
resolveSelect
[6146] Fix | Delete
}) => {
[6147] Fix | Delete
const {
[6148] Fix | Delete
rest_base: restBase,
[6149] Fix | Delete
rest_namespace: restNamespace = 'wp/v2'
[6150] Fix | Delete
} = await resolveSelect.getPostType(postType);
[6151] Fix | Delete
const autosaves = await external_wp_apiFetch_default()({
[6152] Fix | Delete
path: `/${restNamespace}/${restBase}/${postId}/autosaves?context=edit`
[6153] Fix | Delete
});
[6154] Fix | Delete
if (autosaves && autosaves.length) {
[6155] Fix | Delete
dispatch.receiveAutosaves(postId, autosaves);
[6156] Fix | Delete
}
[6157] Fix | Delete
};
[6158] Fix | Delete
[6159] Fix | Delete
/**
[6160] Fix | Delete
* Request autosave data from the REST API.
[6161] Fix | Delete
*
[6162] Fix | Delete
* This resolver exists to ensure the underlying autosaves are fetched via
[6163] Fix | Delete
* `getAutosaves` when a call to the `getAutosave` selector is made.
[6164] Fix | Delete
*
[6165] Fix | Delete
* @param {string} postType The type of the parent post.
[6166] Fix | Delete
* @param {number} postId The id of the parent post.
[6167] Fix | Delete
*/
[6168] Fix | Delete
const resolvers_getAutosave = (postType, postId) => async ({
[6169] Fix | Delete
resolveSelect
[6170] Fix | Delete
}) => {
[6171] Fix | Delete
await resolveSelect.getAutosaves(postType, postId);
[6172] Fix | Delete
};
[6173] Fix | Delete
[6174] Fix | Delete
/**
[6175] Fix | Delete
* Retrieve the frontend template used for a given link.
[6176] Fix | Delete
*
[6177] Fix | Delete
* @param {string} link Link.
[6178] Fix | Delete
*/
[6179] Fix | Delete
const resolvers_experimentalGetTemplateForLink = link => async ({
[6180] Fix | Delete
dispatch,
[6181] Fix | Delete
resolveSelect
[6182] Fix | Delete
}) => {
[6183] Fix | Delete
let template;
[6184] Fix | Delete
try {
[6185] Fix | Delete
// This is NOT calling a REST endpoint but rather ends up with a response from
[6186] Fix | Delete
// an Ajax function which has a different shape from a WP_REST_Response.
[6187] Fix | Delete
template = await external_wp_apiFetch_default()({
[6188] Fix | Delete
url: (0,external_wp_url_namespaceObject.addQueryArgs)(link, {
[6189] Fix | Delete
'_wp-find-template': true
[6190] Fix | Delete
})
[6191] Fix | Delete
}).then(({
[6192] Fix | Delete
data
[6193] Fix | Delete
}) => data);
[6194] Fix | Delete
} catch (e) {
[6195] Fix | Delete
// For non-FSE themes, it is possible that this request returns an error.
[6196] Fix | Delete
}
[6197] Fix | Delete
if (!template) {
[6198] Fix | Delete
return;
[6199] Fix | Delete
}
[6200] Fix | Delete
const record = await resolveSelect.getEntityRecord('postType', 'wp_template', template.id);
[6201] Fix | Delete
if (record) {
[6202] Fix | Delete
dispatch.receiveEntityRecords('postType', 'wp_template', [record], {
[6203] Fix | Delete
'find-template': link
[6204] Fix | Delete
});
[6205] Fix | Delete
}
[6206] Fix | Delete
};
[6207] Fix | Delete
resolvers_experimentalGetTemplateForLink.shouldInvalidate = action => {
[6208] Fix | Delete
return (action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS') && action.invalidateCache && action.kind === 'postType' && action.name === 'wp_template';
[6209] Fix | Delete
};
[6210] Fix | Delete
const resolvers_experimentalGetCurrentGlobalStylesId = () => async ({
[6211] Fix | Delete
dispatch,
[6212] Fix | Delete
resolveSelect
[6213] Fix | Delete
}) => {
[6214] Fix | Delete
const activeThemes = await resolveSelect.getEntityRecords('root', 'theme', {
[6215] Fix | Delete
status: 'active'
[6216] Fix | Delete
});
[6217] Fix | Delete
const globalStylesURL = activeThemes?.[0]?._links?.['wp:user-global-styles']?.[0]?.href;
[6218] Fix | Delete
if (!globalStylesURL) {
[6219] Fix | Delete
return;
[6220] Fix | Delete
}
[6221] Fix | Delete
[6222] Fix | Delete
// Regex matches the ID at the end of a URL or immediately before
[6223] Fix | Delete
// the query string.
[6224] Fix | Delete
const matches = globalStylesURL.match(/\/(\d+)(?:\?|$)/);
[6225] Fix | Delete
const id = matches ? Number(matches[1]) : null;
[6226] Fix | Delete
if (id) {
[6227] Fix | Delete
dispatch.__experimentalReceiveCurrentGlobalStylesId(id);
[6228] Fix | Delete
}
[6229] Fix | Delete
};
[6230] Fix | Delete
const resolvers_experimentalGetCurrentThemeBaseGlobalStyles = () => async ({
[6231] Fix | Delete
resolveSelect,
[6232] Fix | Delete
dispatch
[6233] Fix | Delete
}) => {
[6234] Fix | Delete
const currentTheme = await resolveSelect.getCurrentTheme();
[6235] Fix | Delete
const themeGlobalStyles = await external_wp_apiFetch_default()({
[6236] Fix | Delete
path: `/wp/v2/global-styles/themes/${currentTheme.stylesheet}`
[6237] Fix | Delete
});
[6238] Fix | Delete
dispatch.__experimentalReceiveThemeBaseGlobalStyles(currentTheme.stylesheet, themeGlobalStyles);
[6239] Fix | Delete
};
[6240] Fix | Delete
const resolvers_experimentalGetCurrentThemeGlobalStylesVariations = () => async ({
[6241] Fix | Delete
resolveSelect,
[6242] Fix | Delete
dispatch
[6243] Fix | Delete
}) => {
[6244] Fix | Delete
const currentTheme = await resolveSelect.getCurrentTheme();
[6245] Fix | Delete
const variations = await external_wp_apiFetch_default()({
[6246] Fix | Delete
path: `/wp/v2/global-styles/themes/${currentTheme.stylesheet}/variations`
[6247] Fix | Delete
});
[6248] Fix | Delete
dispatch.__experimentalReceiveThemeGlobalStyleVariations(currentTheme.stylesheet, variations);
[6249] Fix | Delete
};
[6250] Fix | Delete
[6251] Fix | Delete
/**
[6252] Fix | Delete
* Fetches and returns the revisions of the current global styles theme.
[6253] Fix | Delete
*/
[6254] Fix | Delete
const resolvers_getCurrentThemeGlobalStylesRevisions = () => async ({
[6255] Fix | Delete
resolveSelect,
[6256] Fix | Delete
dispatch
[6257] Fix | Delete
}) => {
[6258] Fix | Delete
const globalStylesId = await resolveSelect.__experimentalGetCurrentGlobalStylesId();
[6259] Fix | Delete
const record = globalStylesId ? await resolveSelect.getEntityRecord('root', 'globalStyles', globalStylesId) : undefined;
[6260] Fix | Delete
const revisionsURL = record?._links?.['version-history']?.[0]?.href;
[6261] Fix | Delete
if (revisionsURL) {
[6262] Fix | Delete
const resetRevisions = await external_wp_apiFetch_default()({
[6263] Fix | Delete
url: revisionsURL
[6264] Fix | Delete
});
[6265] Fix | Delete
const revisions = resetRevisions?.map(revision => Object.fromEntries(Object.entries(revision).map(([key, value]) => [camelCase(key), value])));
[6266] Fix | Delete
dispatch.receiveThemeGlobalStyleRevisions(globalStylesId, revisions);
[6267] Fix | Delete
}
[6268] Fix | Delete
};
[6269] Fix | Delete
resolvers_getCurrentThemeGlobalStylesRevisions.shouldInvalidate = action => {
[6270] Fix | Delete
return action.type === 'SAVE_ENTITY_RECORD_FINISH' && action.kind === 'root' && !action.error && action.name === 'globalStyles';
[6271] Fix | Delete
};
[6272] Fix | Delete
const resolvers_getBlockPatterns = () => async ({
[6273] Fix | Delete
dispatch
[6274] Fix | Delete
}) => {
[6275] Fix | Delete
const patterns = await fetchBlockPatterns();
[6276] Fix | Delete
dispatch({
[6277] Fix | Delete
type: 'RECEIVE_BLOCK_PATTERNS',
[6278] Fix | Delete
patterns
[6279] Fix | Delete
});
[6280] Fix | Delete
};
[6281] Fix | Delete
const resolvers_getBlockPatternCategories = () => async ({
[6282] Fix | Delete
dispatch
[6283] Fix | Delete
}) => {
[6284] Fix | Delete
const categories = await external_wp_apiFetch_default()({
[6285] Fix | Delete
path: '/wp/v2/block-patterns/categories'
[6286] Fix | Delete
});
[6287] Fix | Delete
dispatch({
[6288] Fix | Delete
type: 'RECEIVE_BLOCK_PATTERN_CATEGORIES',
[6289] Fix | Delete
categories
[6290] Fix | Delete
});
[6291] Fix | Delete
};
[6292] Fix | Delete
const resolvers_getUserPatternCategories = () => async ({
[6293] Fix | Delete
dispatch,
[6294] Fix | Delete
resolveSelect
[6295] Fix | Delete
}) => {
[6296] Fix | Delete
const patternCategories = await resolveSelect.getEntityRecords('taxonomy', 'wp_pattern_category', {
[6297] Fix | Delete
per_page: -1,
[6298] Fix | Delete
_fields: 'id,name,description,slug',
[6299] Fix | Delete
context: 'view'
[6300] Fix | Delete
});
[6301] Fix | Delete
const mappedPatternCategories = patternCategories?.map(userCategory => ({
[6302] Fix | Delete
...userCategory,
[6303] Fix | Delete
label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(userCategory.name),
[6304] Fix | Delete
name: userCategory.slug
[6305] Fix | Delete
})) || [];
[6306] Fix | Delete
dispatch({
[6307] Fix | Delete
type: 'RECEIVE_USER_PATTERN_CATEGORIES',
[6308] Fix | Delete
patternCategories: mappedPatternCategories
[6309] Fix | Delete
});
[6310] Fix | Delete
};
[6311] Fix | Delete
const resolvers_getNavigationFallbackId = () => async ({
[6312] Fix | Delete
dispatch,
[6313] Fix | Delete
select
[6314] Fix | Delete
}) => {
[6315] Fix | Delete
const fallback = await external_wp_apiFetch_default()({
[6316] Fix | Delete
path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp-block-editor/v1/navigation-fallback', {
[6317] Fix | Delete
_embed: true
[6318] Fix | Delete
})
[6319] Fix | Delete
});
[6320] Fix | Delete
const record = fallback?._embedded?.self;
[6321] Fix | Delete
dispatch.receiveNavigationFallbackId(fallback?.id);
[6322] Fix | Delete
if (record) {
[6323] Fix | Delete
// If the fallback is already in the store, don't invalidate navigation queries.
[6324] Fix | Delete
// Otherwise, invalidate the cache for the scenario where there were no Navigation
[6325] Fix | Delete
// posts in the state and the fallback created one.
[6326] Fix | Delete
const existingFallbackEntityRecord = select.getEntityRecord('postType', 'wp_navigation', fallback.id);
[6327] Fix | Delete
const invalidateNavigationQueries = !existingFallbackEntityRecord;
[6328] Fix | Delete
dispatch.receiveEntityRecords('postType', 'wp_navigation', record, undefined, invalidateNavigationQueries);
[6329] Fix | Delete
[6330] Fix | Delete
// Resolve to avoid further network requests.
[6331] Fix | Delete
dispatch.finishResolution('getEntityRecord', ['postType', 'wp_navigation', fallback.id]);
[6332] Fix | Delete
}
[6333] Fix | Delete
};
[6334] Fix | Delete
const resolvers_getDefaultTemplateId = query => async ({
[6335] Fix | Delete
dispatch
[6336] Fix | Delete
}) => {
[6337] Fix | Delete
const template = await external_wp_apiFetch_default()({
[6338] Fix | Delete
path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/templates/lookup', query)
[6339] Fix | Delete
});
[6340] Fix | Delete
// Endpoint may return an empty object if no template is found.
[6341] Fix | Delete
if (template?.id) {
[6342] Fix | Delete
dispatch.receiveDefaultTemplateId(query, template.id);
[6343] Fix | Delete
}
[6344] Fix | Delete
};
[6345] Fix | Delete
[6346] Fix | Delete
/**
[6347] Fix | Delete
* Requests an entity's revisions from the REST API.
[6348] Fix | Delete
*
[6349] Fix | Delete
* @param {string} kind Entity kind.
[6350] Fix | Delete
* @param {string} name Entity name.
[6351] Fix | Delete
* @param {number|string} recordKey The key of the entity record whose revisions you want to fetch.
[6352] Fix | Delete
* @param {Object|undefined} query Optional object of query parameters to
[6353] Fix | Delete
* include with request. If requesting specific
[6354] Fix | Delete
* fields, fields must always include the ID.
[6355] Fix | Delete
*/
[6356] Fix | Delete
const resolvers_getRevisions = (kind, name, recordKey, query = {}) => async ({
[6357] Fix | Delete
dispatch
[6358] Fix | Delete
}) => {
[6359] Fix | Delete
const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
[6360] Fix | Delete
const entityConfig = configs.find(config => config.name === name && config.kind === kind);
[6361] Fix | Delete
if (!entityConfig || entityConfig?.__experimentalNoFetch) {
[6362] Fix | Delete
return;
[6363] Fix | Delete
}
[6364] Fix | Delete
if (query._fields) {
[6365] Fix | Delete
// If requesting specific fields, items and query association to said
[6366] Fix | Delete
// records are stored by ID reference. Thus, fields must always include
[6367] Fix | Delete
// the ID.
[6368] Fix | Delete
query = {
[6369] Fix | Delete
...query,
[6370] Fix | Delete
_fields: [...new Set([...(get_normalized_comma_separable(query._fields) || []), entityConfig.revisionKey || DEFAULT_ENTITY_KEY])].join()
[6371] Fix | Delete
};
[6372] Fix | Delete
}
[6373] Fix | Delete
const path = (0,external_wp_url_namespaceObject.addQueryArgs)(entityConfig.getRevisionsUrl(recordKey), query);
[6374] Fix | Delete
let records, response;
[6375] Fix | Delete
const meta = {};
[6376] Fix | Delete
const isPaginated = entityConfig.supportsPagination && query.per_page !== -1;
[6377] Fix | Delete
try {
[6378] Fix | Delete
response = await external_wp_apiFetch_default()({
[6379] Fix | Delete
path,
[6380] Fix | Delete
parse: !isPaginated
[6381] Fix | Delete
});
[6382] Fix | Delete
} catch (error) {
[6383] Fix | Delete
// Do nothing if our request comes back with an API error.
[6384] Fix | Delete
return;
[6385] Fix | Delete
}
[6386] Fix | Delete
if (response) {
[6387] Fix | Delete
if (isPaginated) {
[6388] Fix | Delete
records = Object.values(await response.json());
[6389] Fix | Delete
meta.totalItems = parseInt(response.headers.get('X-WP-Total'));
[6390] Fix | Delete
} else {
[6391] Fix | Delete
records = Object.values(response);
[6392] Fix | Delete
}
[6393] Fix | Delete
[6394] Fix | Delete
// If we request fields but the result doesn't contain the fields,
[6395] Fix | Delete
// explicitly set these fields as "undefined"
[6396] Fix | Delete
// that way we consider the query "fulfilled".
[6397] Fix | Delete
if (query._fields) {
[6398] Fix | Delete
records = records.map(record => {
[6399] Fix | Delete
query._fields.split(',').forEach(field => {
[6400] Fix | Delete
if (!record.hasOwnProperty(field)) {
[6401] Fix | Delete
record[field] = undefined;
[6402] Fix | Delete
}
[6403] Fix | Delete
});
[6404] Fix | Delete
return record;
[6405] Fix | Delete
});
[6406] Fix | Delete
}
[6407] Fix | Delete
dispatch.receiveRevisions(kind, name, recordKey, records, query, false, meta);
[6408] Fix | Delete
[6409] Fix | Delete
// When requesting all fields, the list of results can be used to
[6410] Fix | Delete
// resolve the `getRevision` selector in addition to `getRevisions`.
[6411] Fix | Delete
if (!query?._fields && !query.context) {
[6412] Fix | Delete
const key = entityConfig.key || DEFAULT_ENTITY_KEY;
[6413] Fix | Delete
const resolutionsArgs = records.filter(record => record[key]).map(record => [kind, name, recordKey, record[key]]);
[6414] Fix | Delete
dispatch({
[6415] Fix | Delete
type: 'START_RESOLUTIONS',
[6416] Fix | Delete
selectorName: 'getRevision',
[6417] Fix | Delete
args: resolutionsArgs
[6418] Fix | Delete
});
[6419] Fix | Delete
dispatch({
[6420] Fix | Delete
type: 'FINISH_RESOLUTIONS',
[6421] Fix | Delete
selectorName: 'getRevision',
[6422] Fix | Delete
args: resolutionsArgs
[6423] Fix | Delete
});
[6424] Fix | Delete
}
[6425] Fix | Delete
}
[6426] Fix | Delete
};
[6427] Fix | Delete
[6428] Fix | Delete
// Invalidate cache when a new revision is created.
[6429] Fix | Delete
resolvers_getRevisions.shouldInvalidate = (action, kind, name, recordKey) => action.type === 'SAVE_ENTITY_RECORD_FINISH' && name === action.name && kind === action.kind && !action.error && recordKey === action.recordId;
[6430] Fix | Delete
[6431] Fix | Delete
/**
[6432] Fix | Delete
* Requests a specific Entity revision from the REST API.
[6433] Fix | Delete
*
[6434] Fix | Delete
* @param {string} kind Entity kind.
[6435] Fix | Delete
* @param {string} name Entity name.
[6436] Fix | Delete
* @param {number|string} recordKey The key of the entity record whose revisions you want to fetch.
[6437] Fix | Delete
* @param {number|string} revisionKey The revision's key.
[6438] Fix | Delete
* @param {Object|undefined} query Optional object of query parameters to
[6439] Fix | Delete
* include with request. If requesting specific
[6440] Fix | Delete
* fields, fields must always include the ID.
[6441] Fix | Delete
*/
[6442] Fix | Delete
const resolvers_getRevision = (kind, name, recordKey, revisionKey, query) => async ({
[6443] Fix | Delete
dispatch
[6444] Fix | Delete
}) => {
[6445] Fix | Delete
const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
[6446] Fix | Delete
const entityConfig = configs.find(config => config.name === name && config.kind === kind);
[6447] Fix | Delete
if (!entityConfig || entityConfig?.__experimentalNoFetch) {
[6448] Fix | Delete
return;
[6449] Fix | Delete
}
[6450] Fix | Delete
if (query !== undefined && query._fields) {
[6451] Fix | Delete
// If requesting specific fields, items and query association to said
[6452] Fix | Delete
// records are stored by ID reference. Thus, fields must always include
[6453] Fix | Delete
// the ID.
[6454] Fix | Delete
query = {
[6455] Fix | Delete
...query,
[6456] Fix | Delete
_fields: [...new Set([...(get_normalized_comma_separable(query._fields) || []), entityConfig.revisionKey || DEFAULT_ENTITY_KEY])].join()
[6457] Fix | Delete
};
[6458] Fix | Delete
}
[6459] Fix | Delete
const path = (0,external_wp_url_namespaceObject.addQueryArgs)(entityConfig.getRevisionsUrl(recordKey, revisionKey), query);
[6460] Fix | Delete
let record;
[6461] Fix | Delete
try {
[6462] Fix | Delete
record = await external_wp_apiFetch_default()({
[6463] Fix | Delete
path
[6464] Fix | Delete
});
[6465] Fix | Delete
} catch (error) {
[6466] Fix | Delete
// Do nothing if our request comes back with an API error.
[6467] Fix | Delete
return;
[6468] Fix | Delete
}
[6469] Fix | Delete
if (record) {
[6470] Fix | Delete
dispatch.receiveRevisions(kind, name, recordKey, record, query);
[6471] Fix | Delete
}
[6472] Fix | Delete
};
[6473] Fix | Delete
[6474] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/utils.js
[6475] Fix | Delete
function deepCopyLocksTreePath(tree, path) {
[6476] Fix | Delete
const newTree = {
[6477] Fix | Delete
...tree
[6478] Fix | Delete
};
[6479] Fix | Delete
let currentNode = newTree;
[6480] Fix | Delete
for (const branchName of path) {
[6481] Fix | Delete
currentNode.children = {
[6482] Fix | Delete
...currentNode.children,
[6483] Fix | Delete
[branchName]: {
[6484] Fix | Delete
locks: [],
[6485] Fix | Delete
children: {},
[6486] Fix | Delete
...currentNode.children[branchName]
[6487] Fix | Delete
}
[6488] Fix | Delete
};
[6489] Fix | Delete
currentNode = currentNode.children[branchName];
[6490] Fix | Delete
}
[6491] Fix | Delete
return newTree;
[6492] Fix | Delete
}
[6493] Fix | Delete
function getNode(tree, path) {
[6494] Fix | Delete
let currentNode = tree;
[6495] Fix | Delete
for (const branchName of path) {
[6496] Fix | Delete
const nextNode = currentNode.children[branchName];
[6497] Fix | Delete
if (!nextNode) {
[6498] Fix | Delete
return null;
[6499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function