40 // EXPORTS |
40 // EXPORTS |
41 __webpack_require__.d(__webpack_exports__, { |
41 __webpack_require__.d(__webpack_exports__, { |
42 privateApis: () => (/* reexport */ privateApis) |
42 privateApis: () => (/* reexport */ privateApis) |
43 }); |
43 }); |
44 |
44 |
45 ;// CONCATENATED MODULE: external ["wp","commands"] |
45 ;// external ["wp","commands"] |
46 const external_wp_commands_namespaceObject = window["wp"]["commands"]; |
46 const external_wp_commands_namespaceObject = window["wp"]["commands"]; |
47 ;// CONCATENATED MODULE: external ["wp","i18n"] |
47 ;// external ["wp","i18n"] |
48 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
48 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
49 ;// CONCATENATED MODULE: external ["wp","primitives"] |
49 ;// external ["wp","primitives"] |
50 const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; |
50 const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; |
51 ;// CONCATENATED MODULE: external "ReactJSXRuntime" |
51 ;// external "ReactJSXRuntime" |
52 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; |
52 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; |
53 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plus.js |
53 ;// ./node_modules/@wordpress/icons/build-module/library/plus.js |
54 /** |
54 /** |
55 * WordPress dependencies |
55 * WordPress dependencies |
56 */ |
56 */ |
57 |
57 |
58 |
58 |
63 d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" |
63 d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" |
64 }) |
64 }) |
65 }); |
65 }); |
66 /* harmony default export */ const library_plus = (plus); |
66 /* harmony default export */ const library_plus = (plus); |
67 |
67 |
68 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/admin-navigation-commands.js |
68 ;// external ["wp","url"] |
69 /** |
69 const external_wp_url_namespaceObject = window["wp"]["url"]; |
70 * WordPress dependencies |
70 ;// external ["wp","coreData"] |
71 */ |
71 const external_wp_coreData_namespaceObject = window["wp"]["coreData"]; |
72 |
72 ;// external ["wp","data"] |
73 |
73 const external_wp_data_namespaceObject = window["wp"]["data"]; |
74 |
74 ;// external ["wp","element"] |
|
75 const external_wp_element_namespaceObject = window["wp"]["element"]; |
|
76 ;// external ["wp","notices"] |
|
77 const external_wp_notices_namespaceObject = window["wp"]["notices"]; |
|
78 ;// external ["wp","router"] |
|
79 const external_wp_router_namespaceObject = window["wp"]["router"]; |
|
80 ;// external ["wp","privateApis"] |
|
81 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; |
|
82 ;// ./node_modules/@wordpress/core-commands/build-module/lock-unlock.js |
|
83 /** |
|
84 * WordPress dependencies |
|
85 */ |
|
86 |
|
87 const { |
|
88 lock, |
|
89 unlock |
|
90 } = (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'); |
|
91 |
|
92 ;// ./node_modules/@wordpress/core-commands/build-module/admin-navigation-commands.js |
|
93 /** |
|
94 * WordPress dependencies |
|
95 */ |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 /** |
|
107 * Internal dependencies |
|
108 */ |
|
109 |
|
110 const { |
|
111 useHistory |
|
112 } = unlock(external_wp_router_namespaceObject.privateApis); |
|
113 const getAddNewPageCommand = () => function useAddNewPageCommand() { |
|
114 const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php'); |
|
115 const history = useHistory(); |
|
116 const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => { |
|
117 return select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme; |
|
118 }, []); |
|
119 const { |
|
120 saveEntityRecord |
|
121 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); |
|
122 const { |
|
123 createErrorNotice |
|
124 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); |
|
125 const createPageEntity = (0,external_wp_element_namespaceObject.useCallback)(async ({ |
|
126 close |
|
127 }) => { |
|
128 try { |
|
129 const page = await saveEntityRecord('postType', 'page', { |
|
130 status: 'draft' |
|
131 }, { |
|
132 throwOnError: true |
|
133 }); |
|
134 if (page?.id) { |
|
135 history.navigate(`/page/${page.id}?canvas=edit`); |
|
136 } |
|
137 } catch (error) { |
|
138 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the item.'); |
|
139 createErrorNotice(errorMessage, { |
|
140 type: 'snackbar' |
|
141 }); |
|
142 } finally { |
|
143 close(); |
|
144 } |
|
145 }, [createErrorNotice, history, saveEntityRecord]); |
|
146 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { |
|
147 const addNewPage = isSiteEditor && isBlockBasedTheme ? createPageEntity : () => document.location.href = 'post-new.php?post_type=page'; |
|
148 return [{ |
|
149 name: 'core/add-new-page', |
|
150 label: (0,external_wp_i18n_namespaceObject.__)('Add new page'), |
|
151 icon: library_plus, |
|
152 callback: addNewPage |
|
153 }]; |
|
154 }, [createPageEntity, isSiteEditor, isBlockBasedTheme]); |
|
155 return { |
|
156 isLoading: false, |
|
157 commands |
|
158 }; |
|
159 }; |
75 function useAdminNavigationCommands() { |
160 function useAdminNavigationCommands() { |
76 (0,external_wp_commands_namespaceObject.useCommand)({ |
161 (0,external_wp_commands_namespaceObject.useCommand)({ |
77 name: 'core/add-new-post', |
162 name: 'core/add-new-post', |
78 label: (0,external_wp_i18n_namespaceObject.__)('Add new post'), |
163 label: (0,external_wp_i18n_namespaceObject.__)('Add new post'), |
79 icon: library_plus, |
164 icon: library_plus, |
80 callback: () => { |
165 callback: () => { |
81 document.location.href = 'post-new.php'; |
166 document.location.assign('post-new.php'); |
82 } |
167 } |
83 }); |
168 }); |
84 (0,external_wp_commands_namespaceObject.useCommand)({ |
169 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
85 name: 'core/add-new-page', |
170 name: 'core/add-new-page', |
86 label: (0,external_wp_i18n_namespaceObject.__)('Add new page'), |
171 hook: getAddNewPageCommand() |
87 icon: library_plus, |
|
88 callback: () => { |
|
89 document.location.href = 'post-new.php?post_type=page'; |
|
90 } |
|
91 }); |
172 }); |
92 } |
173 } |
93 |
174 |
94 ;// CONCATENATED MODULE: external ["wp","element"] |
175 ;// ./node_modules/@wordpress/icons/build-module/library/post.js |
95 const external_wp_element_namespaceObject = window["wp"]["element"]; |
|
96 ;// CONCATENATED MODULE: external ["wp","data"] |
|
97 const external_wp_data_namespaceObject = window["wp"]["data"]; |
|
98 ;// CONCATENATED MODULE: external ["wp","coreData"] |
|
99 const external_wp_coreData_namespaceObject = window["wp"]["coreData"]; |
|
100 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/post.js |
|
101 /** |
176 /** |
102 * WordPress dependencies |
177 * WordPress dependencies |
103 */ |
178 */ |
104 |
179 |
105 |
180 |
110 d: "m7.3 9.7 1.4 1.4c.2-.2.3-.3.4-.5 0 0 0-.1.1-.1.3-.5.4-1.1.3-1.6L12 7 9 4 7.2 6.5c-.6-.1-1.1 0-1.6.3 0 0-.1 0-.1.1-.3.1-.4.2-.6.4l1.4 1.4L4 11v1h1l2.3-2.3zM4 20h9v-1.5H4V20zm0-5.5V16h16v-1.5H4z" |
185 d: "m7.3 9.7 1.4 1.4c.2-.2.3-.3.4-.5 0 0 0-.1.1-.1.3-.5.4-1.1.3-1.6L12 7 9 4 7.2 6.5c-.6-.1-1.1 0-1.6.3 0 0-.1 0-.1.1-.3.1-.4.2-.6.4l1.4 1.4L4 11v1h1l2.3-2.3zM4 20h9v-1.5H4V20zm0-5.5V16h16v-1.5H4z" |
111 }) |
186 }) |
112 }); |
187 }); |
113 /* harmony default export */ const library_post = (post); |
188 /* harmony default export */ const library_post = (post); |
114 |
189 |
115 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/page.js |
190 ;// ./node_modules/@wordpress/icons/build-module/library/page.js |
116 /** |
191 /** |
117 * WordPress dependencies |
192 * WordPress dependencies |
118 */ |
193 */ |
119 |
|
120 |
194 |
121 |
195 |
122 const page = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, { |
196 const page = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, { |
123 xmlns: "http://www.w3.org/2000/svg", |
197 xmlns: "http://www.w3.org/2000/svg", |
124 viewBox: "0 0 24 24", |
198 viewBox: "0 0 24 24", |
173 d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14.5c-3.6 0-6.5-2.9-6.5-6.5S8.4 5.5 12 5.5s6.5 2.9 6.5 6.5-2.9 6.5-6.5 6.5zM9 16l4.5-3L15 8.4l-4.5 3L9 16z" |
247 d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14.5c-3.6 0-6.5-2.9-6.5-6.5S8.4 5.5 12 5.5s6.5 2.9 6.5 6.5-2.9 6.5-6.5 6.5zM9 16l4.5-3L15 8.4l-4.5 3L9 16z" |
174 }) |
248 }) |
175 }); |
249 }); |
176 /* harmony default export */ const library_navigation = (navigation); |
250 /* harmony default export */ const library_navigation = (navigation); |
177 |
251 |
178 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/styles.js |
252 ;// ./node_modules/@wordpress/icons/build-module/library/styles.js |
179 /** |
253 /** |
180 * WordPress dependencies |
254 * WordPress dependencies |
181 */ |
255 */ |
182 |
256 |
183 |
257 |
184 const styles = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
258 const styles = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
185 viewBox: "0 0 24 24", |
259 viewBox: "0 0 24 24", |
186 xmlns: "http://www.w3.org/2000/svg", |
260 xmlns: "http://www.w3.org/2000/svg", |
187 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
261 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
188 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" |
262 fillRule: "evenodd", |
|
263 clipRule: "evenodd", |
|
264 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" |
189 }) |
265 }) |
190 }); |
266 }); |
191 /* harmony default export */ const library_styles = (styles); |
267 /* harmony default export */ const library_styles = (styles); |
192 |
268 |
193 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js |
269 ;// ./node_modules/@wordpress/icons/build-module/library/symbol.js |
194 /** |
270 /** |
195 * WordPress dependencies |
271 * WordPress dependencies |
196 */ |
272 */ |
197 |
273 |
198 |
274 |
203 d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" |
279 d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" |
204 }) |
280 }) |
205 }); |
281 }); |
206 /* harmony default export */ const library_symbol = (symbol); |
282 /* harmony default export */ const library_symbol = (symbol); |
207 |
283 |
208 ;// CONCATENATED MODULE: external ["wp","router"] |
284 ;// external ["wp","compose"] |
209 const external_wp_router_namespaceObject = window["wp"]["router"]; |
|
210 ;// CONCATENATED MODULE: external ["wp","url"] |
|
211 const external_wp_url_namespaceObject = window["wp"]["url"]; |
|
212 ;// CONCATENATED MODULE: external ["wp","compose"] |
|
213 const external_wp_compose_namespaceObject = window["wp"]["compose"]; |
285 const external_wp_compose_namespaceObject = window["wp"]["compose"]; |
214 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/hooks.js |
286 ;// external ["wp","htmlEntities"] |
215 /** |
287 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; |
216 * WordPress dependencies |
288 ;// ./node_modules/@wordpress/core-commands/build-module/utils/order-entity-records-by-search.js |
217 */ |
|
218 |
|
219 |
|
220 function useIsBlockBasedTheme() { |
|
221 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme, []); |
|
222 } |
|
223 |
|
224 ;// CONCATENATED MODULE: external ["wp","privateApis"] |
|
225 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; |
|
226 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/lock-unlock.js |
|
227 /** |
|
228 * WordPress dependencies |
|
229 */ |
|
230 |
|
231 const { |
|
232 lock, |
|
233 unlock |
|
234 } = (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'); |
|
235 |
|
236 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/utils/order-entity-records-by-search.js |
|
237 function orderEntityRecordsBySearch(records = [], search = '') { |
289 function orderEntityRecordsBySearch(records = [], search = '') { |
238 if (!Array.isArray(records) || !records.length) { |
290 if (!Array.isArray(records) || !records.length) { |
239 return []; |
291 return []; |
240 } |
292 } |
241 if (!search) { |
293 if (!search) { |
321 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { |
384 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { |
322 return (records !== null && records !== void 0 ? records : []).map(record => { |
385 return (records !== null && records !== void 0 ? records : []).map(record => { |
323 const command = { |
386 const command = { |
324 name: postType + '-' + record.id, |
387 name: postType + '-' + record.id, |
325 searchLabel: record.title?.rendered + ' ' + record.id, |
388 searchLabel: record.title?.rendered + ' ' + record.id, |
326 label: record.title?.rendered ? record.title?.rendered : (0,external_wp_i18n_namespaceObject.__)('(no title)'), |
389 label: record.title?.rendered ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(record.title?.rendered) : (0,external_wp_i18n_namespaceObject.__)('(no title)'), |
327 icon: icons[postType] |
390 icon: icons[postType] |
328 }; |
391 }; |
329 if (postType === 'post' || postType === 'page' && !isBlockBasedTheme) { |
392 if (!canCreateTemplate || postType === 'post' || postType === 'page' && !isBlockBasedTheme) { |
330 return { |
393 return { |
331 ...command, |
394 ...command, |
332 callback: ({ |
395 callback: ({ |
333 close |
396 close |
334 }) => { |
397 }) => { |
346 return { |
409 return { |
347 ...command, |
410 ...command, |
348 callback: ({ |
411 callback: ({ |
349 close |
412 close |
350 }) => { |
413 }) => { |
351 const args = { |
414 if (isSiteEditor) { |
352 postType, |
415 history.navigate(`/${postType}/${record.id}?canvas=edit`); |
353 postId: record.id, |
416 } else { |
354 canvas: 'edit' |
417 document.location = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', { |
355 }; |
418 p: `/${postType}/${record.id}`, |
356 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args); |
419 canvas: 'edit' |
357 if (isSiteEditor) { |
420 }); |
358 history.push(args); |
|
359 } else { |
|
360 document.location = targetUrl; |
|
361 } |
421 } |
362 close(); |
422 close(); |
363 } |
423 } |
364 }; |
424 }; |
365 }); |
425 }); |
366 }, [records, isBlockBasedTheme, history]); |
426 }, [canCreateTemplate, records, isBlockBasedTheme, history]); |
367 return { |
427 return { |
368 commands, |
428 commands, |
369 isLoading |
429 isLoading |
370 }; |
430 }; |
371 }; |
431 }; |
372 const getNavigationCommandLoaderPerTemplate = templateType => function useNavigationCommandLoader({ |
432 const getNavigationCommandLoaderPerTemplate = templateType => function useNavigationCommandLoader({ |
373 search |
433 search |
374 }) { |
434 }) { |
375 const history = useHistory(); |
435 const history = site_editor_navigation_commands_useHistory(); |
376 const isBlockBasedTheme = useIsBlockBasedTheme(); |
436 const { |
|
437 isBlockBasedTheme, |
|
438 canCreateTemplate |
|
439 } = (0,external_wp_data_namespaceObject.useSelect)(select => { |
|
440 return { |
|
441 isBlockBasedTheme: select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme, |
|
442 canCreateTemplate: select(external_wp_coreData_namespaceObject.store).canUser('create', { |
|
443 kind: 'postType', |
|
444 name: templateType |
|
445 }) |
|
446 }; |
|
447 }, []); |
377 const { |
448 const { |
378 records, |
449 records, |
379 isLoading |
450 isLoading |
380 } = (0,external_wp_data_namespaceObject.useSelect)(select => { |
451 } = (0,external_wp_data_namespaceObject.useSelect)(select => { |
381 const { |
452 const { |
397 */ |
468 */ |
398 const orderedRecords = (0,external_wp_element_namespaceObject.useMemo)(() => { |
469 const orderedRecords = (0,external_wp_element_namespaceObject.useMemo)(() => { |
399 return orderEntityRecordsBySearch(records, search).slice(0, 10); |
470 return orderEntityRecordsBySearch(records, search).slice(0, 10); |
400 }, [records, search]); |
471 }, [records, search]); |
401 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { |
472 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { |
402 if (!isBlockBasedTheme && !templateType === 'wp_template_part') { |
473 if (!canCreateTemplate || !isBlockBasedTheme && !templateType === 'wp_template_part') { |
403 return []; |
474 return []; |
404 } |
475 } |
405 const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php'); |
476 const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php'); |
406 const result = []; |
477 const result = []; |
407 result.push(...orderedRecords.map(record => { |
478 result.push(...orderedRecords.map(record => { |
434 label: (0,external_wp_i18n_namespaceObject.__)('Template parts'), |
502 label: (0,external_wp_i18n_namespaceObject.__)('Template parts'), |
435 icon: symbol_filled, |
503 icon: symbol_filled, |
436 callback: ({ |
504 callback: ({ |
437 close |
505 close |
438 }) => { |
506 }) => { |
439 const args = { |
507 if (isSiteEditor) { |
440 postType: 'wp_template_part', |
508 history.navigate('/pattern?postType=wp_template_part&categoryId=all-parts'); |
441 categoryId: 'all-parts' |
509 } else { |
442 }; |
510 document.location = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', { |
443 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args); |
511 p: '/pattern', |
444 if (isSiteEditor) { |
512 postType: 'wp_template_part', |
445 history.push(args); |
513 categoryId: 'all-parts' |
446 } else { |
514 }); |
447 document.location = targetUrl; |
|
448 } |
515 } |
449 close(); |
516 close(); |
450 } |
517 } |
451 }); |
518 }); |
452 } |
519 } |
453 return result; |
520 return result; |
454 }, [isBlockBasedTheme, orderedRecords, history]); |
521 }, [canCreateTemplate, isBlockBasedTheme, orderedRecords, history]); |
455 return { |
522 return { |
456 commands, |
523 commands, |
457 isLoading |
524 isLoading |
458 }; |
525 }; |
459 }; |
526 }; |
460 const usePageNavigationCommandLoader = getNavigationCommandLoaderPerPostType('page'); |
527 const getSiteEditorBasicNavigationCommands = () => function useSiteEditorBasicNavigationCommands() { |
461 const usePostNavigationCommandLoader = getNavigationCommandLoaderPerPostType('post'); |
528 const history = site_editor_navigation_commands_useHistory(); |
462 const useTemplateNavigationCommandLoader = getNavigationCommandLoaderPerTemplate('wp_template'); |
|
463 const useTemplatePartNavigationCommandLoader = getNavigationCommandLoaderPerTemplate('wp_template_part'); |
|
464 function useSiteEditorBasicNavigationCommands() { |
|
465 const history = useHistory(); |
|
466 const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php'); |
529 const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php'); |
467 const canCreateTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => { |
530 const { |
468 return select(external_wp_coreData_namespaceObject.store).canUser('create', 'templates'); |
531 isBlockBasedTheme, |
|
532 canCreateTemplate |
|
533 } = (0,external_wp_data_namespaceObject.useSelect)(select => { |
|
534 return { |
|
535 isBlockBasedTheme: select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme, |
|
536 canCreateTemplate: select(external_wp_coreData_namespaceObject.store).canUser('create', { |
|
537 kind: 'postType', |
|
538 name: 'wp_template' |
|
539 }) |
|
540 }; |
469 }, []); |
541 }, []); |
470 const isBlockBasedTheme = useIsBlockBasedTheme(); |
|
471 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { |
542 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { |
472 const result = []; |
543 const result = []; |
473 if (canCreateTemplate && isBlockBasedTheme) { |
544 if (canCreateTemplate && isBlockBasedTheme) { |
474 result.push({ |
545 result.push({ |
475 name: 'core/edit-site/open-navigation', |
546 name: 'core/edit-site/open-navigation', |
476 label: (0,external_wp_i18n_namespaceObject.__)('Navigation'), |
547 label: (0,external_wp_i18n_namespaceObject.__)('Navigation'), |
477 icon: library_navigation, |
548 icon: library_navigation, |
478 callback: ({ |
549 callback: ({ |
479 close |
550 close |
480 }) => { |
551 }) => { |
481 const args = { |
552 if (isSiteEditor) { |
482 postType: 'wp_navigation' |
553 history.navigate('/navigation'); |
483 }; |
554 } else { |
484 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args); |
555 document.location = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', { |
485 if (isSiteEditor) { |
556 p: '/navigation' |
486 history.push(args); |
557 }); |
487 } else { |
|
488 document.location = targetUrl; |
|
489 } |
558 } |
490 close(); |
559 close(); |
491 } |
560 } |
492 }); |
561 }); |
493 result.push({ |
562 result.push({ |
576 }, [history, isSiteEditor, canCreateTemplate, isBlockBasedTheme]); |
637 }, [history, isSiteEditor, canCreateTemplate, isBlockBasedTheme]); |
577 return { |
638 return { |
578 commands, |
639 commands, |
579 isLoading: false |
640 isLoading: false |
580 }; |
641 }; |
581 } |
642 }; |
582 function useSiteEditorNavigationCommands() { |
643 function useSiteEditorNavigationCommands() { |
583 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
644 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
584 name: 'core/edit-site/navigate-pages', |
645 name: 'core/edit-site/navigate-pages', |
585 hook: usePageNavigationCommandLoader |
646 hook: getNavigationCommandLoaderPerPostType('page') |
586 }); |
647 }); |
587 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
648 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
588 name: 'core/edit-site/navigate-posts', |
649 name: 'core/edit-site/navigate-posts', |
589 hook: usePostNavigationCommandLoader |
650 hook: getNavigationCommandLoaderPerPostType('post') |
590 }); |
651 }); |
591 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
652 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
592 name: 'core/edit-site/navigate-templates', |
653 name: 'core/edit-site/navigate-templates', |
593 hook: useTemplateNavigationCommandLoader |
654 hook: getNavigationCommandLoaderPerTemplate('wp_template') |
594 }); |
655 }); |
595 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
656 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
596 name: 'core/edit-site/navigate-template-parts', |
657 name: 'core/edit-site/navigate-template-parts', |
597 hook: useTemplatePartNavigationCommandLoader |
658 hook: getNavigationCommandLoaderPerTemplate('wp_template_part') |
598 }); |
659 }); |
599 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
660 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
600 name: 'core/edit-site/basic-navigation', |
661 name: 'core/edit-site/basic-navigation', |
601 hook: useSiteEditorBasicNavigationCommands, |
662 hook: getSiteEditorBasicNavigationCommands(), |
602 context: 'site-editor' |
663 context: 'site-editor' |
603 }); |
664 }); |
604 } |
665 } |
605 |
666 |
606 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/private-apis.js |
667 ;// ./node_modules/@wordpress/core-commands/build-module/private-apis.js |
607 /** |
668 /** |
608 * Internal dependencies |
669 * Internal dependencies |
609 */ |
670 */ |
610 |
671 |
611 |
672 |