| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
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 ReusableBlocksMenuItems: () => (/* reexport */ ReusableBlocksMenuItems), 43 store: () => (/* reexport */ store) 44 }); 45 46 // NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js 47 var actions_namespaceObject = {}; 48 __webpack_require__.r(actions_namespaceObject); 49 __webpack_require__.d(actions_namespaceObject, { 50 __experimentalConvertBlockToStatic: () => (__experimentalConvertBlockToStatic), 51 __experimentalConvertBlocksToReusable: () => (__experimentalConvertBlocksToReusable), 52 __experimentalDeleteReusableBlock: () => (__experimentalDeleteReusableBlock), 53 __experimentalSetEditingReusableBlock: () => (__experimentalSetEditingReusableBlock) 54 }); 55 56 // NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js 57 var selectors_namespaceObject = {}; 58 __webpack_require__.r(selectors_namespaceObject); 59 __webpack_require__.d(selectors_namespaceObject, { 60 __experimentalIsEditingReusableBlock: () => (__experimentalIsEditingReusableBlock) 61 }); 62 63 ;// external ["wp","data"] 64 const external_wp_data_namespaceObject = window["wp"]["data"]; 65 ;// external ["wp","blockEditor"] 66 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; 67 ;// external ["wp","blocks"] 68 const external_wp_blocks_namespaceObject = window["wp"]["blocks"]; 69 ;// external ["wp","i18n"] 70 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; 71 ;// ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js 72 73 74 75 const __experimentalConvertBlockToStatic = (clientId) => ({ registry }) => { 76 const oldBlock = registry.select(external_wp_blockEditor_namespaceObject.store).getBlock(clientId); 77 const reusableBlock = registry.select("core").getEditedEntityRecord( 78 "postType", 79 "wp_block", 80 oldBlock.attributes.ref 81 ); 82 const newBlocks = (0,external_wp_blocks_namespaceObject.parse)( 83 typeof reusableBlock.content === "function" ? reusableBlock.content(reusableBlock) : reusableBlock.content 84 ); 85 registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(oldBlock.clientId, newBlocks); 86 }; 87 const __experimentalConvertBlocksToReusable = (clientIds, title, syncType) => async ({ registry, dispatch }) => { 88 const meta = syncType === "unsynced" ? { 89 wp_pattern_sync_status: syncType 90 } : void 0; 91 const reusableBlock = { 92 title: title || (0,external_wp_i18n_namespaceObject.__)("Untitled pattern block"), 93 content: (0,external_wp_blocks_namespaceObject.serialize)( 94 registry.select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds) 95 ), 96 status: "publish", 97 meta 98 }; 99 const updatedRecord = await registry.dispatch("core").saveEntityRecord("postType", "wp_block", reusableBlock); 100 if (syncType === "unsynced") { 101 return; 102 } 103 const newBlock = (0,external_wp_blocks_namespaceObject.createBlock)("core/block", { 104 ref: updatedRecord.id 105 }); 106 registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(clientIds, newBlock); 107 dispatch.__experimentalSetEditingReusableBlock( 108 newBlock.clientId, 109 true 110 ); 111 }; 112 const __experimentalDeleteReusableBlock = (id) => async ({ registry }) => { 113 const reusableBlock = registry.select("core").getEditedEntityRecord("postType", "wp_block", id); 114 if (!reusableBlock) { 115 return; 116 } 117 const allBlocks = registry.select(external_wp_blockEditor_namespaceObject.store).getBlocks(); 118 const associatedBlocks = allBlocks.filter( 119 (block) => (0,external_wp_blocks_namespaceObject.isReusableBlock)(block) && block.attributes.ref === id 120 ); 121 const associatedBlockClientIds = associatedBlocks.map( 122 (block) => block.clientId 123 ); 124 if (associatedBlockClientIds.length) { 125 registry.dispatch(external_wp_blockEditor_namespaceObject.store).removeBlocks(associatedBlockClientIds); 126 } 127 await registry.dispatch("core").deleteEntityRecord("postType", "wp_block", id); 128 }; 129 function __experimentalSetEditingReusableBlock(clientId, isEditing) { 130 return { 131 type: "SET_EDITING_REUSABLE_BLOCK", 132 clientId, 133 isEditing 134 }; 135 } 136 137 138 ;// ./node_modules/@wordpress/reusable-blocks/build-module/store/reducer.js 139 140 function isEditingReusableBlock(state = {}, action) { 141 if (action?.type === "SET_EDITING_REUSABLE_BLOCK") { 142 return { 143 ...state, 144 [action.clientId]: action.isEditing 145 }; 146 } 147 return state; 148 } 149 var reducer_default = (0,external_wp_data_namespaceObject.combineReducers)({ 150 isEditingReusableBlock 151 }); 152 153 154 ;// ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js 155 function __experimentalIsEditingReusableBlock(state, clientId) { 156 return state.isEditingReusableBlock[clientId]; 157 } 158 159 160 ;// ./node_modules/@wordpress/reusable-blocks/build-module/store/index.js 161 162 163 164 165 const STORE_NAME = "core/reusable-blocks"; 166 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { 167 actions: actions_namespaceObject, 168 reducer: reducer_default, 169 selectors: selectors_namespaceObject 170 }); 171 (0,external_wp_data_namespaceObject.register)(store); 172 173 174 ;// external "ReactJSXRuntime" 175 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; 176 ;// external ["wp","element"] 177 const external_wp_element_namespaceObject = window["wp"]["element"]; 178 ;// external ["wp","components"] 179 const external_wp_components_namespaceObject = window["wp"]["components"]; 180 ;// external ["wp","primitives"] 181 const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; 182 ;// ./node_modules/@wordpress/icons/build-module/library/symbol.js 183 184 185 var symbol_default = /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.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" }) }); 186 187 188 ;// external ["wp","notices"] 189 const external_wp_notices_namespaceObject = window["wp"]["notices"]; 190 ;// external ["wp","coreData"] 191 const external_wp_coreData_namespaceObject = window["wp"]["coreData"]; 192 ;// ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js 193 194 195 196 197 198 199 200 201 202 203 204 function ReusableBlockConvertButton({ 205 clientIds, 206 rootClientId, 207 onClose 208 }) { 209 const [syncType, setSyncType] = (0,external_wp_element_namespaceObject.useState)(void 0); 210 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); 211 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(""); 212 const canConvert = (0,external_wp_data_namespaceObject.useSelect)( 213 (select) => { 214 const { canUser } = select(external_wp_coreData_namespaceObject.store); 215 const { 216 getBlocksByClientId, 217 canInsertBlockType, 218 getBlockRootClientId 219 } = select(external_wp_blockEditor_namespaceObject.store); 220 const rootId = rootClientId || (clientIds.length > 0 ? getBlockRootClientId(clientIds[0]) : void 0); 221 const blocks = getBlocksByClientId(clientIds) ?? []; 222 const isReusable = blocks.length === 1 && blocks[0] && (0,external_wp_blocks_namespaceObject.isReusableBlock)(blocks[0]) && !!select(external_wp_coreData_namespaceObject.store).getEntityRecord( 223 "postType", 224 "wp_block", 225 blocks[0].attributes.ref 226 ); 227 const _canConvert = ( 228 // Hide when this is already a reusable block. 229 !isReusable && // Hide when reusable blocks are disabled. 230 canInsertBlockType("core/block", rootId) && blocks.every( 231 (block) => ( 232 // Guard against the case where a regular block has *just* been converted. 233 !!block && // Hide on invalid blocks. 234 block.isValid && // Hide when block doesn't support being made reusable. 235 (0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, "reusable", true) 236 ) 237 ) && // Hide when current doesn't have permission to do that. 238 // Blocks refers to the wp_block post type, this checks the ability to create a post of that type. 239 !!canUser("create", { 240 kind: "postType", 241 name: "wp_block" 242 }) 243 ); 244 return _canConvert; 245 }, 246 [clientIds, rootClientId] 247 ); 248 const { __experimentalConvertBlocksToReusable: convertBlocksToReusable } = (0,external_wp_data_namespaceObject.useDispatch)(store); 249 const { createSuccessNotice, createErrorNotice } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 250 const onConvert = (0,external_wp_element_namespaceObject.useCallback)( 251 async function(reusableBlockTitle) { 252 try { 253 await convertBlocksToReusable( 254 clientIds, 255 reusableBlockTitle, 256 syncType 257 ); 258 createSuccessNotice( 259 !syncType ? (0,external_wp_i18n_namespaceObject.sprintf)( 260 // translators: %s: the name the user has given to the pattern. 261 (0,external_wp_i18n_namespaceObject.__)("Synced pattern created: %s"), 262 reusableBlockTitle 263 ) : (0,external_wp_i18n_namespaceObject.sprintf)( 264 // translators: %s: the name the user has given to the pattern. 265 (0,external_wp_i18n_namespaceObject.__)("Unsynced pattern created: %s"), 266 reusableBlockTitle 267 ), 268 { 269 type: "snackbar", 270 id: "convert-to-reusable-block-success" 271 } 272 ); 273 } catch (error) { 274 createErrorNotice(error.message, { 275 type: "snackbar", 276 id: "convert-to-reusable-block-error" 277 }); 278 } 279 }, 280 [ 281 convertBlocksToReusable, 282 clientIds, 283 syncType, 284 createSuccessNotice, 285 createErrorNotice 286 ] 287 ); 288 if (!canConvert) { 289 return null; 290 } 291 return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { children: [ 292 /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, { icon: symbol_default, onClick: () => setIsModalOpen(true), children: (0,external_wp_i18n_namespaceObject.__)("Create pattern") }), 293 isModalOpen && /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)( 294 external_wp_components_namespaceObject.Modal, 295 { 296 title: (0,external_wp_i18n_namespaceObject.__)("Create pattern"), 297 onRequestClose: () => { 298 setIsModalOpen(false); 299 setTitle(""); 300 }, 301 overlayClassName: "reusable-blocks-menu-items__convert-modal", 302 children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)( 303 "form", 304 { 305 onSubmit: (event) => { 306 event.preventDefault(); 307 onConvert(title); 308 setIsModalOpen(false); 309 setTitle(""); 310 onClose(); 311 }, 312 children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: "5", children: [ 313 /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)( 314 external_wp_components_namespaceObject.TextControl, 315 { 316 __next40pxDefaultSize: true, 317 __nextHasNoMarginBottom: true, 318 label: (0,external_wp_i18n_namespaceObject.__)("Name"), 319 value: title, 320 onChange: setTitle, 321 placeholder: (0,external_wp_i18n_namespaceObject.__)("My pattern") 322 } 323 ), 324 /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)( 325 external_wp_components_namespaceObject.ToggleControl, 326 { 327 __nextHasNoMarginBottom: true, 328 label: (0,external_wp_i18n_namespaceObject._x)("Synced", "pattern (singular)"), 329 help: (0,external_wp_i18n_namespaceObject.__)( 330 "Sync this pattern across multiple locations." 331 ), 332 checked: !syncType, 333 onChange: () => { 334 setSyncType( 335 !syncType ? "unsynced" : void 0 336 ); 337 } 338 } 339 ), 340 /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "right", children: [ 341 /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)( 342 external_wp_components_namespaceObject.Button, 343 { 344 __next40pxDefaultSize: true, 345 variant: "tertiary", 346 onClick: () => { 347 setIsModalOpen(false); 348 setTitle(""); 349 }, 350 children: (0,external_wp_i18n_namespaceObject.__)("Cancel") 351 } 352 ), 353 /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)( 354 external_wp_components_namespaceObject.Button, 355 { 356 __next40pxDefaultSize: true, 357 variant: "primary", 358 type: "submit", 359 children: (0,external_wp_i18n_namespaceObject.__)("Create") 360 } 361 ) 362 ] }) 363 ] }) 364 } 365 ) 366 } 367 ) 368 ] }); 369 } 370 371 372 ;// external ["wp","url"] 373 const external_wp_url_namespaceObject = window["wp"]["url"]; 374 ;// ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js 375 376 377 378 379 380 381 382 383 384 function ReusableBlocksManageButton({ clientId }) { 385 const { canRemove, isVisible, managePatternsUrl } = (0,external_wp_data_namespaceObject.useSelect)( 386 (select) => { 387 const { getBlock, canRemoveBlock } = select(external_wp_blockEditor_namespaceObject.store); 388 const { canUser } = select(external_wp_coreData_namespaceObject.store); 389 const reusableBlock = getBlock(clientId); 390 return { 391 canRemove: canRemoveBlock(clientId), 392 isVisible: !!reusableBlock && (0,external_wp_blocks_namespaceObject.isReusableBlock)(reusableBlock) && !!canUser("update", { 393 kind: "postType", 394 name: "wp_block", 395 id: reusableBlock.attributes.ref 396 }), 397 // The site editor and templates both check whether the user 398 // has edit_theme_options capabilities. We can leverage that here 399 // and omit the manage patterns link if the user can't access it. 400 managePatternsUrl: canUser("create", { 401 kind: "postType", 402 name: "wp_template" 403 }) ? (0,external_wp_url_namespaceObject.addQueryArgs)("site-editor.php", { 404 p: "/pattern" 405 }) : (0,external_wp_url_namespaceObject.addQueryArgs)("edit.php", { 406 post_type: "wp_block" 407 }) 408 }; 409 }, 410 [clientId] 411 ); 412 const { __experimentalConvertBlockToStatic: convertBlockToStatic } = (0,external_wp_data_namespaceObject.useDispatch)(store); 413 if (!isVisible) { 414 return null; 415 } 416 return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { children: [ 417 /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, { href: managePatternsUrl, children: (0,external_wp_i18n_namespaceObject.__)("Manage patterns") }), 418 canRemove && /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, { onClick: () => convertBlockToStatic(clientId), children: (0,external_wp_i18n_namespaceObject.__)("Detach") }) 419 ] }); 420 } 421 var reusable_blocks_manage_button_default = ReusableBlocksManageButton; 422 423 424 ;// ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.js 425 426 427 428 429 function ReusableBlocksMenuItems({ rootClientId }) { 430 return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, { children: ({ onClose, selectedClientIds }) => /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { children: [ 431 /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)( 432 ReusableBlockConvertButton, 433 { 434 clientIds: selectedClientIds, 435 rootClientId, 436 onClose 437 } 438 ), 439 selectedClientIds.length === 1 && /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)( 440 reusable_blocks_manage_button_default, 441 { 442 clientId: selectedClientIds[0] 443 } 444 ) 445 ] }) }); 446 } 447 448 449 ;// ./node_modules/@wordpress/reusable-blocks/build-module/components/index.js 450 451 452 453 ;// ./node_modules/@wordpress/reusable-blocks/build-module/index.js 454 455 456 457 458 (window.wp = window.wp || {}).reusableBlocks = __webpack_exports__; 459 /******/ })() 460 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Tue Oct 28 08:20:05 2025 | Cross-referenced by PHPXref |