[ 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/compat get default export */ 8 /******/ (() => { 9 /******/ // getDefaultExport function for compatibility with non-harmony modules 10 /******/ __webpack_require__.n = (module) => { 11 /******/ var getter = module && module.__esModule ? 12 /******/ () => (module['default']) : 13 /******/ () => (module); 14 /******/ __webpack_require__.d(getter, { a: getter }); 15 /******/ return getter; 16 /******/ }; 17 /******/ })(); 18 /******/ 19 /******/ /* webpack/runtime/define property getters */ 20 /******/ (() => { 21 /******/ // define getter functions for harmony exports 22 /******/ __webpack_require__.d = (exports, definition) => { 23 /******/ for(var key in definition) { 24 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 25 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 26 /******/ } 27 /******/ } 28 /******/ }; 29 /******/ })(); 30 /******/ 31 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 32 /******/ (() => { 33 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 34 /******/ })(); 35 /******/ 36 /******/ /* webpack/runtime/make namespace object */ 37 /******/ (() => { 38 /******/ // define __esModule on exports 39 /******/ __webpack_require__.r = (exports) => { 40 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 41 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 42 /******/ } 43 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 44 /******/ }; 45 /******/ })(); 46 /******/ 47 /************************************************************************/ 48 var __webpack_exports__ = {}; 49 // ESM COMPAT FLAG 50 __webpack_require__.r(__webpack_exports__); 51 52 // EXPORTS 53 __webpack_require__.d(__webpack_exports__, { 54 MoveToWidgetArea: () => (/* reexport */ MoveToWidgetArea), 55 addWidgetIdToBlock: () => (/* reexport */ addWidgetIdToBlock), 56 getWidgetIdFromBlock: () => (/* reexport */ getWidgetIdFromBlock), 57 registerLegacyWidgetBlock: () => (/* binding */ registerLegacyWidgetBlock), 58 registerLegacyWidgetVariations: () => (/* reexport */ registerLegacyWidgetVariations), 59 registerWidgetGroupBlock: () => (/* binding */ registerWidgetGroupBlock) 60 }); 61 62 // NAMESPACE OBJECT: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/index.js 63 var legacy_widget_namespaceObject = {}; 64 __webpack_require__.r(legacy_widget_namespaceObject); 65 __webpack_require__.d(legacy_widget_namespaceObject, { 66 yu: () => (metadata), 67 UU: () => (legacy_widget_name), 68 W0: () => (settings) 69 }); 70 71 // NAMESPACE OBJECT: ./node_modules/@wordpress/widgets/build-module/blocks/widget-group/index.js 72 var widget_group_namespaceObject = {}; 73 __webpack_require__.r(widget_group_namespaceObject); 74 __webpack_require__.d(widget_group_namespaceObject, { 75 yu: () => (widget_group_metadata), 76 UU: () => (widget_group_name), 77 W0: () => (widget_group_settings) 78 }); 79 80 ;// external ["wp","blocks"] 81 const external_wp_blocks_namespaceObject = window["wp"]["blocks"]; 82 ;// external ["wp","primitives"] 83 const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; 84 ;// external "ReactJSXRuntime" 85 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; 86 ;// ./node_modules/@wordpress/icons/build-module/library/widget.js 87 /** 88 * WordPress dependencies 89 */ 90 91 92 const widget = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { 93 xmlns: "http://www.w3.org/2000/svg", 94 viewBox: "0 0 24 24", 95 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { 96 d: "M6 3H8V5H16V3H18V5C19.1046 5 20 5.89543 20 7V19C20 20.1046 19.1046 21 18 21H6C4.89543 21 4 20.1046 4 19V7C4 5.89543 4.89543 5 6 5V3ZM18 6.5H6C5.72386 6.5 5.5 6.72386 5.5 7V8H18.5V7C18.5 6.72386 18.2761 6.5 18 6.5ZM18.5 9.5H5.5V19C5.5 19.2761 5.72386 19.5 6 19.5H18C18.2761 19.5 18.5 19.2761 18.5 19V9.5ZM11 11H13V13H11V11ZM7 11V13H9V11H7ZM15 13V11H17V13H15Z" 97 }) 98 }); 99 /* harmony default export */ const library_widget = (widget); 100 101 ;// ./node_modules/clsx/dist/clsx.mjs 102 function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}/* harmony default export */ const dist_clsx = (clsx); 103 ;// external ["wp","blockEditor"] 104 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; 105 ;// external ["wp","components"] 106 const external_wp_components_namespaceObject = window["wp"]["components"]; 107 ;// ./node_modules/@wordpress/icons/build-module/library/brush.js 108 /** 109 * WordPress dependencies 110 */ 111 112 113 const brush = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { 114 xmlns: "http://www.w3.org/2000/svg", 115 viewBox: "0 0 24 24", 116 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { 117 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" 118 }) 119 }); 120 /* harmony default export */ const library_brush = (brush); 121 122 ;// external ["wp","i18n"] 123 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; 124 ;// external ["wp","element"] 125 const external_wp_element_namespaceObject = window["wp"]["element"]; 126 ;// external ["wp","data"] 127 const external_wp_data_namespaceObject = window["wp"]["data"]; 128 ;// external ["wp","coreData"] 129 const external_wp_coreData_namespaceObject = window["wp"]["coreData"]; 130 ;// ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/widget-type-selector.js 131 /** 132 * WordPress dependencies 133 */ 134 135 136 137 138 139 140 function WidgetTypeSelector({ 141 selectedId, 142 onSelect 143 }) { 144 const widgetTypes = (0,external_wp_data_namespaceObject.useSelect)(select => { 145 var _select$getSettings$w; 146 const hiddenIds = (_select$getSettings$w = select(external_wp_blockEditor_namespaceObject.store).getSettings()?.widgetTypesToHideFromLegacyWidgetBlock) !== null && _select$getSettings$w !== void 0 ? _select$getSettings$w : []; 147 return select(external_wp_coreData_namespaceObject.store).getWidgetTypes({ 148 per_page: -1 149 })?.filter(widgetType => !hiddenIds.includes(widgetType.id)); 150 }, []); 151 if (!widgetTypes) { 152 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}); 153 } 154 if (widgetTypes.length === 0) { 155 return (0,external_wp_i18n_namespaceObject.__)('There are no widgets available.'); 156 } 157 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SelectControl, { 158 __next40pxDefaultSize: true, 159 __nextHasNoMarginBottom: true, 160 label: (0,external_wp_i18n_namespaceObject.__)('Legacy widget'), 161 value: selectedId !== null && selectedId !== void 0 ? selectedId : '', 162 options: [{ 163 value: '', 164 label: (0,external_wp_i18n_namespaceObject.__)('Select widget') 165 }, ...widgetTypes.map(widgetType => ({ 166 value: widgetType.id, 167 label: widgetType.name 168 }))], 169 onChange: value => { 170 if (value) { 171 const selected = widgetTypes.find(widgetType => widgetType.id === value); 172 onSelect({ 173 selectedId: selected.id, 174 isMulti: selected.is_multi 175 }); 176 } else { 177 onSelect({ 178 selectedId: null 179 }); 180 } 181 } 182 }); 183 } 184 185 ;// ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/inspector-card.js 186 187 188 function InspectorCard({ 189 name, 190 description 191 }) { 192 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", { 193 className: "wp-block-legacy-widget-inspector-card", 194 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h3", { 195 className: "wp-block-legacy-widget-inspector-card__name", 196 children: name 197 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", { 198 children: description 199 })] 200 }); 201 } 202 203 ;// external ["wp","notices"] 204 const external_wp_notices_namespaceObject = window["wp"]["notices"]; 205 ;// external ["wp","compose"] 206 const external_wp_compose_namespaceObject = window["wp"]["compose"]; 207 ;// external ["wp","apiFetch"] 208 const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"]; 209 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject); 210 ;// ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/control.js 211 /* wp:polyfill */ 212 /** 213 * WordPress dependencies 214 */ 215 216 217 218 219 /** 220 * An API for creating and loading a widget control (a <div class="widget"> 221 * element) that is compatible with most third party widget scripts. By not 222 * using React for this, we ensure that we have complete contorl over the DOM 223 * and do not accidentally remove any elements that a third party widget script 224 * has attached an event listener to. 225 * 226 * @property {Element} element The control's DOM element. 227 */ 228 class Control { 229 /** 230 * Creates and loads a new control. 231 * 232 * @access public 233 * @param {Object} params 234 * @param {string} params.id 235 * @param {string} params.idBase 236 * @param {Object} params.instance 237 * @param {Function} params.onChangeInstance 238 * @param {Function} params.onChangeHasPreview 239 * @param {Function} params.onError 240 */ 241 constructor({ 242 id, 243 idBase, 244 instance, 245 onChangeInstance, 246 onChangeHasPreview, 247 onError 248 }) { 249 this.id = id; 250 this.idBase = idBase; 251 this._instance = instance; 252 this._hasPreview = null; 253 this.onChangeInstance = onChangeInstance; 254 this.onChangeHasPreview = onChangeHasPreview; 255 this.onError = onError; 256 257 // We can't use the real widget number as this is calculated by the 258 // server and we may not ever *actually* save this widget. Instead, use 259 // a fake but unique number. 260 this.number = ++lastNumber; 261 this.handleFormChange = (0,external_wp_compose_namespaceObject.debounce)(this.handleFormChange.bind(this), 200); 262 this.handleFormSubmit = this.handleFormSubmit.bind(this); 263 this.initDOM(); 264 this.bindEvents(); 265 this.loadContent(); 266 } 267 268 /** 269 * Clean up the control so that it can be garabge collected. 270 * 271 * @access public 272 */ 273 destroy() { 274 this.unbindEvents(); 275 this.element.remove(); 276 // TODO: How do we make third party widget scripts remove their event 277 // listeners? 278 } 279 280 /** 281 * Creates the control's DOM structure. 282 * 283 * @access private 284 */ 285 initDOM() { 286 var _this$id, _this$idBase; 287 this.element = el('div', { 288 class: 'widget open' 289 }, [el('div', { 290 class: 'widget-inside' 291 }, [this.form = el('form', { 292 class: 'form', 293 method: 'post' 294 }, [ 295 // These hidden form inputs are what most widgets' scripts 296 // use to access data about the widget. 297 el('input', { 298 class: 'widget-id', 299 type: 'hidden', 300 name: 'widget-id', 301 value: (_this$id = this.id) !== null && _this$id !== void 0 ? _this$id : `$this.idBase}-$this.number}` 302 }), el('input', { 303 class: 'id_base', 304 type: 'hidden', 305 name: 'id_base', 306 value: (_this$idBase = this.idBase) !== null && _this$idBase !== void 0 ? _this$idBase : this.id 307 }), el('input', { 308 class: 'widget-width', 309 type: 'hidden', 310 name: 'widget-width', 311 value: '250' 312 }), el('input', { 313 class: 'widget-height', 314 type: 'hidden', 315 name: 'widget-height', 316 value: '200' 317 }), el('input', { 318 class: 'widget_number', 319 type: 'hidden', 320 name: 'widget_number', 321 value: this.idBase ? this.number.toString() : '' 322 }), this.content = el('div', { 323 class: 'widget-content' 324 }), 325 // Non-multi widgets can be saved via a Save button. 326 this.id && el('button', { 327 class: 'button is-primary', 328 type: 'submit' 329 }, (0,external_wp_i18n_namespaceObject.__)('Save'))])])]); 330 } 331 332 /** 333 * Adds the control's event listeners. 334 * 335 * @access private 336 */ 337 bindEvents() { 338 // Prefer jQuery 'change' event instead of the native 'change' event 339 // because many widgets use jQuery's event bus to trigger an update. 340 if (window.jQuery) { 341 const { 342 jQuery: $ 343 } = window; 344 $(this.form).on('change', null, this.handleFormChange); 345 $(this.form).on('input', null, this.handleFormChange); 346 $(this.form).on('submit', this.handleFormSubmit); 347 } else { 348 this.form.addEventListener('change', this.handleFormChange); 349 this.form.addEventListener('input', this.handleFormChange); 350 this.form.addEventListener('submit', this.handleFormSubmit); 351 } 352 } 353 354 /** 355 * Removes the control's event listeners. 356 * 357 * @access private 358 */ 359 unbindEvents() { 360 if (window.jQuery) { 361 const { 362 jQuery: $ 363 } = window; 364 $(this.form).off('change', null, this.handleFormChange); 365 $(this.form).off('input', null, this.handleFormChange); 366 $(this.form).off('submit', this.handleFormSubmit); 367 } else { 368 this.form.removeEventListener('change', this.handleFormChange); 369 this.form.removeEventListener('input', this.handleFormChange); 370 this.form.removeEventListener('submit', this.handleFormSubmit); 371 } 372 } 373 374 /** 375 * Fetches the widget's form HTML from the REST API and loads it into the 376 * control's form. 377 * 378 * @access private 379 */ 380 async loadContent() { 381 try { 382 if (this.id) { 383 const { 384 form 385 } = await saveWidget(this.id); 386 this.content.innerHTML = form; 387 } else if (this.idBase) { 388 const { 389 form, 390 preview 391 } = await encodeWidget({ 392 idBase: this.idBase, 393 instance: this.instance, 394 number: this.number 395 }); 396 this.content.innerHTML = form; 397 this.hasPreview = !isEmptyHTML(preview); 398 399 // If we don't have an instance, perform a save right away. This 400 // happens when creating a new Legacy Widget block. 401 if (!this.instance.hash) { 402 const { 403 instance 404 } = await encodeWidget({ 405 idBase: this.idBase, 406 instance: this.instance, 407 number: this.number, 408 formData: serializeForm(this.form) 409 }); 410 this.instance = instance; 411 } 412 } 413 414 // Trigger 'widget-added' when widget is ready. This event is what 415 // widgets' scripts use to initialize, attach events, etc. The event 416 // must be fired using jQuery's event bus as this is what widget 417 // scripts expect. If jQuery is not loaded, do nothing - some 418 // widgets will still work regardless. 419 if (window.jQuery) { 420 const { 421 jQuery: $ 422 } = window; 423 $(document).trigger('widget-added', [$(this.element)]); 424 } 425 } catch (error) { 426 this.onError(error); 427 } 428 } 429 430 /** 431 * Perform a save when a multi widget's form is changed. Non-multi widgets 432 * are saved manually. 433 * 434 * @access private 435 */ 436 handleFormChange() { 437 if (this.idBase) { 438 this.saveForm(); 439 } 440 } 441 442 /** 443 * Perform a save when the control's form is manually submitted. 444 * 445 * @access private 446 * @param {Event} event 447 */ 448 handleFormSubmit(event) { 449 event.preventDefault(); 450 this.saveForm(); 451 } 452 453 /** 454 * Serialize the control's form, send it to the REST API, and update the 455 * instance with the encoded instance that the REST API returns. 456 * 457 * @access private 458 */ 459 async saveForm() { 460 const formData = serializeForm(this.form); 461 try { 462 if (this.id) { 463 const { 464 form 465 } = await saveWidget(this.id, formData); 466 this.content.innerHTML = form; 467 if (window.jQuery) { 468 const { 469 jQuery: $ 470 } = window; 471 $(document).trigger('widget-updated', [$(this.element)]); 472 } 473 } else if (this.idBase) { 474 const { 475 instance, 476 preview 477 } = await encodeWidget({ 478 idBase: this.idBase, 479 instance: this.instance, 480 number: this.number, 481 formData 482 }); 483 this.instance = instance; 484 this.hasPreview = !isEmptyHTML(preview); 485 } 486 } catch (error) { 487 this.onError(error); 488 } 489 } 490 491 /** 492 * The widget's instance object. 493 * 494 * @access private 495 */ 496 get instance() { 497 return this._instance; 498 } 499 500 /** 501 * The widget's instance object. 502 * 503 * @access private 504 */ 505 set instance(instance) { 506 if (this._instance !== instance) { 507 this._instance = instance; 508 this.onChangeInstance(instance); 509 } 510 } 511 512 /** 513 * Whether or not the widget can be previewed. 514 * 515 * @access public 516 */ 517 get hasPreview() { 518 return this._hasPreview; 519 } 520 521 /** 522 * Whether or not the widget can be previewed. 523 * 524 * @access private 525 */ 526 set hasPreview(hasPreview) { 527 if (this._hasPreview !== hasPreview) { 528 this._hasPreview = hasPreview; 529 this.onChangeHasPreview(hasPreview); 530 } 531 } 532 } 533 let lastNumber = 0; 534 function el(tagName, attributes = {}, content = null) { 535 const element = document.createElement(tagName); 536 for (const [attribute, value] of Object.entries(attributes)) { 537 element.setAttribute(attribute, value); 538 } 539 if (Array.isArray(content)) { 540 for (const child of content) { 541 if (child) { 542 element.appendChild(child); 543 } 544 } 545 } else if (typeof content === 'string') { 546 element.innerText = content; 547 } 548 return element; 549 } 550 async function saveWidget(id, formData = null) { 551 let widget; 552 if (formData) { 553 widget = await external_wp_apiFetch_default()({ 554 path: `/wp/v2/widgets/$id}?context=edit`, 555 method: 'PUT', 556 data: { 557 form_data: formData 558 } 559 }); 560 } else { 561 widget = await external_wp_apiFetch_default()({ 562 path: `/wp/v2/widgets/$id}?context=edit`, 563 method: 'GET' 564 }); 565 } 566 return { 567 form: widget.rendered_form 568 }; 569 } 570 async function encodeWidget({ 571 idBase, 572 instance, 573 number, 574 formData = null 575 }) { 576 const response = await external_wp_apiFetch_default()({ 577 path: `/wp/v2/widget-types/$idBase}/encode`, 578 method: 'POST', 579 data: { 580 instance, 581 number, 582 form_data: formData 583 } 584 }); 585 return { 586 instance: response.instance, 587 form: response.form, 588 preview: response.preview 589 }; 590 } 591 function isEmptyHTML(html) { 592 const element = document.createElement('div'); 593 element.innerHTML = html; 594 return isEmptyNode(element); 595 } 596 function isEmptyNode(node) { 597 switch (node.nodeType) { 598 case node.TEXT_NODE: 599 // Text nodes are empty if it's entirely whitespace. 600 return node.nodeValue.trim() === ''; 601 case node.ELEMENT_NODE: 602 // Elements that are "embedded content" are not empty. 603 // https://dev.w3.org/html5/spec-LC/content-models.html#embedded-content-0 604 if (['AUDIO', 'CANVAS', 'EMBED', 'IFRAME', 'IMG', 'MATH', 'OBJECT', 'SVG', 'VIDEO'].includes(node.tagName)) { 605 return false; 606 } 607 // Elements with no children are empty. 608 if (!node.hasChildNodes()) { 609 return true; 610 } 611 // Elements with children are empty if all their children are empty. 612 return Array.from(node.childNodes).every(isEmptyNode); 613 default: 614 return true; 615 } 616 } 617 function serializeForm(form) { 618 return new window.URLSearchParams(Array.from(new window.FormData(form))).toString(); 619 } 620 621 ;// ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/form.js 622 /** 623 * External dependencies 624 */ 625 626 /** 627 * WordPress dependencies 628 */ 629 630 631 632 633 634 635 /** 636 * Internal dependencies 637 */ 638 639 640 641 function Form({ 642 title, 643 isVisible, 644 id, 645 idBase, 646 instance, 647 isWide, 648 onChangeInstance, 649 onChangeHasPreview 650 }) { 651 const ref = (0,external_wp_element_namespaceObject.useRef)(); 652 const isMediumLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small'); 653 654 // We only want to remount the control when the instance changes 655 // *externally*. For example, if the user performs an undo. To do this, we 656 // keep track of changes made to instance by the control itself and then 657 // ignore those. 658 const outgoingInstances = (0,external_wp_element_namespaceObject.useRef)(new Set()); 659 const incomingInstances = (0,external_wp_element_namespaceObject.useRef)(new Set()); 660 const { 661 createNotice 662 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 663 (0,external_wp_element_namespaceObject.useEffect)(() => { 664 if (incomingInstances.current.has(instance)) { 665 incomingInstances.current.delete(instance); 666 return; 667 } 668 const control = new Control({ 669 id, 670 idBase, 671 instance, 672 onChangeInstance(nextInstance) { 673 outgoingInstances.current.add(instance); 674 incomingInstances.current.add(nextInstance); 675 onChangeInstance(nextInstance); 676 }, 677 onChangeHasPreview, 678 onError(error) { 679 window.console.error(error); 680 createNotice('error', (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: the name of the affected block. */ 681 (0,external_wp_i18n_namespaceObject.__)('The "%s" block was affected by errors and may not function properly. Check the developer tools for more details.'), idBase || id)); 682 } 683 }); 684 ref.current.appendChild(control.element); 685 return () => { 686 if (outgoingInstances.current.has(instance)) { 687 outgoingInstances.current.delete(instance); 688 return; 689 } 690 control.destroy(); 691 }; 692 }, [id, idBase, instance, onChangeInstance, onChangeHasPreview, isMediumLargeViewport]); 693 if (isWide && isMediumLargeViewport) { 694 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", { 695 className: dist_clsx({ 696 'wp-block-legacy-widget__container': isVisible 697 }), 698 children: [isVisible && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h3", { 699 className: "wp-block-legacy-widget__edit-form-title", 700 children: title 701 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Popover, { 702 focusOnMount: false, 703 placement: "right", 704 offset: 32, 705 resize: false, 706 flip: false, 707 shift: true, 708 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { 709 ref: ref, 710 className: "wp-block-legacy-widget__edit-form", 711 hidden: !isVisible 712 }) 713 })] 714 }); 715 } 716 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { 717 ref: ref, 718 className: "wp-block-legacy-widget__edit-form", 719 hidden: !isVisible, 720 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h3", { 721 className: "wp-block-legacy-widget__edit-form-title", 722 children: title 723 }) 724 }); 725 } 726 727 ;// ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/preview.js 728 /** 729 * External dependencies 730 */ 731 732 733 /** 734 * WordPress dependencies 735 */ 736 737 738 739 740 741 742 743 744 function Preview({ 745 idBase, 746 instance, 747 isVisible 748 }) { 749 const [isLoaded, setIsLoaded] = (0,external_wp_element_namespaceObject.useState)(false); 750 const [srcDoc, setSrcDoc] = (0,external_wp_element_namespaceObject.useState)(''); 751 (0,external_wp_element_namespaceObject.useEffect)(() => { 752 const abortController = typeof window.AbortController === 'undefined' ? undefined : new window.AbortController(); 753 async function fetchPreviewHTML() { 754 const restRoute = `/wp/v2/widget-types/$idBase}/render`; 755 return await external_wp_apiFetch_default()({ 756 path: restRoute, 757 method: 'POST', 758 signal: abortController?.signal, 759 data: instance ? { 760 instance 761 } : {} 762 }); 763 } 764 fetchPreviewHTML().then(response => { 765 setSrcDoc(response.preview); 766 }).catch(error => { 767 if ('AbortError' === error.name) { 768 // We don't want to log aborted requests. 769 return; 770 } 771 throw error; 772 }); 773 return () => abortController?.abort(); 774 }, [idBase, instance]); 775 776 // Resize the iframe on either the load event, or when the iframe becomes visible. 777 const ref = (0,external_wp_compose_namespaceObject.useRefEffect)(iframe => { 778 // Only set height if the iframe is loaded, 779 // or it will grow to an unexpected large height in Safari if it's hidden initially. 780 if (!isLoaded) { 781 return; 782 } 783 // If the preview frame has another origin then this won't work. 784 // One possible solution is to add custom script to call `postMessage` in the preview frame. 785 // Or, better yet, we migrate away from iframe. 786 function setHeight() { 787 var _iframe$contentDocume, _iframe$contentDocume2; 788 // Pick the maximum of these two values to account for margin collapsing. 789 const height = Math.max((_iframe$contentDocume = iframe.contentDocument.documentElement?.offsetHeight) !== null && _iframe$contentDocume !== void 0 ? _iframe$contentDocume : 0, (_iframe$contentDocume2 = iframe.contentDocument.body?.offsetHeight) !== null && _iframe$contentDocume2 !== void 0 ? _iframe$contentDocume2 : 0); 790 791 // Fallback to a height of 100px if the height cannot be determined. 792 // This ensures the block is still selectable. 100px should hopefully 793 // be not so big that it's annoying, and not so small that nothing 794 // can be seen. 795 iframe.style.height = `$height !== 0 ? height : 100}px`; 796 } 797 const { 798 IntersectionObserver 799 } = iframe.ownerDocument.defaultView; 800 801 // Observe for intersections that might cause a change in the height of 802 // the iframe, e.g. a Widget Area becoming expanded. 803 const intersectionObserver = new IntersectionObserver(([entry]) => { 804 if (entry.isIntersecting) { 805 setHeight(); 806 } 807 }, { 808 threshold: 1 809 }); 810 intersectionObserver.observe(iframe); 811 iframe.addEventListener('load', setHeight); 812 return () => { 813 intersectionObserver.disconnect(); 814 iframe.removeEventListener('load', setHeight); 815 }; 816 }, [isLoaded]); 817 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 818 children: [isVisible && !isLoaded && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Placeholder, { 819 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}) 820 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { 821 className: dist_clsx('wp-block-legacy-widget__edit-preview', { 822 'is-offscreen': !isVisible || !isLoaded 823 }), 824 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Disabled, { 825 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("iframe", { 826 ref: ref, 827 className: "wp-block-legacy-widget__edit-preview-iframe", 828 tabIndex: "-1", 829 title: (0,external_wp_i18n_namespaceObject.__)('Legacy Widget Preview'), 830 srcDoc: srcDoc, 831 onLoad: event => { 832 // To hide the scrollbars of the preview frame for some edge cases, 833 // such as negative margins in the Gallery Legacy Widget. 834 // It can't be scrolled anyway. 835 // TODO: Ideally, this should be fixed in core. 836 event.target.contentDocument.body.style.overflow = 'hidden'; 837 setIsLoaded(true); 838 }, 839 height: 100 840 }) 841 }) 842 })] 843 }); 844 } 845 846 ;// ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/no-preview.js 847 /** 848 * WordPress dependencies 849 */ 850 851 852 853 function NoPreview({ 854 name 855 }) { 856 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", { 857 className: "wp-block-legacy-widget__edit-no-preview", 858 children: [name && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h3", { 859 children: name 860 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", { 861 children: (0,external_wp_i18n_namespaceObject.__)('No preview available.') 862 })] 863 }); 864 } 865 866 ;// ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/convert-to-blocks-button.js 867 /** 868 * WordPress dependencies 869 */ 870 871 872 873 874 875 876 function ConvertToBlocksButton({ 877 clientId, 878 rawInstance 879 }) { 880 const { 881 replaceBlocks 882 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 883 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarButton, { 884 onClick: () => { 885 if (rawInstance.title) { 886 replaceBlocks(clientId, [(0,external_wp_blocks_namespaceObject.createBlock)('core/heading', { 887 content: rawInstance.title 888 }), ...(0,external_wp_blocks_namespaceObject.rawHandler)({ 889 HTML: rawInstance.text 890 })]); 891 } else { 892 replaceBlocks(clientId, (0,external_wp_blocks_namespaceObject.rawHandler)({ 893 HTML: rawInstance.text 894 })); 895 } 896 }, 897 children: (0,external_wp_i18n_namespaceObject.__)('Convert to blocks') 898 }); 899 } 900 901 ;// ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/index.js 902 /** 903 * External dependencies 904 */ 905 906 907 /** 908 * WordPress dependencies 909 */ 910 911 912 913 914 915 916 917 918 /** 919 * Internal dependencies 920 */ 921 922 923 924 925 926 927 928 929 930 function Edit(props) { 931 const { 932 id, 933 idBase 934 } = props.attributes; 935 const { 936 isWide = false 937 } = props; 938 const blockProps = (0,external_wp_blockEditor_namespaceObject.useBlockProps)({ 939 className: dist_clsx({ 940 'is-wide-widget': isWide 941 }) 942 }); 943 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { 944 ...blockProps, 945 children: !id && !idBase ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Empty, { 946 ...props 947 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NotEmpty, { 948 ...props 949 }) 950 }); 951 } 952 function Empty({ 953 attributes: { 954 id, 955 idBase 956 }, 957 setAttributes 958 }) { 959 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Placeholder, { 960 icon: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockIcon, { 961 icon: library_brush 962 }), 963 label: (0,external_wp_i18n_namespaceObject.__)('Legacy Widget'), 964 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Flex, { 965 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexBlock, { 966 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WidgetTypeSelector, { 967 selectedId: id !== null && id !== void 0 ? id : idBase, 968 onSelect: ({ 969 selectedId, 970 isMulti 971 }) => { 972 if (!selectedId) { 973 setAttributes({ 974 id: null, 975 idBase: null, 976 instance: null 977 }); 978 } else if (isMulti) { 979 setAttributes({ 980 id: null, 981 idBase: selectedId, 982 instance: {} 983 }); 984 } else { 985 setAttributes({ 986 id: selectedId, 987 idBase: null, 988 instance: null 989 }); 990 } 991 } 992 }) 993 }) 994 }) 995 }); 996 } 997 function NotEmpty({ 998 attributes: { 999 id, 1000 idBase, 1001 instance 1002 }, 1003 setAttributes, 1004 clientId, 1005 isSelected, 1006 isWide = false 1007 }) { 1008 const [hasPreview, setHasPreview] = (0,external_wp_element_namespaceObject.useState)(null); 1009 const widgetTypeId = id !== null && id !== void 0 ? id : idBase; 1010 const { 1011 record: widgetType, 1012 hasResolved: hasResolvedWidgetType 1013 } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('root', 'widgetType', widgetTypeId); 1014 const isNavigationMode = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).isNavigationMode(), []); 1015 const setInstance = (0,external_wp_element_namespaceObject.useCallback)(nextInstance => { 1016 setAttributes({ 1017 instance: nextInstance 1018 }); 1019 }, []); 1020 if (!widgetType && hasResolvedWidgetType) { 1021 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Placeholder, { 1022 icon: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockIcon, { 1023 icon: library_brush 1024 }), 1025 label: (0,external_wp_i18n_namespaceObject.__)('Legacy Widget'), 1026 children: (0,external_wp_i18n_namespaceObject.__)('Widget is missing.') 1027 }); 1028 } 1029 if (!hasResolvedWidgetType) { 1030 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Placeholder, { 1031 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}) 1032 }); 1033 } 1034 const mode = idBase && (isNavigationMode || !isSelected) ? 'preview' : 'edit'; 1035 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 1036 children: [idBase === 'text' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockControls, { 1037 group: "other", 1038 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ConvertToBlocksButton, { 1039 clientId: clientId, 1040 rawInstance: instance.raw 1041 }) 1042 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.InspectorControls, { 1043 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(InspectorCard, { 1044 name: widgetType.name, 1045 description: widgetType.description 1046 }) 1047 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Form, { 1048 title: widgetType.name, 1049 isVisible: mode === 'edit', 1050 id: id, 1051 idBase: idBase, 1052 instance: instance, 1053 isWide: isWide, 1054 onChangeInstance: setInstance, 1055 onChangeHasPreview: setHasPreview 1056 }), idBase && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 1057 children: [hasPreview === null && mode === 'preview' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Placeholder, { 1058 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}) 1059 }), hasPreview === true && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Preview, { 1060 idBase: idBase, 1061 instance: instance, 1062 isVisible: mode === 'preview' 1063 }), hasPreview === false && mode === 'preview' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NoPreview, { 1064 name: widgetType.name 1065 })] 1066 })] 1067 }); 1068 } 1069 1070 ;// ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/transforms.js 1071 /** 1072 * WordPress dependencies 1073 */ 1074 1075 const legacyWidgetTransforms = [{ 1076 block: 'core/calendar', 1077 widget: 'calendar' 1078 }, { 1079 block: 'core/search', 1080 widget: 'search' 1081 }, { 1082 block: 'core/html', 1083 widget: 'custom_html', 1084 transform: ({ 1085 content 1086 }) => ({ 1087 content 1088 }) 1089 }, { 1090 block: 'core/archives', 1091 widget: 'archives', 1092 transform: ({ 1093 count, 1094 dropdown 1095 }) => { 1096 return { 1097 displayAsDropdown: !!dropdown, 1098 showPostCounts: !!count 1099 }; 1100 } 1101 }, { 1102 block: 'core/latest-posts', 1103 widget: 'recent-posts', 1104 transform: ({ 1105 show_date: displayPostDate, 1106 number 1107 }) => { 1108 return { 1109 displayPostDate: !!displayPostDate, 1110 postsToShow: number 1111 }; 1112 } 1113 }, { 1114 block: 'core/latest-comments', 1115 widget: 'recent-comments', 1116 transform: ({ 1117 number 1118 }) => { 1119 return { 1120 commentsToShow: number 1121 }; 1122 } 1123 }, { 1124 block: 'core/tag-cloud', 1125 widget: 'tag_cloud', 1126 transform: ({ 1127 taxonomy, 1128 count 1129 }) => { 1130 return { 1131 showTagCounts: !!count, 1132 taxonomy 1133 }; 1134 } 1135 }, { 1136 block: 'core/categories', 1137 widget: 'categories', 1138 transform: ({ 1139 count, 1140 dropdown, 1141 hierarchical 1142 }) => { 1143 return { 1144 displayAsDropdown: !!dropdown, 1145 showPostCounts: !!count, 1146 showHierarchy: !!hierarchical 1147 }; 1148 } 1149 }, { 1150 block: 'core/audio', 1151 widget: 'media_audio', 1152 transform: ({ 1153 url, 1154 preload, 1155 loop, 1156 attachment_id: id 1157 }) => { 1158 return { 1159 src: url, 1160 id, 1161 preload, 1162 loop 1163 }; 1164 } 1165 }, { 1166 block: 'core/video', 1167 widget: 'media_video', 1168 transform: ({ 1169 url, 1170 preload, 1171 loop, 1172 attachment_id: id 1173 }) => { 1174 return { 1175 src: url, 1176 id, 1177 preload, 1178 loop 1179 }; 1180 } 1181 }, { 1182 block: 'core/image', 1183 widget: 'media_image', 1184 transform: ({ 1185 alt, 1186 attachment_id: id, 1187 caption, 1188 height, 1189 link_classes: linkClass, 1190 link_rel: rel, 1191 link_target_blank: targetBlack, 1192 link_type: linkDestination, 1193 link_url: link, 1194 size: sizeSlug, 1195 url, 1196 width 1197 }) => { 1198 return { 1199 alt, 1200 caption, 1201 height, 1202 id, 1203 link, 1204 linkClass, 1205 linkDestination, 1206 linkTarget: targetBlack ? '_blank' : undefined, 1207 rel, 1208 sizeSlug, 1209 url, 1210 width 1211 }; 1212 } 1213 }, { 1214 block: 'core/gallery', 1215 widget: 'media_gallery', 1216 transform: ({ 1217 ids, 1218 link_type: linkTo, 1219 size, 1220 number 1221 }) => { 1222 return { 1223 ids, 1224 columns: number, 1225 linkTo, 1226 sizeSlug: size, 1227 images: ids.map(id => ({ 1228 id 1229 })) 1230 }; 1231 } 1232 }, { 1233 block: 'core/rss', 1234 widget: 'rss', 1235 transform: ({ 1236 url, 1237 show_author: displayAuthor, 1238 show_date: displayDate, 1239 show_summary: displayExcerpt, 1240 items 1241 }) => { 1242 return { 1243 feedURL: url, 1244 displayAuthor: !!displayAuthor, 1245 displayDate: !!displayDate, 1246 displayExcerpt: !!displayExcerpt, 1247 itemsToShow: items 1248 }; 1249 } 1250 }].map(({ 1251 block, 1252 widget, 1253 transform 1254 }) => { 1255 return { 1256 type: 'block', 1257 blocks: [block], 1258 isMatch: ({ 1259 idBase, 1260 instance 1261 }) => { 1262 return idBase === widget && !!instance?.raw; 1263 }, 1264 transform: ({ 1265 instance 1266 }) => { 1267 const transformedBlock = (0,external_wp_blocks_namespaceObject.createBlock)(block, transform ? transform(instance.raw) : undefined); 1268 if (!instance.raw?.title) { 1269 return transformedBlock; 1270 } 1271 return [(0,external_wp_blocks_namespaceObject.createBlock)('core/heading', { 1272 content: instance.raw.title 1273 }), transformedBlock]; 1274 } 1275 }; 1276 }); 1277 const transforms = { 1278 to: legacyWidgetTransforms 1279 }; 1280 /* harmony default export */ const legacy_widget_transforms = (transforms); 1281 1282 ;// ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/index.js 1283 /** 1284 * WordPress dependencies 1285 */ 1286 1287 1288 /** 1289 * Internal dependencies 1290 */ 1291 const metadata = { 1292 $schema: "https://schemas.wp.org/trunk/block.json", 1293 apiVersion: 3, 1294 name: "core/legacy-widget", 1295 title: "Legacy Widget", 1296 category: "widgets", 1297 description: "Display a legacy widget.", 1298 textdomain: "default", 1299 attributes: { 1300 id: { 1301 type: "string", 1302 "default": null 1303 }, 1304 idBase: { 1305 type: "string", 1306 "default": null 1307 }, 1308 instance: { 1309 type: "object", 1310 "default": null 1311 } 1312 }, 1313 supports: { 1314 html: false, 1315 customClassName: false, 1316 reusable: false 1317 }, 1318 editorStyle: "wp-block-legacy-widget-editor" 1319 }; 1320 1321 1322 const { 1323 name: legacy_widget_name 1324 } = metadata; 1325 1326 const settings = { 1327 icon: library_widget, 1328 edit: Edit, 1329 transforms: legacy_widget_transforms 1330 }; 1331 1332 ;// ./node_modules/@wordpress/icons/build-module/library/group.js 1333 /** 1334 * WordPress dependencies 1335 */ 1336 1337 1338 const group = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { 1339 viewBox: "0 0 24 24", 1340 xmlns: "http://www.w3.org/2000/svg", 1341 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { 1342 d: "M18 4h-7c-1.1 0-2 .9-2 2v3H6c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h7c1.1 0 2-.9 2-2v-3h3c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4.5 14c0 .3-.2.5-.5.5H6c-.3 0-.5-.2-.5-.5v-7c0-.3.2-.5.5-.5h3V13c0 1.1.9 2 2 2h2.5v3zm0-4.5H11c-.3 0-.5-.2-.5-.5v-2.5H13c.3 0 .5.2.5.5v2.5zm5-.5c0 .3-.2.5-.5.5h-3V11c0-1.1-.9-2-2-2h-2.5V6c0-.3.2-.5.5-.5h7c.3 0 .5.2.5.5v7z" 1343 }) 1344 }); 1345 /* harmony default export */ const library_group = (group); 1346 1347 ;// ./node_modules/@wordpress/widgets/build-module/blocks/widget-group/edit.js 1348 /** 1349 * WordPress dependencies 1350 */ 1351 1352 1353 1354 1355 1356 1357 1358 1359 function edit_Edit(props) { 1360 const { 1361 clientId 1362 } = props; 1363 const { 1364 innerBlocks 1365 } = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getBlock(clientId), [clientId]); 1366 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { 1367 ...(0,external_wp_blockEditor_namespaceObject.useBlockProps)({ 1368 className: 'widget' 1369 }), 1370 children: innerBlocks.length === 0 ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PlaceholderContent, { 1371 ...props 1372 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreviewContent, { 1373 ...props 1374 }) 1375 }); 1376 } 1377 function PlaceholderContent({ 1378 clientId 1379 }) { 1380 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 1381 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Placeholder, { 1382 className: "wp-block-widget-group__placeholder", 1383 icon: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockIcon, { 1384 icon: library_group 1385 }), 1386 label: (0,external_wp_i18n_namespaceObject.__)('Widget Group'), 1387 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.ButtonBlockAppender, { 1388 rootClientId: clientId 1389 }) 1390 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.InnerBlocks, { 1391 renderAppender: false 1392 })] 1393 }); 1394 } 1395 function PreviewContent({ 1396 attributes, 1397 setAttributes 1398 }) { 1399 var _attributes$title; 1400 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 1401 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichText, { 1402 tagName: "h2", 1403 identifier: "title", 1404 className: "widget-title", 1405 allowedFormats: [], 1406 placeholder: (0,external_wp_i18n_namespaceObject.__)('Title'), 1407 value: (_attributes$title = attributes.title) !== null && _attributes$title !== void 0 ? _attributes$title : '', 1408 onChange: title => setAttributes({ 1409 title 1410 }) 1411 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.InnerBlocks, {})] 1412 }); 1413 } 1414 1415 ;// ./node_modules/@wordpress/widgets/build-module/blocks/widget-group/save.js 1416 /** 1417 * WordPress dependencies 1418 */ 1419 1420 1421 1422 1423 function save({ 1424 attributes 1425 }) { 1426 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 1427 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichText.Content, { 1428 tagName: "h2", 1429 className: "widget-title", 1430 value: attributes.title 1431 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { 1432 className: "wp-widget-group__inner-blocks", 1433 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.InnerBlocks.Content, {}) 1434 })] 1435 }); 1436 } 1437 1438 ;// ./node_modules/@wordpress/widgets/build-module/blocks/widget-group/deprecated.js 1439 /** 1440 * WordPress dependencies 1441 */ 1442 1443 1444 1445 1446 const v1 = { 1447 attributes: { 1448 title: { 1449 type: 'string' 1450 } 1451 }, 1452 supports: { 1453 html: false, 1454 inserter: true, 1455 customClassName: true, 1456 reusable: false 1457 }, 1458 save({ 1459 attributes 1460 }) { 1461 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { 1462 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.RichText.Content, { 1463 tagName: "h2", 1464 className: "widget-title", 1465 value: attributes.title 1466 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.InnerBlocks.Content, {})] 1467 }); 1468 } 1469 }; 1470 /* harmony default export */ const deprecated = ([v1]); 1471 1472 ;// ./node_modules/@wordpress/widgets/build-module/blocks/widget-group/index.js 1473 /** 1474 * WordPress dependencies 1475 */ 1476 1477 1478 1479 1480 /** 1481 * Internal dependencies 1482 */ 1483 const widget_group_metadata = { 1484 $schema: "https://schemas.wp.org/trunk/block.json", 1485 apiVersion: 3, 1486 name: "core/widget-group", 1487 title: "Widget Group", 1488 category: "widgets", 1489 attributes: { 1490 title: { 1491 type: "string" 1492 } 1493 }, 1494 supports: { 1495 html: false, 1496 inserter: true, 1497 customClassName: true, 1498 reusable: false 1499 }, 1500 editorStyle: "wp-block-widget-group-editor", 1501 style: "wp-block-widget-group" 1502 }; 1503 1504 1505 1506 const { 1507 name: widget_group_name 1508 } = widget_group_metadata; 1509 1510 const widget_group_settings = { 1511 title: (0,external_wp_i18n_namespaceObject.__)('Widget Group'), 1512 description: (0,external_wp_i18n_namespaceObject.__)('Create a classic widget layout with a title that’s styled by your theme for your widget areas.'), 1513 icon: library_group, 1514 __experimentalLabel: ({ 1515 name: label 1516 }) => label, 1517 edit: edit_Edit, 1518 save: save, 1519 transforms: { 1520 from: [{ 1521 type: 'block', 1522 isMultiBlock: true, 1523 blocks: ['*'], 1524 isMatch(attributes, blocks) { 1525 // Avoid transforming existing `widget-group` blocks. 1526 return !blocks.some(block => block.name === 'core/widget-group'); 1527 }, 1528 __experimentalConvert(blocks) { 1529 // Put the selected blocks inside the new Widget Group's innerBlocks. 1530 let innerBlocks = [...blocks.map(block => { 1531 return (0,external_wp_blocks_namespaceObject.createBlock)(block.name, block.attributes, block.innerBlocks); 1532 })]; 1533 1534 // If the first block is a heading then assume this is intended 1535 // to be the Widget's "title". 1536 const firstHeadingBlock = innerBlocks[0].name === 'core/heading' ? innerBlocks[0] : null; 1537 1538 // Remove the first heading block as we're copying 1539 // it's content into the Widget Group's title attribute. 1540 innerBlocks = innerBlocks.filter(block => block !== firstHeadingBlock); 1541 return (0,external_wp_blocks_namespaceObject.createBlock)('core/widget-group', { 1542 ...(firstHeadingBlock && { 1543 title: firstHeadingBlock.attributes.content 1544 }) 1545 }, innerBlocks); 1546 } 1547 }] 1548 }, 1549 deprecated: deprecated 1550 }; 1551 1552 ;// ./node_modules/@wordpress/icons/build-module/library/move-to.js 1553 /** 1554 * WordPress dependencies 1555 */ 1556 1557 1558 const moveTo = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { 1559 xmlns: "http://www.w3.org/2000/svg", 1560 viewBox: "0 0 24 24", 1561 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { 1562 d: "M19.75 9c0-1.257-.565-2.197-1.39-2.858-.797-.64-1.827-1.017-2.815-1.247-1.802-.42-3.703-.403-4.383-.396L11 4.5V6l.177-.001c.696-.006 2.416-.02 4.028.356.887.207 1.67.518 2.216.957.52.416.829.945.829 1.688 0 .592-.167.966-.407 1.23-.255.281-.656.508-1.236.674-1.19.34-2.82.346-4.607.346h-.077c-1.692 0-3.527 0-4.942.404-.732.209-1.424.545-1.935 1.108-.526.579-.796 1.33-.796 2.238 0 1.257.565 2.197 1.39 2.858.797.64 1.827 1.017 2.815 1.247 1.802.42 3.703.403 4.383.396L13 19.5h.714V22L18 18.5 13.714 15v3H13l-.177.001c-.696.006-2.416.02-4.028-.356-.887-.207-1.67-.518-2.216-.957-.52-.416-.829-.945-.829-1.688 0-.592.167-.966.407-1.23.255-.281.656-.508 1.237-.674 1.189-.34 2.819-.346 4.606-.346h.077c1.692 0 3.527 0 4.941-.404.732-.209 1.425-.545 1.936-1.108.526-.579.796-1.33.796-2.238z" 1563 }) 1564 }); 1565 /* harmony default export */ const move_to = (moveTo); 1566 1567 ;// ./node_modules/@wordpress/widgets/build-module/components/move-to-widget-area/index.js 1568 /** 1569 * WordPress dependencies 1570 */ 1571 1572 1573 1574 1575 function MoveToWidgetArea({ 1576 currentWidgetAreaId, 1577 widgetAreas, 1578 onSelect 1579 }) { 1580 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarGroup, { 1581 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, { 1582 children: toggleProps => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, { 1583 icon: move_to, 1584 label: (0,external_wp_i18n_namespaceObject.__)('Move to widget area'), 1585 toggleProps: toggleProps, 1586 children: ({ 1587 onClose 1588 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, { 1589 label: (0,external_wp_i18n_namespaceObject.__)('Move to'), 1590 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItemsChoice, { 1591 choices: widgetAreas.map(widgetArea => ({ 1592 value: widgetArea.id, 1593 label: widgetArea.name, 1594 info: widgetArea.description 1595 })), 1596 value: currentWidgetAreaId, 1597 onSelect: value => { 1598 onSelect(value); 1599 onClose(); 1600 } 1601 }) 1602 }) 1603 }) 1604 }) 1605 }); 1606 } 1607 1608 ;// ./node_modules/@wordpress/widgets/build-module/components/index.js 1609 1610 1611 ;// ./node_modules/@wordpress/widgets/build-module/utils.js 1612 // @ts-check 1613 1614 /** 1615 * Get the internal widget id from block. 1616 * 1617 * @typedef {Object} Attributes 1618 * @property {string} __internalWidgetId The internal widget id. 1619 * @typedef {Object} Block 1620 * @property {Attributes} attributes The attributes of the block. 1621 * 1622 * @param {Block} block The block. 1623 * @return {string} The internal widget id. 1624 */ 1625 function getWidgetIdFromBlock(block) { 1626 return block.attributes.__internalWidgetId; 1627 } 1628 1629 /** 1630 * Add internal widget id to block's attributes. 1631 * 1632 * @param {Block} block The block. 1633 * @param {string} widgetId The widget id. 1634 * @return {Block} The updated block. 1635 */ 1636 function addWidgetIdToBlock(block, widgetId) { 1637 return { 1638 ...block, 1639 attributes: { 1640 ...(block.attributes || {}), 1641 __internalWidgetId: widgetId 1642 } 1643 }; 1644 } 1645 1646 ;// ./node_modules/@wordpress/widgets/build-module/register-legacy-widget-variations.js 1647 /** 1648 * WordPress dependencies 1649 */ 1650 1651 1652 1653 function registerLegacyWidgetVariations(settings) { 1654 const unsubscribe = (0,external_wp_data_namespaceObject.subscribe)(() => { 1655 var _settings$widgetTypes; 1656 const hiddenIds = (_settings$widgetTypes = settings?.widgetTypesToHideFromLegacyWidgetBlock) !== null && _settings$widgetTypes !== void 0 ? _settings$widgetTypes : []; 1657 const widgetTypes = (0,external_wp_data_namespaceObject.select)(external_wp_coreData_namespaceObject.store).getWidgetTypes({ 1658 per_page: -1 1659 })?.filter(widgetType => !hiddenIds.includes(widgetType.id)); 1660 if (widgetTypes) { 1661 unsubscribe(); 1662 (0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).addBlockVariations('core/legacy-widget', widgetTypes.map(widgetType => ({ 1663 name: widgetType.id, 1664 title: widgetType.name, 1665 description: widgetType.description, 1666 attributes: widgetType.is_multi ? { 1667 idBase: widgetType.id, 1668 instance: {} 1669 } : { 1670 id: widgetType.id 1671 } 1672 }))); 1673 } 1674 }); 1675 } 1676 1677 ;// ./node_modules/@wordpress/widgets/build-module/index.js 1678 /** 1679 * WordPress dependencies 1680 */ 1681 1682 1683 /** 1684 * Internal dependencies 1685 */ 1686 1687 1688 1689 1690 1691 /** 1692 * Registers the Legacy Widget block. 1693 * 1694 * Note that for the block to be useful, any scripts required by a widget must 1695 * be loaded into the page. 1696 * 1697 * @param {Object} supports Block support settings. 1698 * @see https://developer.wordpress.org/block-editor/how-to-guides/widgets/legacy-widget-block/ 1699 */ 1700 function registerLegacyWidgetBlock(supports = {}) { 1701 const { 1702 /* metadata */ "yu": metadata, 1703 /* settings */ "W0": settings, 1704 /* name */ "UU": name 1705 } = legacy_widget_namespaceObject; 1706 (0,external_wp_blocks_namespaceObject.registerBlockType)({ 1707 name, 1708 ...metadata 1709 }, { 1710 ...settings, 1711 supports: { 1712 ...settings.supports, 1713 ...supports 1714 } 1715 }); 1716 } 1717 1718 /** 1719 * Registers the Widget Group block. 1720 * 1721 * @param {Object} supports Block support settings. 1722 */ 1723 function registerWidgetGroupBlock(supports = {}) { 1724 const { 1725 /* metadata */ "yu": metadata, 1726 /* settings */ "W0": settings, 1727 /* name */ "UU": name 1728 } = widget_group_namespaceObject; 1729 (0,external_wp_blocks_namespaceObject.registerBlockType)({ 1730 name, 1731 ...metadata 1732 }, { 1733 ...settings, 1734 supports: { 1735 ...settings.supports, 1736 ...supports 1737 } 1738 }); 1739 } 1740 1741 1742 (window.wp = window.wp || {}).widgets = __webpack_exports__; 1743 /******/ })() 1744 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Dec 21 08:20:01 2024 | Cross-referenced by PHPXref |