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