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