| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 var __create = Object.create; 2 var __defProp = Object.defineProperty; 3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 4 var __getOwnPropNames = Object.getOwnPropertyNames; 5 var __getProtoOf = Object.getPrototypeOf; 6 var __hasOwnProp = Object.prototype.hasOwnProperty; 7 var __commonJS = (cb, mod) => function __require() { 8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 9 }; 10 var __copyProps = (to, from, except, desc) => { 11 if (from && typeof from === "object" || typeof from === "function") { 12 for (let key of __getOwnPropNames(from)) 13 if (!__hasOwnProp.call(to, key) && key !== except) 14 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 15 } 16 return to; 17 }; 18 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 19 // If the importer is in node compatibility mode or this is not an ESM 20 // file that has been converted to a CommonJS file using a Babel- 21 // compatible transform (i.e. "__esModule" has not been set), then set 22 // "default" to the CommonJS "module.exports" for node compatibility. 23 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 24 mod 25 )); 26 27 // package-external:@wordpress/i18n 28 var require_i18n = __commonJS({ 29 "package-external:@wordpress/i18n"(exports, module) { 30 module.exports = window.wp.i18n; 31 } 32 }); 33 34 // package-external:@wordpress/html-entities 35 var require_html_entities = __commonJS({ 36 "package-external:@wordpress/html-entities"(exports, module) { 37 module.exports = window.wp.htmlEntities; 38 } 39 }); 40 41 // package-external:@wordpress/components 42 var require_components = __commonJS({ 43 "package-external:@wordpress/components"(exports, module) { 44 module.exports = window.wp.components; 45 } 46 }); 47 48 // package-external:@wordpress/data 49 var require_data = __commonJS({ 50 "package-external:@wordpress/data"(exports, module) { 51 module.exports = window.wp.data; 52 } 53 }); 54 55 // package-external:@wordpress/core-data 56 var require_core_data = __commonJS({ 57 "package-external:@wordpress/core-data"(exports, module) { 58 module.exports = window.wp.coreData; 59 } 60 }); 61 62 // package-external:@wordpress/notices 63 var require_notices = __commonJS({ 64 "package-external:@wordpress/notices"(exports, module) { 65 module.exports = window.wp.notices; 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 // packages/core-actions/build-module/page/set-as-homepage/action.mjs 77 var import_i18n3 = __toESM(require_i18n(), 1); 78 79 // packages/core-actions/build-module/shared/utils.mjs 80 var import_html_entities = __toESM(require_html_entities(), 1); 81 var import_i18n = __toESM(require_i18n(), 1); 82 function getItemTitle(item, fallback = (0, import_i18n.__)("(no title)")) { 83 let title = ""; 84 if (typeof item.title === "string") { 85 title = (0, import_html_entities.decodeEntities)(item.title); 86 } else if (item.title && "rendered" in item.title) { 87 title = (0, import_html_entities.decodeEntities)(item.title.rendered); 88 } else if (item.title && "raw" in item.title) { 89 title = (0, import_html_entities.decodeEntities)(item.title.raw); 90 } 91 return title || fallback; 92 } 93 94 // packages/core-actions/build-module/shared/has-action-link.mjs 95 function hasActionLink(item, action) { 96 if (!item._links) { 97 return true; 98 } 99 return !!item._links[action]; 100 } 101 102 // packages/core-actions/build-module/page/set-site-page-modal.mjs 103 var import_components = __toESM(require_components(), 1); 104 var import_data = __toESM(require_data(), 1); 105 var import_core_data2 = __toESM(require_core_data(), 1); 106 var import_i18n2 = __toESM(require_i18n(), 1); 107 var import_notices = __toESM(require_notices(), 1); 108 109 // packages/core-actions/build-module/page/refetch-pages.mjs 110 var import_core_data = __toESM(require_core_data(), 1); 111 async function refetchPages(registry, ids) { 112 const include = [...new Set(ids.filter(Boolean))]; 113 if (!include.length) { 114 return; 115 } 116 const query = { include }; 117 registry.dispatch(import_core_data.store).invalidateResolution("getEntityRecords", [ 118 "postType", 119 "page", 120 query 121 ]); 122 await registry.resolveSelect(import_core_data.store).getEntityRecords("postType", "page", query); 123 } 124 125 // packages/core-actions/build-module/page/set-site-page-modal.mjs 126 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); 127 function SetSitePageModal({ 128 setting, 129 items, 130 closeModal, 131 getText: getText3, 132 submitLabel, 133 successNotice, 134 errorNotice 135 }) { 136 const [item] = items; 137 const { siteSettings, currentPage, isSaving } = (0, import_data.useSelect)( 138 (select) => { 139 const { getEntityRecord, isSavingEntityRecord } = select(import_core_data2.store); 140 const settings = getEntityRecord("root", "site"); 141 const currentId = settings?.[setting]; 142 return { 143 siteSettings: settings, 144 // A setting holding no page is `0`, and `getEntityRecord()` 145 // without a key would request the whole collection. 146 currentPage: currentId ? getEntityRecord("postType", "page", currentId) : void 0, 147 isSaving: isSavingEntityRecord("root", "site") 148 }; 149 }, 150 [setting] 151 ); 152 const registry = (0, import_data.useRegistry)(); 153 const { saveEntityRecord } = (0, import_data.useDispatch)(import_core_data2.store); 154 const { createSuccessNotice, createErrorNotice } = (0, import_data.useDispatch)(import_notices.store); 155 async function onSubmit(event) { 156 event.preventDefault(); 157 const previousId = siteSettings?.[setting]; 158 try { 159 await saveEntityRecord( 160 "root", 161 "site", 162 { [setting]: item.id, show_on_front: "page" }, 163 { throwOnError: true } 164 ); 165 } catch (error) { 166 const typedError = error; 167 const errorMessage = typedError.message && typedError.code !== "unknown_error" ? typedError.message : errorNotice; 168 createErrorNotice(errorMessage, { type: "snackbar" }); 169 closeModal?.(); 170 return; 171 } 172 createSuccessNotice(successNotice, { type: "snackbar" }); 173 closeModal?.(); 174 try { 175 await refetchPages(registry, [item.id, previousId]); 176 } catch { 177 } 178 } 179 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("form", { onSubmit, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { spacing: "5", children: [ 180 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { children: getText3({ 181 pageTitle: getItemTitle(item, ""), 182 currentPage, 183 siteSettings 184 }) }), 185 /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { justify: "right", children: [ 186 /* @__PURE__ */ (0, import_jsx_runtime.jsx)( 187 import_components.Button, 188 { 189 __next40pxDefaultSize: true, 190 variant: "tertiary", 191 onClick: () => { 192 closeModal?.(); 193 }, 194 disabled: isSaving, 195 accessibleWhenDisabled: true, 196 children: (0, import_i18n2.__)("Cancel") 197 } 198 ), 199 /* @__PURE__ */ (0, import_jsx_runtime.jsx)( 200 import_components.Button, 201 { 202 __next40pxDefaultSize: true, 203 variant: "primary", 204 type: "submit", 205 disabled: isSaving, 206 accessibleWhenDisabled: true, 207 children: submitLabel 208 } 209 ) 210 ] }) 211 ] }) }); 212 } 213 214 // packages/core-actions/build-module/page/set-as-homepage/action.mjs 215 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); 216 var getText = ({ 217 pageTitle, 218 currentPage, 219 siteSettings 220 }) => { 221 let warning = ""; 222 if ("posts" === siteSettings?.show_on_front) { 223 warning = (0, import_i18n3.__)( 224 "This will replace the current homepage which is set to display latest posts." 225 ); 226 } else if (currentPage) { 227 warning = (0, import_i18n3.sprintf)( 228 // translators: %s: title of the current home page. 229 (0, import_i18n3.__)('This will replace the current homepage: "%s"'), 230 getItemTitle(currentPage, "") 231 ); 232 } 233 return (0, import_i18n3.sprintf)( 234 // translators: %1$s: title of the page to be set as the homepage, %2$s: homepage replacement warning message. 235 (0, import_i18n3.__)('Set "%1$s" as the site homepage? %2$s'), 236 pageTitle, 237 warning 238 ).trim(); 239 }; 240 var setAsHomepage = { 241 isEligible(post) { 242 return post.status === "publish" && hasActionLink(post, "wp:action-set-homepage"); 243 }, 244 RenderModal: ({ items, closeModal }) => { 245 const submitLabel = (0, import_i18n3.__)("Set homepage"); 246 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( 247 SetSitePageModal, 248 { 249 setting: "page_on_front", 250 items, 251 closeModal, 252 getText, 253 submitLabel, 254 successNotice: (0, import_i18n3.__)("Homepage updated."), 255 errorNotice: (0, import_i18n3.__)( 256 "An error occurred while setting the homepage." 257 ) 258 } 259 ); 260 } 261 }; 262 var action_default = setAsHomepage; 263 264 // packages/core-actions/build-module/page/set-as-posts-page/action.mjs 265 var import_i18n4 = __toESM(require_i18n(), 1); 266 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); 267 var getText2 = ({ 268 pageTitle, 269 currentPage 270 }) => (0, import_i18n4.sprintf)( 271 // translators: %1$s: title of the page to be set as the posts page, %2$s: posts page replacement warning message. 272 (0, import_i18n4.__)('Set "%1$s" as the posts page? %2$s'), 273 pageTitle, 274 currentPage ? (0, import_i18n4.sprintf)( 275 // translators: %s: title of the current posts page. 276 (0, import_i18n4.__)('This will replace the current posts page: "%s"'), 277 getItemTitle(currentPage, "") 278 ) : (0, import_i18n4.__)("This page will show the latest posts.") 279 ); 280 var setAsPostsPage = { 281 isEligible(post) { 282 return post.status === "publish" && hasActionLink(post, "wp:action-set-posts-page"); 283 }, 284 RenderModal: ({ items, closeModal }) => { 285 const submitLabel = (0, import_i18n4.__)("Set posts page"); 286 return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)( 287 SetSitePageModal, 288 { 289 setting: "page_for_posts", 290 items, 291 closeModal, 292 getText: getText2, 293 submitLabel, 294 successNotice: (0, import_i18n4.__)("Posts page updated."), 295 errorNotice: (0, import_i18n4.__)( 296 "An error occurred while setting the posts page." 297 ) 298 } 299 ); 300 } 301 }; 302 var action_default2 = setAsPostsPage; 303 304 // packages/core-actions/build-module/page/index.mjs 305 var actions = { 306 "set-as-homepage": action_default, 307 "set-as-posts-page": action_default2 308 }; 309 var page_default = actions; 310 export { 311 page_default as default 312 };
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Wed Oct 21 08:20:34 2026 | Cross-referenced by PHPXref |