|
1 /******/ (() => { // webpackBootstrap |
|
2 /******/ "use strict"; |
|
3 /******/ // The require scope |
|
4 /******/ var __webpack_require__ = {}; |
|
5 /******/ |
|
6 /************************************************************************/ |
|
7 /******/ /* webpack/runtime/define property getters */ |
|
8 /******/ (() => { |
|
9 /******/ // define getter functions for harmony exports |
|
10 /******/ __webpack_require__.d = (exports, definition) => { |
|
11 /******/ for(var key in definition) { |
|
12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
|
13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
|
14 /******/ } |
|
15 /******/ } |
|
16 /******/ }; |
|
17 /******/ })(); |
|
18 /******/ |
|
19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
|
20 /******/ (() => { |
|
21 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
|
22 /******/ })(); |
|
23 /******/ |
|
24 /******/ /* webpack/runtime/make namespace object */ |
|
25 /******/ (() => { |
|
26 /******/ // define __esModule on exports |
|
27 /******/ __webpack_require__.r = (exports) => { |
|
28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
30 /******/ } |
|
31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
32 /******/ }; |
|
33 /******/ })(); |
|
34 /******/ |
|
35 /************************************************************************/ |
|
36 var __webpack_exports__ = {}; |
|
37 // ESM COMPAT FLAG |
|
38 __webpack_require__.r(__webpack_exports__); |
|
39 |
|
40 // EXPORTS |
|
41 __webpack_require__.d(__webpack_exports__, { |
|
42 privateApis: () => (/* reexport */ privateApis) |
|
43 }); |
|
44 |
|
45 ;// CONCATENATED MODULE: external ["wp","commands"] |
|
46 const external_wp_commands_namespaceObject = window["wp"]["commands"]; |
|
47 ;// CONCATENATED MODULE: external ["wp","i18n"] |
|
48 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
|
49 ;// CONCATENATED MODULE: external ["wp","primitives"] |
|
50 const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; |
|
51 ;// CONCATENATED MODULE: external "ReactJSXRuntime" |
|
52 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; |
|
53 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plus.js |
|
54 /** |
|
55 * WordPress dependencies |
|
56 */ |
|
57 |
|
58 |
|
59 const plus = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
|
60 xmlns: "http://www.w3.org/2000/svg", |
|
61 viewBox: "0 0 24 24", |
|
62 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
|
63 d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" |
|
64 }) |
|
65 }); |
|
66 /* harmony default export */ const library_plus = (plus); |
|
67 |
|
68 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/admin-navigation-commands.js |
|
69 /** |
|
70 * WordPress dependencies |
|
71 */ |
|
72 |
|
73 |
|
74 |
|
75 function useAdminNavigationCommands() { |
|
76 (0,external_wp_commands_namespaceObject.useCommand)({ |
|
77 name: 'core/add-new-post', |
|
78 label: (0,external_wp_i18n_namespaceObject.__)('Add new post'), |
|
79 icon: library_plus, |
|
80 callback: () => { |
|
81 document.location.href = 'post-new.php'; |
|
82 } |
|
83 }); |
|
84 (0,external_wp_commands_namespaceObject.useCommand)({ |
|
85 name: 'core/add-new-page', |
|
86 label: (0,external_wp_i18n_namespaceObject.__)('Add new page'), |
|
87 icon: library_plus, |
|
88 callback: () => { |
|
89 document.location.href = 'post-new.php?post_type=page'; |
|
90 } |
|
91 }); |
|
92 } |
|
93 |
|
94 ;// CONCATENATED MODULE: external ["wp","element"] |
|
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 /** |
|
102 * WordPress dependencies |
|
103 */ |
|
104 |
|
105 |
|
106 const post = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
|
107 xmlns: "http://www.w3.org/2000/svg", |
|
108 viewBox: "0 0 24 24", |
|
109 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
|
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" |
|
111 }) |
|
112 }); |
|
113 /* harmony default export */ const library_post = (post); |
|
114 |
|
115 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/page.js |
|
116 /** |
|
117 * WordPress dependencies |
|
118 */ |
|
119 |
|
120 |
|
121 |
|
122 const page = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, { |
|
123 xmlns: "http://www.w3.org/2000/svg", |
|
124 viewBox: "0 0 24 24", |
|
125 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
|
126 d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z" |
|
127 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
|
128 d: "M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z" |
|
129 })] |
|
130 }); |
|
131 /* harmony default export */ const library_page = (page); |
|
132 |
|
133 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/layout.js |
|
134 /** |
|
135 * WordPress dependencies |
|
136 */ |
|
137 |
|
138 |
|
139 const layout = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
|
140 xmlns: "http://www.w3.org/2000/svg", |
|
141 viewBox: "0 0 24 24", |
|
142 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
|
143 d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" |
|
144 }) |
|
145 }); |
|
146 /* harmony default export */ const library_layout = (layout); |
|
147 |
|
148 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol-filled.js |
|
149 /** |
|
150 * WordPress dependencies |
|
151 */ |
|
152 |
|
153 |
|
154 const symbolFilled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
|
155 xmlns: "http://www.w3.org/2000/svg", |
|
156 viewBox: "0 0 24 24", |
|
157 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
|
158 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-17.6 1L10 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" |
|
159 }) |
|
160 }); |
|
161 /* harmony default export */ const symbol_filled = (symbolFilled); |
|
162 |
|
163 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/navigation.js |
|
164 /** |
|
165 * WordPress dependencies |
|
166 */ |
|
167 |
|
168 |
|
169 const navigation = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
|
170 viewBox: "0 0 24 24", |
|
171 xmlns: "http://www.w3.org/2000/svg", |
|
172 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
|
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" |
|
174 }) |
|
175 }); |
|
176 /* harmony default export */ const library_navigation = (navigation); |
|
177 |
|
178 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/styles.js |
|
179 /** |
|
180 * WordPress dependencies |
|
181 */ |
|
182 |
|
183 |
|
184 const styles = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
|
185 viewBox: "0 0 24 24", |
|
186 xmlns: "http://www.w3.org/2000/svg", |
|
187 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" |
|
189 }) |
|
190 }); |
|
191 /* harmony default export */ const library_styles = (styles); |
|
192 |
|
193 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js |
|
194 /** |
|
195 * WordPress dependencies |
|
196 */ |
|
197 |
|
198 |
|
199 const symbol = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
|
200 xmlns: "http://www.w3.org/2000/svg", |
|
201 viewBox: "0 0 24 24", |
|
202 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
|
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" |
|
204 }) |
|
205 }); |
|
206 /* harmony default export */ const library_symbol = (symbol); |
|
207 |
|
208 ;// CONCATENATED MODULE: external ["wp","router"] |
|
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"]; |
|
214 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/hooks.js |
|
215 /** |
|
216 * WordPress dependencies |
|
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 = '') { |
|
238 if (!Array.isArray(records) || !records.length) { |
|
239 return []; |
|
240 } |
|
241 if (!search) { |
|
242 return records; |
|
243 } |
|
244 const priority = []; |
|
245 const nonPriority = []; |
|
246 for (let i = 0; i < records.length; i++) { |
|
247 const record = records[i]; |
|
248 if (record?.title?.raw?.toLowerCase()?.includes(search?.toLowerCase())) { |
|
249 priority.push(record); |
|
250 } else { |
|
251 nonPriority.push(record); |
|
252 } |
|
253 } |
|
254 return priority.concat(nonPriority); |
|
255 } |
|
256 |
|
257 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/site-editor-navigation-commands.js |
|
258 /** |
|
259 * WordPress dependencies |
|
260 */ |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 /** |
|
272 * Internal dependencies |
|
273 */ |
|
274 |
|
275 |
|
276 |
|
277 const { |
|
278 useHistory |
|
279 } = unlock(external_wp_router_namespaceObject.privateApis); |
|
280 const icons = { |
|
281 post: library_post, |
|
282 page: library_page, |
|
283 wp_template: library_layout, |
|
284 wp_template_part: symbol_filled |
|
285 }; |
|
286 function useDebouncedValue(value) { |
|
287 const [debouncedValue, setDebouncedValue] = (0,external_wp_element_namespaceObject.useState)(''); |
|
288 const debounced = (0,external_wp_compose_namespaceObject.useDebounce)(setDebouncedValue, 250); |
|
289 (0,external_wp_element_namespaceObject.useEffect)(() => { |
|
290 debounced(value); |
|
291 return () => debounced.cancel(); |
|
292 }, [debounced, value]); |
|
293 return debouncedValue; |
|
294 } |
|
295 const getNavigationCommandLoaderPerPostType = postType => function useNavigationCommandLoader({ |
|
296 search |
|
297 }) { |
|
298 const history = useHistory(); |
|
299 const isBlockBasedTheme = useIsBlockBasedTheme(); |
|
300 const delayedSearch = useDebouncedValue(search); |
|
301 const { |
|
302 records, |
|
303 isLoading |
|
304 } = (0,external_wp_data_namespaceObject.useSelect)(select => { |
|
305 if (!delayedSearch) { |
|
306 return { |
|
307 isLoading: false |
|
308 }; |
|
309 } |
|
310 const query = { |
|
311 search: delayedSearch, |
|
312 per_page: 10, |
|
313 orderby: 'relevance', |
|
314 status: ['publish', 'future', 'draft', 'pending', 'private'] |
|
315 }; |
|
316 return { |
|
317 records: select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', postType, query), |
|
318 isLoading: !select(external_wp_coreData_namespaceObject.store).hasFinishedResolution('getEntityRecords', ['postType', postType, query]) |
|
319 }; |
|
320 }, [delayedSearch]); |
|
321 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { |
|
322 return (records !== null && records !== void 0 ? records : []).map(record => { |
|
323 const command = { |
|
324 name: postType + '-' + record.id, |
|
325 searchLabel: record.title?.rendered + ' ' + record.id, |
|
326 label: record.title?.rendered ? record.title?.rendered : (0,external_wp_i18n_namespaceObject.__)('(no title)'), |
|
327 icon: icons[postType] |
|
328 }; |
|
329 if (postType === 'post' || postType === 'page' && !isBlockBasedTheme) { |
|
330 return { |
|
331 ...command, |
|
332 callback: ({ |
|
333 close |
|
334 }) => { |
|
335 const args = { |
|
336 post: record.id, |
|
337 action: 'edit' |
|
338 }; |
|
339 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('post.php', args); |
|
340 document.location = targetUrl; |
|
341 close(); |
|
342 } |
|
343 }; |
|
344 } |
|
345 const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php'); |
|
346 return { |
|
347 ...command, |
|
348 callback: ({ |
|
349 close |
|
350 }) => { |
|
351 const args = { |
|
352 postType, |
|
353 postId: record.id, |
|
354 canvas: 'edit' |
|
355 }; |
|
356 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args); |
|
357 if (isSiteEditor) { |
|
358 history.push(args); |
|
359 } else { |
|
360 document.location = targetUrl; |
|
361 } |
|
362 close(); |
|
363 } |
|
364 }; |
|
365 }); |
|
366 }, [records, isBlockBasedTheme, history]); |
|
367 return { |
|
368 commands, |
|
369 isLoading |
|
370 }; |
|
371 }; |
|
372 const getNavigationCommandLoaderPerTemplate = templateType => function useNavigationCommandLoader({ |
|
373 search |
|
374 }) { |
|
375 const history = useHistory(); |
|
376 const isBlockBasedTheme = useIsBlockBasedTheme(); |
|
377 const { |
|
378 records, |
|
379 isLoading |
|
380 } = (0,external_wp_data_namespaceObject.useSelect)(select => { |
|
381 const { |
|
382 getEntityRecords |
|
383 } = select(external_wp_coreData_namespaceObject.store); |
|
384 const query = { |
|
385 per_page: -1 |
|
386 }; |
|
387 return { |
|
388 records: getEntityRecords('postType', templateType, query), |
|
389 isLoading: !select(external_wp_coreData_namespaceObject.store).hasFinishedResolution('getEntityRecords', ['postType', templateType, query]) |
|
390 }; |
|
391 }, []); |
|
392 |
|
393 /* |
|
394 * wp_template and wp_template_part endpoints do not support per_page or orderby parameters. |
|
395 * We need to sort the results based on the search query to avoid removing relevant |
|
396 * records below using .slice(). |
|
397 */ |
|
398 const orderedRecords = (0,external_wp_element_namespaceObject.useMemo)(() => { |
|
399 return orderEntityRecordsBySearch(records, search).slice(0, 10); |
|
400 }, [records, search]); |
|
401 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { |
|
402 if (!isBlockBasedTheme && !templateType === 'wp_template_part') { |
|
403 return []; |
|
404 } |
|
405 const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php'); |
|
406 const result = []; |
|
407 result.push(...orderedRecords.map(record => { |
|
408 return { |
|
409 name: templateType + '-' + record.id, |
|
410 searchLabel: record.title?.rendered + ' ' + record.id, |
|
411 label: record.title?.rendered ? record.title?.rendered : (0,external_wp_i18n_namespaceObject.__)('(no title)'), |
|
412 icon: icons[templateType], |
|
413 callback: ({ |
|
414 close |
|
415 }) => { |
|
416 const args = { |
|
417 postType: templateType, |
|
418 postId: record.id, |
|
419 canvas: 'edit' |
|
420 }; |
|
421 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args); |
|
422 if (isSiteEditor) { |
|
423 history.push(args); |
|
424 } else { |
|
425 document.location = targetUrl; |
|
426 } |
|
427 close(); |
|
428 } |
|
429 }; |
|
430 })); |
|
431 if (orderedRecords?.length > 0 && templateType === 'wp_template_part') { |
|
432 result.push({ |
|
433 name: 'core/edit-site/open-template-parts', |
|
434 label: (0,external_wp_i18n_namespaceObject.__)('Template parts'), |
|
435 icon: symbol_filled, |
|
436 callback: ({ |
|
437 close |
|
438 }) => { |
|
439 const args = { |
|
440 postType: 'wp_template_part', |
|
441 categoryId: 'all-parts' |
|
442 }; |
|
443 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args); |
|
444 if (isSiteEditor) { |
|
445 history.push(args); |
|
446 } else { |
|
447 document.location = targetUrl; |
|
448 } |
|
449 close(); |
|
450 } |
|
451 }); |
|
452 } |
|
453 return result; |
|
454 }, [isBlockBasedTheme, orderedRecords, history]); |
|
455 return { |
|
456 commands, |
|
457 isLoading |
|
458 }; |
|
459 }; |
|
460 const usePageNavigationCommandLoader = getNavigationCommandLoaderPerPostType('page'); |
|
461 const usePostNavigationCommandLoader = getNavigationCommandLoaderPerPostType('post'); |
|
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'); |
|
467 const canCreateTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => { |
|
468 return select(external_wp_coreData_namespaceObject.store).canUser('create', 'templates'); |
|
469 }, []); |
|
470 const isBlockBasedTheme = useIsBlockBasedTheme(); |
|
471 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { |
|
472 const result = []; |
|
473 if (canCreateTemplate && isBlockBasedTheme) { |
|
474 result.push({ |
|
475 name: 'core/edit-site/open-navigation', |
|
476 label: (0,external_wp_i18n_namespaceObject.__)('Navigation'), |
|
477 icon: library_navigation, |
|
478 callback: ({ |
|
479 close |
|
480 }) => { |
|
481 const args = { |
|
482 postType: 'wp_navigation' |
|
483 }; |
|
484 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args); |
|
485 if (isSiteEditor) { |
|
486 history.push(args); |
|
487 } else { |
|
488 document.location = targetUrl; |
|
489 } |
|
490 close(); |
|
491 } |
|
492 }); |
|
493 result.push({ |
|
494 name: 'core/edit-site/open-styles', |
|
495 label: (0,external_wp_i18n_namespaceObject.__)('Styles'), |
|
496 icon: library_styles, |
|
497 callback: ({ |
|
498 close |
|
499 }) => { |
|
500 const args = { |
|
501 path: '/wp_global_styles' |
|
502 }; |
|
503 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args); |
|
504 if (isSiteEditor) { |
|
505 history.push(args); |
|
506 } else { |
|
507 document.location = targetUrl; |
|
508 } |
|
509 close(); |
|
510 } |
|
511 }); |
|
512 result.push({ |
|
513 name: 'core/edit-site/open-pages', |
|
514 label: (0,external_wp_i18n_namespaceObject.__)('Pages'), |
|
515 icon: library_page, |
|
516 callback: ({ |
|
517 close |
|
518 }) => { |
|
519 const args = { |
|
520 postType: 'page' |
|
521 }; |
|
522 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args); |
|
523 if (isSiteEditor) { |
|
524 history.push(args); |
|
525 } else { |
|
526 document.location = targetUrl; |
|
527 } |
|
528 close(); |
|
529 } |
|
530 }); |
|
531 result.push({ |
|
532 name: 'core/edit-site/open-templates', |
|
533 label: (0,external_wp_i18n_namespaceObject.__)('Templates'), |
|
534 icon: library_layout, |
|
535 callback: ({ |
|
536 close |
|
537 }) => { |
|
538 const args = { |
|
539 postType: 'wp_template' |
|
540 }; |
|
541 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args); |
|
542 if (isSiteEditor) { |
|
543 history.push(args); |
|
544 } else { |
|
545 document.location = targetUrl; |
|
546 } |
|
547 close(); |
|
548 } |
|
549 }); |
|
550 } |
|
551 result.push({ |
|
552 name: 'core/edit-site/open-patterns', |
|
553 label: (0,external_wp_i18n_namespaceObject.__)('Patterns'), |
|
554 icon: library_symbol, |
|
555 callback: ({ |
|
556 close |
|
557 }) => { |
|
558 if (canCreateTemplate) { |
|
559 const args = { |
|
560 postType: 'wp_block' |
|
561 }; |
|
562 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args); |
|
563 if (isSiteEditor) { |
|
564 history.push(args); |
|
565 } else { |
|
566 document.location = targetUrl; |
|
567 } |
|
568 close(); |
|
569 } else { |
|
570 // If a user cannot access the site editor |
|
571 document.location.href = 'edit.php?post_type=wp_block'; |
|
572 } |
|
573 } |
|
574 }); |
|
575 return result; |
|
576 }, [history, isSiteEditor, canCreateTemplate, isBlockBasedTheme]); |
|
577 return { |
|
578 commands, |
|
579 isLoading: false |
|
580 }; |
|
581 } |
|
582 function useSiteEditorNavigationCommands() { |
|
583 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
|
584 name: 'core/edit-site/navigate-pages', |
|
585 hook: usePageNavigationCommandLoader |
|
586 }); |
|
587 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
|
588 name: 'core/edit-site/navigate-posts', |
|
589 hook: usePostNavigationCommandLoader |
|
590 }); |
|
591 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
|
592 name: 'core/edit-site/navigate-templates', |
|
593 hook: useTemplateNavigationCommandLoader |
|
594 }); |
|
595 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
|
596 name: 'core/edit-site/navigate-template-parts', |
|
597 hook: useTemplatePartNavigationCommandLoader |
|
598 }); |
|
599 (0,external_wp_commands_namespaceObject.useCommandLoader)({ |
|
600 name: 'core/edit-site/basic-navigation', |
|
601 hook: useSiteEditorBasicNavigationCommands, |
|
602 context: 'site-editor' |
|
603 }); |
|
604 } |
|
605 |
|
606 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/private-apis.js |
|
607 /** |
|
608 * Internal dependencies |
|
609 */ |
|
610 |
|
611 |
|
612 |
|
613 function useCommands() { |
|
614 useAdminNavigationCommands(); |
|
615 useSiteEditorNavigationCommands(); |
|
616 } |
|
617 const privateApis = {}; |
|
618 lock(privateApis, { |
|
619 useCommands |
|
620 }); |
|
621 |
|
622 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-commands/build-module/index.js |
|
623 |
|
624 |
|
625 (window.wp = window.wp || {}).coreCommands = __webpack_exports__; |
|
626 /******/ })() |
|
627 ; |