plugin updates
This commit is contained in:
195
wp/wp-includes/js/dist/core-commands.js
vendored
195
wp/wp-includes/js/dist/core-commands.js
vendored
@@ -65,6 +65,30 @@ const plus = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(exter
|
||||
});
|
||||
/* harmony default export */ const library_plus = (plus);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","url"]
|
||||
const external_wp_url_namespaceObject = window["wp"]["url"];
|
||||
;// CONCATENATED MODULE: external ["wp","coreData"]
|
||||
const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
|
||||
;// CONCATENATED MODULE: external ["wp","data"]
|
||||
const external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: external ["wp","notices"]
|
||||
const external_wp_notices_namespaceObject = window["wp"]["notices"];
|
||||
;// CONCATENATED MODULE: external ["wp","router"]
|
||||
const external_wp_router_namespaceObject = window["wp"]["router"];
|
||||
;// CONCATENATED MODULE: external ["wp","privateApis"]
|
||||
const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/lock-unlock.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const {
|
||||
lock,
|
||||
unlock
|
||||
} = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/core-commands');
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/admin-navigation-commands.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
@@ -72,6 +96,71 @@ const plus = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(exter
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
const {
|
||||
useHistory
|
||||
} = unlock(external_wp_router_namespaceObject.privateApis);
|
||||
function useAddNewPageCommand() {
|
||||
const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php');
|
||||
const history = useHistory();
|
||||
const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => {
|
||||
return select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme;
|
||||
}, []);
|
||||
const {
|
||||
saveEntityRecord
|
||||
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
|
||||
const {
|
||||
createErrorNotice
|
||||
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
|
||||
const createPageEntity = (0,external_wp_element_namespaceObject.useCallback)(async ({
|
||||
close
|
||||
}) => {
|
||||
try {
|
||||
const page = await saveEntityRecord('postType', 'page', {
|
||||
status: 'draft'
|
||||
}, {
|
||||
throwOnError: true
|
||||
});
|
||||
if (page?.id) {
|
||||
history.push({
|
||||
postId: page.id,
|
||||
postType: 'page',
|
||||
canvas: 'edit'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the item.');
|
||||
createErrorNotice(errorMessage, {
|
||||
type: 'snackbar'
|
||||
});
|
||||
} finally {
|
||||
close();
|
||||
}
|
||||
}, [createErrorNotice, history, saveEntityRecord]);
|
||||
const commands = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
||||
const addNewPage = isSiteEditor && isBlockBasedTheme ? createPageEntity : () => document.location.href = 'post-new.php?post_type=page';
|
||||
return [{
|
||||
name: 'core/add-new-page',
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Add new page'),
|
||||
icon: library_plus,
|
||||
callback: addNewPage
|
||||
}];
|
||||
}, [createPageEntity, isSiteEditor, isBlockBasedTheme]);
|
||||
return {
|
||||
isLoading: false,
|
||||
commands
|
||||
};
|
||||
}
|
||||
function useAdminNavigationCommands() {
|
||||
(0,external_wp_commands_namespaceObject.useCommand)({
|
||||
name: 'core/add-new-post',
|
||||
@@ -81,22 +170,12 @@ function useAdminNavigationCommands() {
|
||||
document.location.href = 'post-new.php';
|
||||
}
|
||||
});
|
||||
(0,external_wp_commands_namespaceObject.useCommand)({
|
||||
(0,external_wp_commands_namespaceObject.useCommandLoader)({
|
||||
name: 'core/add-new-page',
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Add new page'),
|
||||
icon: library_plus,
|
||||
callback: () => {
|
||||
document.location.href = 'post-new.php?post_type=page';
|
||||
}
|
||||
hook: useAddNewPageCommand
|
||||
});
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: external ["wp","data"]
|
||||
const external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// CONCATENATED MODULE: external ["wp","coreData"]
|
||||
const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/post.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
@@ -185,7 +264,9 @@ const styles = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ext
|
||||
viewBox: "0 0 24 24",
|
||||
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 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z"
|
||||
fillRule: "evenodd",
|
||||
clipRule: "evenodd",
|
||||
d: "M20 12a8 8 0 1 1-16 0 8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 0 1-6.5 6.5v-13a6.5 6.5 0 0 1 6.5 6.5Z"
|
||||
})
|
||||
});
|
||||
/* harmony default export */ const library_styles = (styles);
|
||||
@@ -205,34 +286,10 @@ const symbol = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ext
|
||||
});
|
||||
/* harmony default export */ const library_symbol = (symbol);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","router"]
|
||||
const external_wp_router_namespaceObject = window["wp"]["router"];
|
||||
;// CONCATENATED MODULE: external ["wp","url"]
|
||||
const external_wp_url_namespaceObject = window["wp"]["url"];
|
||||
;// CONCATENATED MODULE: external ["wp","compose"]
|
||||
const external_wp_compose_namespaceObject = window["wp"]["compose"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/hooks.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
function useIsBlockBasedTheme() {
|
||||
return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme, []);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","privateApis"]
|
||||
const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/lock-unlock.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const {
|
||||
lock,
|
||||
unlock
|
||||
} = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/core-commands');
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","htmlEntities"]
|
||||
const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/utils/order-entity-records-by-search.js
|
||||
function orderEntityRecordsBySearch(records = [], search = '') {
|
||||
if (!Array.isArray(records) || !records.length) {
|
||||
@@ -268,14 +325,14 @@ function orderEntityRecordsBySearch(records = [], search = '') {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const {
|
||||
useHistory
|
||||
useHistory: site_editor_navigation_commands_useHistory
|
||||
} = unlock(external_wp_router_namespaceObject.privateApis);
|
||||
const icons = {
|
||||
post: library_post,
|
||||
@@ -295,8 +352,19 @@ function useDebouncedValue(value) {
|
||||
const getNavigationCommandLoaderPerPostType = postType => function useNavigationCommandLoader({
|
||||
search
|
||||
}) {
|
||||
const history = useHistory();
|
||||
const isBlockBasedTheme = useIsBlockBasedTheme();
|
||||
const history = site_editor_navigation_commands_useHistory();
|
||||
const {
|
||||
isBlockBasedTheme,
|
||||
canCreateTemplate
|
||||
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
|
||||
return {
|
||||
isBlockBasedTheme: select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme,
|
||||
canCreateTemplate: select(external_wp_coreData_namespaceObject.store).canUser('create', {
|
||||
kind: 'postType',
|
||||
name: 'wp_template'
|
||||
})
|
||||
};
|
||||
}, []);
|
||||
const delayedSearch = useDebouncedValue(search);
|
||||
const {
|
||||
records,
|
||||
@@ -323,10 +391,10 @@ const getNavigationCommandLoaderPerPostType = postType => function useNavigation
|
||||
const command = {
|
||||
name: postType + '-' + record.id,
|
||||
searchLabel: record.title?.rendered + ' ' + record.id,
|
||||
label: record.title?.rendered ? record.title?.rendered : (0,external_wp_i18n_namespaceObject.__)('(no title)'),
|
||||
label: record.title?.rendered ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(record.title?.rendered) : (0,external_wp_i18n_namespaceObject.__)('(no title)'),
|
||||
icon: icons[postType]
|
||||
};
|
||||
if (postType === 'post' || postType === 'page' && !isBlockBasedTheme) {
|
||||
if (!canCreateTemplate || postType === 'post' || postType === 'page' && !isBlockBasedTheme) {
|
||||
return {
|
||||
...command,
|
||||
callback: ({
|
||||
@@ -363,7 +431,7 @@ const getNavigationCommandLoaderPerPostType = postType => function useNavigation
|
||||
}
|
||||
};
|
||||
});
|
||||
}, [records, isBlockBasedTheme, history]);
|
||||
}, [canCreateTemplate, records, isBlockBasedTheme, history]);
|
||||
return {
|
||||
commands,
|
||||
isLoading
|
||||
@@ -372,8 +440,19 @@ const getNavigationCommandLoaderPerPostType = postType => function useNavigation
|
||||
const getNavigationCommandLoaderPerTemplate = templateType => function useNavigationCommandLoader({
|
||||
search
|
||||
}) {
|
||||
const history = useHistory();
|
||||
const isBlockBasedTheme = useIsBlockBasedTheme();
|
||||
const history = site_editor_navigation_commands_useHistory();
|
||||
const {
|
||||
isBlockBasedTheme,
|
||||
canCreateTemplate
|
||||
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
|
||||
return {
|
||||
isBlockBasedTheme: select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme,
|
||||
canCreateTemplate: select(external_wp_coreData_namespaceObject.store).canUser('create', {
|
||||
kind: 'postType',
|
||||
name: templateType
|
||||
})
|
||||
};
|
||||
}, []);
|
||||
const {
|
||||
records,
|
||||
isLoading
|
||||
@@ -399,7 +478,7 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
|
||||
return orderEntityRecordsBySearch(records, search).slice(0, 10);
|
||||
}, [records, search]);
|
||||
const commands = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
||||
if (!isBlockBasedTheme && !templateType === 'wp_template_part') {
|
||||
if (!canCreateTemplate || !isBlockBasedTheme && !templateType === 'wp_template_part') {
|
||||
return [];
|
||||
}
|
||||
const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php');
|
||||
@@ -451,7 +530,7 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}, [isBlockBasedTheme, orderedRecords, history]);
|
||||
}, [canCreateTemplate, isBlockBasedTheme, orderedRecords, history]);
|
||||
return {
|
||||
commands,
|
||||
isLoading
|
||||
@@ -462,12 +541,20 @@ const usePostNavigationCommandLoader = getNavigationCommandLoaderPerPostType('po
|
||||
const useTemplateNavigationCommandLoader = getNavigationCommandLoaderPerTemplate('wp_template');
|
||||
const useTemplatePartNavigationCommandLoader = getNavigationCommandLoaderPerTemplate('wp_template_part');
|
||||
function useSiteEditorBasicNavigationCommands() {
|
||||
const history = useHistory();
|
||||
const history = site_editor_navigation_commands_useHistory();
|
||||
const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php');
|
||||
const canCreateTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => {
|
||||
return select(external_wp_coreData_namespaceObject.store).canUser('create', 'templates');
|
||||
const {
|
||||
isBlockBasedTheme,
|
||||
canCreateTemplate
|
||||
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
|
||||
return {
|
||||
isBlockBasedTheme: select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme,
|
||||
canCreateTemplate: select(external_wp_coreData_namespaceObject.store).canUser('create', {
|
||||
kind: 'postType',
|
||||
name: 'wp_template'
|
||||
})
|
||||
};
|
||||
}, []);
|
||||
const isBlockBasedTheme = useIsBlockBasedTheme();
|
||||
const commands = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
||||
const result = [];
|
||||
if (canCreateTemplate && isBlockBasedTheme) {
|
||||
|
||||
Reference in New Issue
Block a user