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