[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 this["wp"] = this["wp"] || {}; this["wp"]["shortcode"] = 2 /******/ (function(modules) { // webpackBootstrap 3 /******/ // The module cache 4 /******/ var installedModules = {}; 5 /******/ 6 /******/ // The require function 7 /******/ function __webpack_require__(moduleId) { 8 /******/ 9 /******/ // Check if module is in cache 10 /******/ if(installedModules[moduleId]) { 11 /******/ return installedModules[moduleId].exports; 12 /******/ } 13 /******/ // Create a new module (and put it into the cache) 14 /******/ var module = installedModules[moduleId] = { 15 /******/ i: moduleId, 16 /******/ l: false, 17 /******/ exports: {} 18 /******/ }; 19 /******/ 20 /******/ // Execute the module function 21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 22 /******/ 23 /******/ // Flag the module as loaded 24 /******/ module.l = true; 25 /******/ 26 /******/ // Return the exports of the module 27 /******/ return module.exports; 28 /******/ } 29 /******/ 30 /******/ 31 /******/ // expose the modules object (__webpack_modules__) 32 /******/ __webpack_require__.m = modules; 33 /******/ 34 /******/ // expose the module cache 35 /******/ __webpack_require__.c = installedModules; 36 /******/ 37 /******/ // define getter function for harmony exports 38 /******/ __webpack_require__.d = function(exports, name, getter) { 39 /******/ if(!__webpack_require__.o(exports, name)) { 40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 41 /******/ } 42 /******/ }; 43 /******/ 44 /******/ // define __esModule on exports 45 /******/ __webpack_require__.r = function(exports) { 46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 48 /******/ } 49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 50 /******/ }; 51 /******/ 52 /******/ // create a fake namespace object 53 /******/ // mode & 1: value is a module id, require it 54 /******/ // mode & 2: merge all properties of value into the ns 55 /******/ // mode & 4: return value when already ns object 56 /******/ // mode & 8|1: behave like require 57 /******/ __webpack_require__.t = function(value, mode) { 58 /******/ if(mode & 1) value = __webpack_require__(value); 59 /******/ if(mode & 8) return value; 60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 61 /******/ var ns = Object.create(null); 62 /******/ __webpack_require__.r(ns); 63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 65 /******/ return ns; 66 /******/ }; 67 /******/ 68 /******/ // getDefaultExport function for compatibility with non-harmony modules 69 /******/ __webpack_require__.n = function(module) { 70 /******/ var getter = module && module.__esModule ? 71 /******/ function getDefault() { return module['default']; } : 72 /******/ function getModuleExports() { return module; }; 73 /******/ __webpack_require__.d(getter, 'a', getter); 74 /******/ return getter; 75 /******/ }; 76 /******/ 77 /******/ // Object.prototype.hasOwnProperty.call 78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 79 /******/ 80 /******/ // __webpack_public_path__ 81 /******/ __webpack_require__.p = ""; 82 /******/ 83 /******/ 84 /******/ // Load entry module and return exports 85 /******/ return __webpack_require__(__webpack_require__.s = 452); 86 /******/ }) 87 /************************************************************************/ 88 /******/ ({ 89 90 /***/ 2: 91 /***/ (function(module, exports) { 92 93 (function() { module.exports = window["lodash"]; }()); 94 95 /***/ }), 96 97 /***/ 452: 98 /***/ (function(module, __webpack_exports__, __webpack_require__) { 99 100 "use strict"; 101 __webpack_require__.r(__webpack_exports__); 102 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "next", function() { return next; }); 103 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "replace", function() { return replace; }); 104 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "string", function() { return string; }); 105 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "regexp", function() { return regexp; }); 106 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "attrs", function() { return attrs; }); 107 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromMatch", function() { return fromMatch; }); 108 /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); 109 /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_0__); 110 /* harmony import */ var memize__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71); 111 /* harmony import */ var memize__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(memize__WEBPACK_IMPORTED_MODULE_1__); 112 /** 113 * External dependencies 114 */ 115 116 117 /** 118 * Shortcode attributes object. 119 * 120 * @typedef {Object} WPShortcodeAttrs 121 * 122 * @property {Object} named Object with named attributes. 123 * @property {Array} numeric Array with numeric attributes. 124 */ 125 126 /** 127 * Shortcode object. 128 * 129 * @typedef {Object} WPShortcode 130 * 131 * @property {string} tag Shortcode tag. 132 * @property {WPShortcodeAttrs} attrs Shortcode attributes. 133 * @property {string} content Shortcode content. 134 * @property {string} type Shortcode type: `self-closing`, 135 * `closed`, or `single`. 136 */ 137 138 /** 139 * @typedef {Object} WPShortcodeMatch 140 * 141 * @property {number} index Index the shortcode is found at. 142 * @property {string} content Matched content. 143 * @property {WPShortcode} shortcode Shortcode instance of the match. 144 */ 145 146 /** 147 * Find the next matching shortcode. 148 * 149 * @param {string} tag Shortcode tag. 150 * @param {string} text Text to search. 151 * @param {number} index Index to start search from. 152 * 153 * @return {?WPShortcodeMatch} Matched information. 154 */ 155 156 function next(tag, text) { 157 var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; 158 var re = regexp(tag); 159 re.lastIndex = index; 160 var match = re.exec(text); 161 162 if (!match) { 163 return; 164 } // If we matched an escaped shortcode, try again. 165 166 167 if ('[' === match[1] && ']' === match[7]) { 168 return next(tag, text, re.lastIndex); 169 } 170 171 var result = { 172 index: match.index, 173 content: match[0], 174 shortcode: fromMatch(match) 175 }; // If we matched a leading `[`, strip it from the match and increment the 176 // index accordingly. 177 178 if (match[1]) { 179 result.content = result.content.slice(1); 180 result.index++; 181 } // If we matched a trailing `]`, strip it from the match. 182 183 184 if (match[7]) { 185 result.content = result.content.slice(0, -1); 186 } 187 188 return result; 189 } 190 /** 191 * Replace matching shortcodes in a block of text. 192 * 193 * @param {string} tag Shortcode tag. 194 * @param {string} text Text to search. 195 * @param {Function} callback Function to process the match and return 196 * replacement string. 197 * 198 * @return {string} Text with shortcodes replaced. 199 */ 200 201 function replace(tag, text, callback) { 202 return text.replace(regexp(tag), function (match, left, $3, attrs, slash, content, closing, right) { 203 // If both extra brackets exist, the shortcode has been properly 204 // escaped. 205 if (left === '[' && right === ']') { 206 return match; 207 } // Create the match object and pass it through the callback. 208 209 210 var result = callback(fromMatch(arguments)); // Make sure to return any of the extra brackets if they weren't used to 211 // escape the shortcode. 212 213 return result || result === '' ? left + result + right : match; 214 }); 215 } 216 /** 217 * Generate a string from shortcode parameters. 218 * 219 * Creates a shortcode instance and returns a string. 220 * 221 * Accepts the same `options` as the `shortcode()` constructor, containing a 222 * `tag` string, a string or object of `attrs`, a boolean indicating whether to 223 * format the shortcode using a `single` tag, and a `content` string. 224 * 225 * @param {Object} options 226 * 227 * @return {string} String representation of the shortcode. 228 */ 229 230 function string(options) { 231 return new shortcode(options).string(); 232 } 233 /** 234 * Generate a RegExp to identify a shortcode. 235 * 236 * The base regex is functionally equivalent to the one found in 237 * `get_shortcode_regex()` in `wp-includes/shortcodes.php`. 238 * 239 * Capture groups: 240 * 241 * 1. An extra `[` to allow for escaping shortcodes with double `[[]]` 242 * 2. The shortcode name 243 * 3. The shortcode argument list 244 * 4. The self closing `/` 245 * 5. The content of a shortcode when it wraps some content. 246 * 6. The closing tag. 247 * 7. An extra `]` to allow for escaping shortcodes with double `[[]]` 248 * 249 * @param {string} tag Shortcode tag. 250 * 251 * @return {RegExp} Shortcode RegExp. 252 */ 253 254 function regexp(tag) { 255 return new RegExp('\\[(\\[?)(' + tag + ')(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)', 'g'); 256 } 257 /** 258 * Parse shortcode attributes. 259 * 260 * Shortcodes accept many types of attributes. These can chiefly be divided into 261 * named and numeric attributes: 262 * 263 * Named attributes are assigned on a key/value basis, while numeric attributes 264 * are treated as an array. 265 * 266 * Named attributes can be formatted as either `name="value"`, `name='value'`, 267 * or `name=value`. Numeric attributes can be formatted as `"value"` or just 268 * `value`. 269 * 270 * @param {string} text Serialised shortcode attributes. 271 * 272 * @return {WPShortcodeAttrs} Parsed shortcode attributes. 273 */ 274 275 var attrs = memize__WEBPACK_IMPORTED_MODULE_1___default()(function (text) { 276 var named = {}; 277 var numeric = []; // This regular expression is reused from `shortcode_parse_atts()` in 278 // `wp-includes/shortcodes.php`. 279 // 280 // Capture groups: 281 // 282 // 1. An attribute name, that corresponds to... 283 // 2. a value in double quotes. 284 // 3. An attribute name, that corresponds to... 285 // 4. a value in single quotes. 286 // 5. An attribute name, that corresponds to... 287 // 6. an unquoted value. 288 // 7. A numeric attribute in double quotes. 289 // 8. A numeric attribute in single quotes. 290 // 9. An unquoted numeric attribute. 291 292 var pattern = /([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*'([^']*)'(?:\s|$)|([\w-]+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|'([^']*)'(?:\s|$)|(\S+)(?:\s|$)/g; // Map zero-width spaces to actual spaces. 293 294 text = text.replace(/[\u00a0\u200b]/g, ' '); 295 var match; // Match and normalize attributes. 296 297 while (match = pattern.exec(text)) { 298 if (match[1]) { 299 named[match[1].toLowerCase()] = match[2]; 300 } else if (match[3]) { 301 named[match[3].toLowerCase()] = match[4]; 302 } else if (match[5]) { 303 named[match[5].toLowerCase()] = match[6]; 304 } else if (match[7]) { 305 numeric.push(match[7]); 306 } else if (match[8]) { 307 numeric.push(match[8]); 308 } else if (match[9]) { 309 numeric.push(match[9]); 310 } 311 } 312 313 return { 314 named: named, 315 numeric: numeric 316 }; 317 }); 318 /** 319 * Generate a Shortcode Object from a RegExp match. 320 * 321 * Accepts a `match` object from calling `regexp.exec()` on a `RegExp` generated 322 * by `regexp()`. `match` can also be set to the `arguments` from a callback 323 * passed to `regexp.replace()`. 324 * 325 * @param {Array} match Match array. 326 * 327 * @return {WPShortcode} Shortcode instance. 328 */ 329 330 function fromMatch(match) { 331 var type; 332 333 if (match[4]) { 334 type = 'self-closing'; 335 } else if (match[6]) { 336 type = 'closed'; 337 } else { 338 type = 'single'; 339 } 340 341 return new shortcode({ 342 tag: match[2], 343 attrs: match[3], 344 type: type, 345 content: match[5] 346 }); 347 } 348 /** 349 * Creates a shortcode instance. 350 * 351 * To access a raw representation of a shortcode, pass an `options` object, 352 * containing a `tag` string, a string or object of `attrs`, a string indicating 353 * the `type` of the shortcode ('single', 'self-closing', or 'closed'), and a 354 * `content` string. 355 * 356 * @param {Object} options Options as described. 357 * 358 * @return {WPShortcode} Shortcode instance. 359 */ 360 361 var shortcode = Object(lodash__WEBPACK_IMPORTED_MODULE_0__["extend"])(function (options) { 362 var _this = this; 363 364 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["extend"])(this, Object(lodash__WEBPACK_IMPORTED_MODULE_0__["pick"])(options || {}, 'tag', 'attrs', 'type', 'content')); 365 var attributes = this.attrs; // Ensure we have a correctly formatted `attrs` object. 366 367 this.attrs = { 368 named: {}, 369 numeric: [] 370 }; 371 372 if (!attributes) { 373 return; 374 } // Parse a string of attributes. 375 376 377 if (Object(lodash__WEBPACK_IMPORTED_MODULE_0__["isString"])(attributes)) { 378 this.attrs = attrs(attributes); // Identify a correctly formatted `attrs` object. 379 } else if (Object(lodash__WEBPACK_IMPORTED_MODULE_0__["isEqual"])(Object.keys(attributes), ['named', 'numeric'])) { 380 this.attrs = attributes; // Handle a flat object of attributes. 381 } else { 382 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["forEach"])(attributes, function (value, key) { 383 _this.set(key, value); 384 }); 385 } 386 }, { 387 next: next, 388 replace: replace, 389 string: string, 390 regexp: regexp, 391 attrs: attrs, 392 fromMatch: fromMatch 393 }); 394 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["extend"])(shortcode.prototype, { 395 /** 396 * Get a shortcode attribute. 397 * 398 * Automatically detects whether `attr` is named or numeric and routes it 399 * accordingly. 400 * 401 * @param {(number|string)} attr Attribute key. 402 * 403 * @return {string} Attribute value. 404 */ 405 get: function get(attr) { 406 return this.attrs[Object(lodash__WEBPACK_IMPORTED_MODULE_0__["isNumber"])(attr) ? 'numeric' : 'named'][attr]; 407 }, 408 409 /** 410 * Set a shortcode attribute. 411 * 412 * Automatically detects whether `attr` is named or numeric and routes it 413 * accordingly. 414 * 415 * @param {(number|string)} attr Attribute key. 416 * @param {string} value Attribute value. 417 * 418 * @return {WPShortcode} Shortcode instance. 419 */ 420 set: function set(attr, value) { 421 this.attrs[Object(lodash__WEBPACK_IMPORTED_MODULE_0__["isNumber"])(attr) ? 'numeric' : 'named'][attr] = value; 422 return this; 423 }, 424 425 /** 426 * Transform the shortcode into a string. 427 * 428 * @return {string} String representation of the shortcode. 429 */ 430 string: function string() { 431 var text = '[' + this.tag; 432 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["forEach"])(this.attrs.numeric, function (value) { 433 if (/\s/.test(value)) { 434 text += ' "' + value + '"'; 435 } else { 436 text += ' ' + value; 437 } 438 }); 439 Object(lodash__WEBPACK_IMPORTED_MODULE_0__["forEach"])(this.attrs.named, function (value, name) { 440 text += ' ' + name + '="' + value + '"'; 441 }); // If the tag is marked as `single` or `self-closing`, close the tag and 442 // ignore any additional content. 443 444 if ('single' === this.type) { 445 return text + ']'; 446 } else if ('self-closing' === this.type) { 447 return text + ' /]'; 448 } // Complete the opening tag. 449 450 451 text += ']'; 452 453 if (this.content) { 454 text += this.content; 455 } // Add the closing tag. 456 457 458 return text + '[/' + this.tag + ']'; 459 } 460 }); 461 /* harmony default export */ __webpack_exports__["default"] = (shortcode); 462 463 464 /***/ }), 465 466 /***/ 71: 467 /***/ (function(module, exports, __webpack_require__) { 468 469 /** 470 * Memize options object. 471 * 472 * @typedef MemizeOptions 473 * 474 * @property {number} [maxSize] Maximum size of the cache. 475 */ 476 477 /** 478 * Internal cache entry. 479 * 480 * @typedef MemizeCacheNode 481 * 482 * @property {?MemizeCacheNode|undefined} [prev] Previous node. 483 * @property {?MemizeCacheNode|undefined} [next] Next node. 484 * @property {Array<*>} args Function arguments for cache 485 * entry. 486 * @property {*} val Function result. 487 */ 488 489 /** 490 * Properties of the enhanced function for controlling cache. 491 * 492 * @typedef MemizeMemoizedFunction 493 * 494 * @property {()=>void} clear Clear the cache. 495 */ 496 497 /** 498 * Accepts a function to be memoized, and returns a new memoized function, with 499 * optional options. 500 * 501 * @template {Function} F 502 * 503 * @param {F} fn Function to memoize. 504 * @param {MemizeOptions} [options] Options object. 505 * 506 * @return {F & MemizeMemoizedFunction} Memoized function. 507 */ 508 function memize( fn, options ) { 509 var size = 0; 510 511 /** @type {?MemizeCacheNode|undefined} */ 512 var head; 513 514 /** @type {?MemizeCacheNode|undefined} */ 515 var tail; 516 517 options = options || {}; 518 519 function memoized( /* ...args */ ) { 520 var node = head, 521 len = arguments.length, 522 args, i; 523 524 searchCache: while ( node ) { 525 // Perform a shallow equality test to confirm that whether the node 526 // under test is a candidate for the arguments passed. Two arrays 527 // are shallowly equal if their length matches and each entry is 528 // strictly equal between the two sets. Avoid abstracting to a 529 // function which could incur an arguments leaking deoptimization. 530 531 // Check whether node arguments match arguments length 532 if ( node.args.length !== arguments.length ) { 533 node = node.next; 534 continue; 535 } 536 537 // Check whether node arguments match arguments values 538 for ( i = 0; i < len; i++ ) { 539 if ( node.args[ i ] !== arguments[ i ] ) { 540 node = node.next; 541 continue searchCache; 542 } 543 } 544 545 // At this point we can assume we've found a match 546 547 // Surface matched node to head if not already 548 if ( node !== head ) { 549 // As tail, shift to previous. Must only shift if not also 550 // head, since if both head and tail, there is no previous. 551 if ( node === tail ) { 552 tail = node.prev; 553 } 554 555 // Adjust siblings to point to each other. If node was tail, 556 // this also handles new tail's empty `next` assignment. 557 /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next; 558 if ( node.next ) { 559 node.next.prev = node.prev; 560 } 561 562 node.next = head; 563 node.prev = null; 564 /** @type {MemizeCacheNode} */ ( head ).prev = node; 565 head = node; 566 } 567 568 // Return immediately 569 return node.val; 570 } 571 572 // No cached value found. Continue to insertion phase: 573 574 // Create a copy of arguments (avoid leaking deoptimization) 575 args = new Array( len ); 576 for ( i = 0; i < len; i++ ) { 577 args[ i ] = arguments[ i ]; 578 } 579 580 node = { 581 args: args, 582 583 // Generate the result from original function 584 val: fn.apply( null, args ), 585 }; 586 587 // Don't need to check whether node is already head, since it would 588 // have been returned above already if it was 589 590 // Shift existing head down list 591 if ( head ) { 592 head.prev = node; 593 node.next = head; 594 } else { 595 // If no head, follows that there's no tail (at initial or reset) 596 tail = node; 597 } 598 599 // Trim tail if we're reached max size and are pending cache insertion 600 if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) { 601 tail = /** @type {MemizeCacheNode} */ ( tail ).prev; 602 /** @type {MemizeCacheNode} */ ( tail ).next = null; 603 } else { 604 size++; 605 } 606 607 head = node; 608 609 return node.val; 610 } 611 612 memoized.clear = function() { 613 head = null; 614 tail = null; 615 size = 0; 616 }; 617 618 if ( false ) {} 619 620 // Ignore reason: There's not a clear solution to create an intersection of 621 // the function with additional properties, where the goal is to retain the 622 // function signature of the incoming argument and add control properties 623 // on the return value. 624 625 // @ts-ignore 626 return memoized; 627 } 628 629 module.exports = memize; 630 631 632 /***/ }) 633 634 /******/ })["default"];
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Mar 4 01:00:04 2021 | Cross-referenced by PHPXref 0.7.1 |