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