| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 var wp; 2 (wp ||= {}).coreCommands = (() => { 3 var __create = Object.create; 4 var __defProp = Object.defineProperty; 5 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 6 var __getOwnPropNames = Object.getOwnPropertyNames; 7 var __getProtoOf = Object.getPrototypeOf; 8 var __hasOwnProp = Object.prototype.hasOwnProperty; 9 var __commonJS = (cb, mod) => function __require() { 10 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 11 }; 12 var __export = (target, all) => { 13 for (var name in all) 14 __defProp(target, name, { get: all[name], enumerable: true }); 15 }; 16 var __copyProps = (to, from, except, desc) => { 17 if (from && typeof from === "object" || typeof from === "function") { 18 for (let key of __getOwnPropNames(from)) 19 if (!__hasOwnProp.call(to, key) && key !== except) 20 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 21 } 22 return to; 23 }; 24 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 25 // If the importer is in node compatibility mode or this is not an ESM 26 // file that has been converted to a CommonJS file using a Babel- 27 // compatible transform (i.e. "__esModule" has not been set), then set 28 // "default" to the CommonJS "module.exports" for node compatibility. 29 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 30 mod 31 )); 32 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); 33 34 // package-external:@wordpress/element 35 var require_element = __commonJS({ 36 "package-external:@wordpress/element"(exports, module) { 37 module.exports = window.wp.element; 38 } 39 }); 40 41 // package-external:@wordpress/router 42 var require_router = __commonJS({ 43 "package-external:@wordpress/router"(exports, module) { 44 module.exports = window.wp.router; 45 } 46 }); 47 48 // package-external:@wordpress/commands 49 var require_commands = __commonJS({ 50 "package-external:@wordpress/commands"(exports, module) { 51 module.exports = window.wp.commands; 52 } 53 }); 54 55 // package-external:@wordpress/i18n 56 var require_i18n = __commonJS({ 57 "package-external:@wordpress/i18n"(exports, module) { 58 module.exports = window.wp.i18n; 59 } 60 }); 61 62 // package-external:@wordpress/primitives 63 var require_primitives = __commonJS({ 64 "package-external:@wordpress/primitives"(exports, module) { 65 module.exports = window.wp.primitives; 66 } 67 }); 68 69 // vendor-external:react/jsx-runtime 70 var require_jsx_runtime = __commonJS({ 71 "vendor-external:react/jsx-runtime"(exports, module) { 72 module.exports = window.ReactJSXRuntime; 73 } 74 }); 75 76 // package-external:@wordpress/core-data 77 var require_core_data = __commonJS({ 78 "package-external:@wordpress/core-data"(exports, module) { 79 module.exports = window.wp.coreData; 80 } 81 }); 82 83 // package-external:@wordpress/data 84 var require_data = __commonJS({ 85 "package-external:@wordpress/data"(exports, module) { 86 module.exports = window.wp.data; 87 } 88 }); 89 90 // package-external:@wordpress/url 91 var require_url = __commonJS({ 92 "package-external:@wordpress/url"(exports, module) { 93 module.exports = window.wp.url; 94 } 95 }); 96 97 // package-external:@wordpress/compose 98 var require_compose = __commonJS({ 99 "package-external:@wordpress/compose"(exports, module) { 100 module.exports = window.wp.compose; 101 } 102 }); 103 104 // package-external:@wordpress/html-entities 105 var require_html_entities = __commonJS({ 106 "package-external:@wordpress/html-entities"(exports, module) { 107 module.exports = window.wp.htmlEntities; 108 } 109 }); 110 111 // package-external:@wordpress/private-apis 112 var require_private_apis = __commonJS({ 113 "package-external:@wordpress/private-apis"(exports, module) { 114 module.exports = window.wp.privateApis; 115 } 116 }); 117 118 // packages/core-commands/build-module/index.mjs 119 var index_exports = {}; 120 __export(index_exports, { 121 initializeCommandPalette: () => initializeCommandPalette, 122 privateApis: () => privateApis 123 }); 124 var import_element3 = __toESM(require_element(), 1); 125 var import_router2 = __toESM(require_router(), 1); 126 var import_commands3 = __toESM(require_commands(), 1); 127 128 // packages/core-commands/build-module/admin-navigation-commands.mjs 129 var import_commands = __toESM(require_commands(), 1); 130 var import_i18n = __toESM(require_i18n(), 1); 131 132 // packages/icons/build-module/library/brush.mjs 133 var import_primitives = __toESM(require_primitives(), 1); 134 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); 135 var brush_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "M4 20h8v-1.5H4V20zM18.9 3.5c-.6-.6-1.5-.6-2.1 0l-7.2 7.2c-.4-.1-.7 0-1.1.1-.5.2-1.5.7-1.9 2.2-.4 1.7-.8 2.2-1.1 2.7-.1.1-.2.3-.3.4l-.6 1.1H6c2 0 3.4-.4 4.7-1.4.8-.6 1.2-1.4 1.3-2.3 0-.3 0-.5-.1-.7L19 5.7c.5-.6.5-1.6-.1-2.2zM9.7 14.7c-.7.5-1.5.8-2.4 1 .2-.5.5-1.2.8-2.3.2-.6.4-1 .8-1.1.5-.1 1 .1 1.3.3.2.2.3.5.2.8 0 .3-.1.9-.7 1.3z" }) }); 136 137 // packages/icons/build-module/library/external.mjs 138 var import_primitives2 = __toESM(require_primitives(), 1); 139 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); 140 var external_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { d: "M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z" }) }); 141 142 // packages/icons/build-module/library/layout.mjs 143 var import_primitives3 = __toESM(require_primitives(), 1); 144 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); 145 var layout_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.Path, { 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" }) }); 146 147 // packages/icons/build-module/library/navigation.mjs 148 var import_primitives4 = __toESM(require_primitives(), 1); 149 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1); 150 var navigation_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { 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" }) }); 151 152 // packages/icons/build-module/library/page.mjs 153 var import_primitives5 = __toESM(require_primitives(), 1); 154 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1); 155 var page_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 156 /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z" }), 157 /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { 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" }) 158 ] }); 159 160 // packages/icons/build-module/library/post.mjs 161 var import_primitives6 = __toESM(require_primitives(), 1); 162 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1); 163 var post_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { 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" }) }); 164 165 // packages/icons/build-module/library/styles.mjs 166 var import_primitives7 = __toESM(require_primitives(), 1); 167 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1); 168 var styles_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.Path, { 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" }) }); 169 170 // packages/icons/build-module/library/symbol-filled.mjs 171 var import_primitives8 = __toESM(require_primitives(), 1); 172 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1); 173 var symbol_filled_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { 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" }) }); 174 175 // packages/icons/build-module/library/symbol.mjs 176 var import_primitives9 = __toESM(require_primitives(), 1); 177 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1); 178 var symbol_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { 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" }) }); 179 180 // packages/core-commands/build-module/admin-navigation-commands.mjs 181 var import_element = __toESM(require_element(), 1); 182 var import_core_data = __toESM(require_core_data(), 1); 183 var import_data = __toESM(require_data(), 1); 184 var getViewSiteCommand = () => function useViewSiteCommand() { 185 const homeUrl = (0, import_data.useSelect)((select) => { 186 return select(import_core_data.store).getEntityRecord( 187 "root", 188 "__unstableBase" 189 )?.home; 190 }, []); 191 const commands = (0, import_element.useMemo)(() => { 192 if (!homeUrl) { 193 return []; 194 } 195 return [ 196 { 197 name: "core/view-site", 198 label: (0, import_i18n.__)("View site"), 199 icon: external_default, 200 category: "view", 201 callback: ({ close }) => { 202 close(); 203 window.open(homeUrl, "_blank"); 204 } 205 } 206 ]; 207 }, [homeUrl]); 208 return { 209 isLoading: false, 210 commands 211 }; 212 }; 213 function useAdminNavigationCommands(menuCommands) { 214 const commands = (0, import_element.useMemo)(() => { 215 return (menuCommands ?? []).map((menuCommand) => { 216 const label = (0, import_i18n.sprintf)( 217 /* translators: %s: menu label */ 218 (0, import_i18n.__)("Go to: %s"), 219 menuCommand.label 220 ); 221 return { 222 name: menuCommand.name, 223 label, 224 searchLabel: label, 225 category: "view", 226 callback: ({ close }) => { 227 document.location = menuCommand.url; 228 close(); 229 } 230 }; 231 }); 232 }, [menuCommands]); 233 (0, import_commands.useCommands)(commands); 234 (0, import_commands.useCommandLoader)({ 235 name: "core/view-site", 236 hook: getViewSiteCommand() 237 }); 238 } 239 240 // packages/core-commands/build-module/site-editor-navigation-commands.mjs 241 var import_commands2 = __toESM(require_commands(), 1); 242 var import_i18n2 = __toESM(require_i18n(), 1); 243 var import_element2 = __toESM(require_element(), 1); 244 var import_data2 = __toESM(require_data(), 1); 245 var import_core_data2 = __toESM(require_core_data(), 1); 246 var import_router = __toESM(require_router(), 1); 247 var import_url = __toESM(require_url(), 1); 248 var import_compose = __toESM(require_compose(), 1); 249 var import_html_entities = __toESM(require_html_entities(), 1); 250 251 // packages/core-commands/build-module/lock-unlock.mjs 252 var import_private_apis = __toESM(require_private_apis(), 1); 253 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 254 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 255 "@wordpress/core-commands" 256 ); 257 258 // packages/core-commands/build-module/utils/order-entity-records-by-search.mjs 259 function orderEntityRecordsBySearch(records = [], search = "") { 260 if (!Array.isArray(records) || !records.length) { 261 return []; 262 } 263 if (!search) { 264 return records; 265 } 266 const priority = []; 267 const nonPriority = []; 268 for (let i = 0; i < records.length; i++) { 269 const record = records[i]; 270 if (record?.title?.raw?.toLowerCase()?.includes(search?.toLowerCase())) { 271 priority.push(record); 272 } else { 273 nonPriority.push(record); 274 } 275 } 276 return priority.concat(nonPriority); 277 } 278 279 // packages/core-commands/build-module/site-editor-navigation-commands.mjs 280 var { useHistory } = unlock(import_router.privateApis); 281 var icons = { 282 post: post_default, 283 page: page_default, 284 wp_template: layout_default, 285 wp_template_part: symbol_filled_default 286 }; 287 function useDebouncedValue(value) { 288 const [debouncedValue, setDebouncedValue] = (0, import_element2.useState)(""); 289 const debounced = (0, import_compose.useDebounce)(setDebouncedValue, 250); 290 (0, import_element2.useEffect)(() => { 291 debounced(value); 292 return () => debounced.cancel(); 293 }, [debounced, value]); 294 return debouncedValue; 295 } 296 var ROUTE_MAPPING = { 297 "/template": "/templates", 298 "/pattern": "/patterns" 299 }; 300 function getSiteEditorPage() { 301 return window.__experimentalExtensibleSiteEditor ? "admin.php?page=site-editor-v2" : "site-editor.php"; 302 } 303 function mapRoute(path) { 304 if (!window.__experimentalExtensibleSiteEditor) { 305 return path; 306 } 307 for (const [oldPath, newPath] of Object.entries(ROUTE_MAPPING)) { 308 if (path === oldPath || path.startsWith(oldPath + "?")) { 309 if (path.includes("postType=wp_template_part")) { 310 return "/template-parts"; 311 } 312 return path.replace(oldPath, newPath); 313 } 314 } 315 return path; 316 } 317 function isInSiteEditor() { 318 const path = (0, import_url.getPath)(window.location.href); 319 return path?.includes("site-editor.php") || path?.includes("page=site-editor-v2"); 320 } 321 var getNavigationCommandLoaderPerPostType = (postType) => function useNavigationCommandLoader({ search }) { 322 const history = useHistory(); 323 const { isBlockBasedTheme, canCreateTemplate } = (0, import_data2.useSelect)( 324 (select) => { 325 return { 326 isBlockBasedTheme: select(import_core_data2.store).getCurrentTheme()?.is_block_theme, 327 canCreateTemplate: select(import_core_data2.store).canUser("create", { 328 kind: "postType", 329 name: "wp_template" 330 }) 331 }; 332 }, 333 [] 334 ); 335 const delayedSearch = useDebouncedValue(search); 336 const { records, isLoading } = (0, import_data2.useSelect)( 337 (select) => { 338 if (!delayedSearch) { 339 return { 340 isLoading: false 341 }; 342 } 343 const query = { 344 search: delayedSearch, 345 per_page: 10, 346 orderby: "relevance", 347 status: [ 348 "publish", 349 "future", 350 "draft", 351 "pending", 352 "private" 353 ] 354 }; 355 return { 356 records: select(import_core_data2.store).getEntityRecords( 357 "postType", 358 postType, 359 query 360 ), 361 isLoading: !select(import_core_data2.store).hasFinishedResolution( 362 "getEntityRecords", 363 ["postType", postType, query] 364 ) 365 }; 366 }, 367 [delayedSearch] 368 ); 369 const commands = (0, import_element2.useMemo)(() => { 370 return (records ?? []).map((record) => { 371 const command = { 372 name: postType + "-" + record.id, 373 searchLabel: record.title?.rendered + " " + record.id, 374 label: record.title?.rendered ? (0, import_html_entities.decodeEntities)(record.title?.rendered) : (0, import_i18n2.__)("(no title)"), 375 icon: icons[postType], 376 category: "edit" 377 }; 378 if (!canCreateTemplate || postType === "post" || postType === "page" && !isBlockBasedTheme) { 379 return { 380 ...command, 381 callback: ({ close }) => { 382 const args = { 383 post: record.id, 384 action: "edit" 385 }; 386 const targetUrl = (0, import_url.addQueryArgs)("post.php", args); 387 document.location = targetUrl; 388 close(); 389 } 390 }; 391 } 392 const isSiteEditor = isInSiteEditor(); 393 return { 394 ...command, 395 callback: ({ close }) => { 396 if (isSiteEditor) { 397 history.navigate( 398 `/$postType}/$record.id}?canvas=edit` 399 ); 400 } else { 401 document.location = (0, import_url.addQueryArgs)( 402 getSiteEditorPage(), 403 { 404 p: `/$postType}/$record.id}`, 405 canvas: "edit" 406 } 407 ); 408 } 409 close(); 410 } 411 }; 412 }); 413 }, [canCreateTemplate, records, isBlockBasedTheme, history]); 414 return { 415 commands, 416 isLoading 417 }; 418 }; 419 var getNavigationCommandLoaderPerTemplate = (templateType) => function useNavigationCommandLoader({ search }) { 420 const history = useHistory(); 421 const { isBlockBasedTheme, canCreateTemplate } = (0, import_data2.useSelect)( 422 (select) => { 423 return { 424 isBlockBasedTheme: select(import_core_data2.store).getCurrentTheme()?.is_block_theme, 425 canCreateTemplate: select(import_core_data2.store).canUser("create", { 426 kind: "postType", 427 name: templateType 428 }) 429 }; 430 }, 431 [] 432 ); 433 const { records, isLoading } = (0, import_data2.useSelect)((select) => { 434 const { getEntityRecords } = select(import_core_data2.store); 435 const query = { per_page: -1 }; 436 return { 437 records: getEntityRecords("postType", templateType, query), 438 isLoading: !select(import_core_data2.store).hasFinishedResolution( 439 "getEntityRecords", 440 ["postType", templateType, query] 441 ) 442 }; 443 }, []); 444 const orderedRecords = (0, import_element2.useMemo)(() => { 445 return orderEntityRecordsBySearch(records, search).slice(0, 10); 446 }, [records, search]); 447 const commands = (0, import_element2.useMemo)(() => { 448 if (!canCreateTemplate || !isBlockBasedTheme && !templateType === "wp_template_part") { 449 return []; 450 } 451 const isSiteEditor = (0, import_url.getPath)(window.location.href)?.includes( 452 "site-editor.php" 453 ); 454 const result = []; 455 result.push( 456 ...orderedRecords.map((record) => { 457 return { 458 name: templateType + "-" + record.id, 459 searchLabel: record.title?.rendered + " " + record.id, 460 label: record.title?.rendered ? record.title?.rendered : (0, import_i18n2.__)("(no title)"), 461 icon: icons[templateType], 462 category: "edit", 463 callback: ({ close }) => { 464 if (isSiteEditor) { 465 history.navigate( 466 `/$templateType}/$record.id}?canvas=edit` 467 ); 468 } else { 469 document.location = (0, import_url.addQueryArgs)( 470 getSiteEditorPage(), 471 { 472 p: `/$templateType}/$record.id}`, 473 canvas: "edit" 474 } 475 ); 476 } 477 close(); 478 } 479 }; 480 }) 481 ); 482 if (orderedRecords?.length > 0 && templateType === "wp_template_part") { 483 result.push({ 484 name: "core/edit-site/open-template-parts", 485 label: (0, import_i18n2.__)("Go to: Template parts"), 486 icon: symbol_filled_default, 487 category: "view", 488 callback: ({ close }) => { 489 if (isSiteEditor) { 490 history.navigate( 491 mapRoute( 492 "/pattern?postType=wp_template_part&categoryId=all-parts" 493 ) 494 ); 495 } else { 496 document.location = (0, import_url.addQueryArgs)( 497 getSiteEditorPage(), 498 { 499 p: mapRoute("/pattern"), 500 postType: "wp_template_part", 501 categoryId: "all-parts" 502 } 503 ); 504 } 505 close(); 506 } 507 }); 508 } 509 return result; 510 }, [canCreateTemplate, isBlockBasedTheme, orderedRecords, history]); 511 return { 512 commands, 513 isLoading 514 }; 515 }; 516 var getSiteEditorBasicNavigationCommands = () => function useSiteEditorBasicNavigationCommands() { 517 const history = useHistory(); 518 const isSiteEditor = isInSiteEditor(); 519 const { isBlockBasedTheme, canCreateTemplate, canCreatePatterns } = (0, import_data2.useSelect)((select) => { 520 return { 521 isBlockBasedTheme: select(import_core_data2.store).getCurrentTheme()?.is_block_theme, 522 canCreateTemplate: select(import_core_data2.store).canUser("create", { 523 kind: "postType", 524 name: "wp_template" 525 }), 526 canCreatePatterns: select(import_core_data2.store).canUser("create", { 527 kind: "postType", 528 name: "wp_block" 529 }) 530 }; 531 }, []); 532 const commands = (0, import_element2.useMemo)(() => { 533 const result = []; 534 if (canCreateTemplate && isBlockBasedTheme) { 535 result.push({ 536 name: "core/edit-site/open-styles", 537 label: (0, import_i18n2.__)("Go to: Styles"), 538 icon: styles_default, 539 category: "view", 540 callback: ({ close }) => { 541 if (isSiteEditor) { 542 history.navigate("/styles"); 543 } else { 544 document.location = (0, import_url.addQueryArgs)( 545 getSiteEditorPage(), 546 { 547 p: "/styles" 548 } 549 ); 550 } 551 close(); 552 } 553 }); 554 result.push({ 555 name: "core/edit-site/open-navigation", 556 label: (0, import_i18n2.__)("Go to: Navigation"), 557 icon: navigation_default, 558 category: "view", 559 callback: ({ close }) => { 560 if (isSiteEditor) { 561 history.navigate("/navigation"); 562 } else { 563 document.location = (0, import_url.addQueryArgs)( 564 getSiteEditorPage(), 565 { 566 p: "/navigation" 567 } 568 ); 569 } 570 close(); 571 } 572 }); 573 result.push({ 574 name: "core/edit-site/open-templates", 575 label: (0, import_i18n2.__)("Go to: Templates"), 576 icon: layout_default, 577 category: "view", 578 callback: ({ close }) => { 579 if (isSiteEditor) { 580 history.navigate(mapRoute("/template")); 581 } else { 582 document.location = (0, import_url.addQueryArgs)( 583 getSiteEditorPage(), 584 { 585 p: mapRoute("/template") 586 } 587 ); 588 } 589 close(); 590 } 591 }); 592 } 593 if (canCreatePatterns) { 594 result.push({ 595 name: "core/edit-site/open-patterns", 596 label: (0, import_i18n2.__)("Go to: Patterns"), 597 icon: symbol_default, 598 category: "view", 599 callback: ({ close }) => { 600 if (canCreateTemplate) { 601 if (isSiteEditor) { 602 history.navigate(mapRoute("/pattern")); 603 } else { 604 document.location = (0, import_url.addQueryArgs)( 605 getSiteEditorPage(), 606 { 607 p: mapRoute("/pattern") 608 } 609 ); 610 } 611 close(); 612 } else { 613 document.location.href = "edit.php?post_type=wp_block"; 614 } 615 } 616 }); 617 } 618 return result; 619 }, [ 620 history, 621 isSiteEditor, 622 canCreateTemplate, 623 canCreatePatterns, 624 isBlockBasedTheme 625 ]); 626 return { 627 commands, 628 isLoading: false 629 }; 630 }; 631 var getGlobalStylesOpenCssCommands = () => function useGlobalStylesOpenCssCommands() { 632 const history = useHistory(); 633 const isSiteEditor = isInSiteEditor(); 634 const { canEditCSS } = (0, import_data2.useSelect)((select) => { 635 const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select(import_core_data2.store); 636 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 637 const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0; 638 return { 639 canEditCSS: !!globalStyles?._links?.["wp:action-edit-css"] 640 }; 641 }, []); 642 const commands = (0, import_element2.useMemo)(() => { 643 if (!canEditCSS) { 644 return []; 645 } 646 return [ 647 { 648 name: "core/open-styles-css", 649 label: (0, import_i18n2.__)("Open custom CSS"), 650 icon: brush_default, 651 category: "view", 652 callback: ({ close }) => { 653 close(); 654 if (isSiteEditor) { 655 history.navigate("/styles?section=/css"); 656 } else { 657 document.location = (0, import_url.addQueryArgs)( 658 getSiteEditorPage(), 659 { 660 p: "/styles", 661 section: "/css" 662 } 663 ); 664 } 665 } 666 } 667 ]; 668 }, [history, canEditCSS, isSiteEditor]); 669 return { 670 isLoading: false, 671 commands 672 }; 673 }; 674 function useSiteEditorNavigationCommands(isNetworkAdmin) { 675 (0, import_commands2.useCommandLoader)({ 676 name: "core/edit-site/navigate-pages", 677 hook: getNavigationCommandLoaderPerPostType("page"), 678 disabled: isNetworkAdmin 679 }); 680 (0, import_commands2.useCommandLoader)({ 681 name: "core/edit-site/navigate-posts", 682 hook: getNavigationCommandLoaderPerPostType("post"), 683 disabled: isNetworkAdmin 684 }); 685 (0, import_commands2.useCommandLoader)({ 686 name: "core/edit-site/navigate-templates", 687 hook: getNavigationCommandLoaderPerTemplate("wp_template"), 688 disabled: isNetworkAdmin 689 }); 690 (0, import_commands2.useCommandLoader)({ 691 name: "core/edit-site/navigate-template-parts", 692 hook: getNavigationCommandLoaderPerTemplate("wp_template_part"), 693 disabled: isNetworkAdmin 694 }); 695 (0, import_commands2.useCommandLoader)({ 696 name: "core/edit-site/basic-navigation", 697 hook: getSiteEditorBasicNavigationCommands(), 698 context: "site-editor", 699 disabled: isNetworkAdmin 700 }); 701 (0, import_commands2.useCommandLoader)({ 702 name: "core/edit-site/global-styles-css", 703 hook: getGlobalStylesOpenCssCommands(), 704 disabled: isNetworkAdmin 705 }); 706 } 707 708 // packages/core-commands/build-module/private-apis.mjs 709 function useCommands2() { 710 useAdminNavigationCommands(); 711 useSiteEditorNavigationCommands(); 712 } 713 var privateApis = {}; 714 lock(privateApis, { 715 useCommands: useCommands2 716 }); 717 718 // packages/core-commands/build-module/index.mjs 719 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1); 720 var { RouterProvider } = unlock(import_router2.privateApis); 721 function CommandPalette({ settings }) { 722 const { menu_commands: menuCommands, is_network_admin: isNetworkAdmin } = settings; 723 useAdminNavigationCommands(menuCommands); 724 useSiteEditorNavigationCommands(isNetworkAdmin); 725 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RouterProvider, { pathArg: "p", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_commands3.CommandMenu, {}) }); 726 } 727 function initializeCommandPalette(settings) { 728 const root = document.createElement("div"); 729 document.body.appendChild(root); 730 (0, import_element3.createRoot)(root).render( 731 /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_element3.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CommandPalette, { settings }) }) 732 ); 733 } 734 return __toCommonJS(index_exports); 735 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sat Jun 13 09:38:55 2026 | Cross-referenced by PHPXref |