19
|
1 |
/******/ (function() { // webpackBootstrap |
|
2 |
/******/ var __webpack_modules__ = ({ |
9
|
3 |
|
19
|
4 |
/***/ 9756: |
|
5 |
/***/ (function(module) { |
9
|
6 |
|
18
|
7 |
/** |
|
8 |
* Memize options object. |
|
9 |
* |
|
10 |
* @typedef MemizeOptions |
|
11 |
* |
|
12 |
* @property {number} [maxSize] Maximum size of the cache. |
|
13 |
*/ |
9
|
14 |
|
18
|
15 |
/** |
|
16 |
* Internal cache entry. |
|
17 |
* |
|
18 |
* @typedef MemizeCacheNode |
|
19 |
* |
|
20 |
* @property {?MemizeCacheNode|undefined} [prev] Previous node. |
|
21 |
* @property {?MemizeCacheNode|undefined} [next] Next node. |
|
22 |
* @property {Array<*>} args Function arguments for cache |
|
23 |
* entry. |
|
24 |
* @property {*} val Function result. |
|
25 |
*/ |
9
|
26 |
|
18
|
27 |
/** |
|
28 |
* Properties of the enhanced function for controlling cache. |
|
29 |
* |
|
30 |
* @typedef MemizeMemoizedFunction |
|
31 |
* |
|
32 |
* @property {()=>void} clear Clear the cache. |
|
33 |
*/ |
16
|
34 |
|
18
|
35 |
/** |
|
36 |
* Accepts a function to be memoized, and returns a new memoized function, with |
|
37 |
* optional options. |
|
38 |
* |
|
39 |
* @template {Function} F |
|
40 |
* |
|
41 |
* @param {F} fn Function to memoize. |
|
42 |
* @param {MemizeOptions} [options] Options object. |
|
43 |
* |
|
44 |
* @return {F & MemizeMemoizedFunction} Memoized function. |
|
45 |
*/ |
|
46 |
function memize( fn, options ) { |
|
47 |
var size = 0; |
9
|
48 |
|
18
|
49 |
/** @type {?MemizeCacheNode|undefined} */ |
|
50 |
var head; |
9
|
51 |
|
18
|
52 |
/** @type {?MemizeCacheNode|undefined} */ |
|
53 |
var tail; |
|
54 |
|
|
55 |
options = options || {}; |
9
|
56 |
|
18
|
57 |
function memoized( /* ...args */ ) { |
|
58 |
var node = head, |
|
59 |
len = arguments.length, |
|
60 |
args, i; |
|
61 |
|
|
62 |
searchCache: while ( node ) { |
|
63 |
// Perform a shallow equality test to confirm that whether the node |
|
64 |
// under test is a candidate for the arguments passed. Two arrays |
|
65 |
// are shallowly equal if their length matches and each entry is |
|
66 |
// strictly equal between the two sets. Avoid abstracting to a |
|
67 |
// function which could incur an arguments leaking deoptimization. |
9
|
68 |
|
18
|
69 |
// Check whether node arguments match arguments length |
|
70 |
if ( node.args.length !== arguments.length ) { |
|
71 |
node = node.next; |
|
72 |
continue; |
|
73 |
} |
|
74 |
|
|
75 |
// Check whether node arguments match arguments values |
|
76 |
for ( i = 0; i < len; i++ ) { |
|
77 |
if ( node.args[ i ] !== arguments[ i ] ) { |
|
78 |
node = node.next; |
|
79 |
continue searchCache; |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
83 |
// At this point we can assume we've found a match |
9
|
84 |
|
18
|
85 |
// Surface matched node to head if not already |
|
86 |
if ( node !== head ) { |
|
87 |
// As tail, shift to previous. Must only shift if not also |
|
88 |
// head, since if both head and tail, there is no previous. |
|
89 |
if ( node === tail ) { |
|
90 |
tail = node.prev; |
|
91 |
} |
|
92 |
|
|
93 |
// Adjust siblings to point to each other. If node was tail, |
|
94 |
// this also handles new tail's empty `next` assignment. |
|
95 |
/** @type {MemizeCacheNode} */ ( node.prev ).next = node.next; |
|
96 |
if ( node.next ) { |
|
97 |
node.next.prev = node.prev; |
|
98 |
} |
9
|
99 |
|
18
|
100 |
node.next = head; |
|
101 |
node.prev = null; |
|
102 |
/** @type {MemizeCacheNode} */ ( head ).prev = node; |
|
103 |
head = node; |
|
104 |
} |
|
105 |
|
|
106 |
// Return immediately |
|
107 |
return node.val; |
|
108 |
} |
|
109 |
|
|
110 |
// No cached value found. Continue to insertion phase: |
|
111 |
|
|
112 |
// Create a copy of arguments (avoid leaking deoptimization) |
|
113 |
args = new Array( len ); |
|
114 |
for ( i = 0; i < len; i++ ) { |
|
115 |
args[ i ] = arguments[ i ]; |
|
116 |
} |
|
117 |
|
|
118 |
node = { |
|
119 |
args: args, |
|
120 |
|
|
121 |
// Generate the result from original function |
|
122 |
val: fn.apply( null, args ), |
|
123 |
}; |
16
|
124 |
|
18
|
125 |
// Don't need to check whether node is already head, since it would |
|
126 |
// have been returned above already if it was |
16
|
127 |
|
18
|
128 |
// Shift existing head down list |
|
129 |
if ( head ) { |
|
130 |
head.prev = node; |
|
131 |
node.next = head; |
|
132 |
} else { |
|
133 |
// If no head, follows that there's no tail (at initial or reset) |
|
134 |
tail = node; |
|
135 |
} |
16
|
136 |
|
18
|
137 |
// Trim tail if we're reached max size and are pending cache insertion |
|
138 |
if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) { |
|
139 |
tail = /** @type {MemizeCacheNode} */ ( tail ).prev; |
|
140 |
/** @type {MemizeCacheNode} */ ( tail ).next = null; |
|
141 |
} else { |
|
142 |
size++; |
|
143 |
} |
16
|
144 |
|
18
|
145 |
head = node; |
16
|
146 |
|
18
|
147 |
return node.val; |
|
148 |
} |
16
|
149 |
|
18
|
150 |
memoized.clear = function() { |
|
151 |
head = null; |
|
152 |
tail = null; |
|
153 |
size = 0; |
|
154 |
}; |
|
155 |
|
|
156 |
if ( false ) {} |
|
157 |
|
|
158 |
// Ignore reason: There's not a clear solution to create an intersection of |
|
159 |
// the function with additional properties, where the goal is to retain the |
|
160 |
// function signature of the incoming argument and add control properties |
|
161 |
// on the return value. |
|
162 |
|
|
163 |
// @ts-ignore |
|
164 |
return memoized; |
16
|
165 |
} |
|
166 |
|
18
|
167 |
module.exports = memize; |
16
|
168 |
|
|
169 |
|
19
|
170 |
/***/ }) |
18
|
171 |
|
19
|
172 |
/******/ }); |
|
173 |
/************************************************************************/ |
|
174 |
/******/ // The module cache |
|
175 |
/******/ var __webpack_module_cache__ = {}; |
|
176 |
/******/ |
|
177 |
/******/ // The require function |
|
178 |
/******/ function __webpack_require__(moduleId) { |
|
179 |
/******/ // Check if module is in cache |
|
180 |
/******/ var cachedModule = __webpack_module_cache__[moduleId]; |
|
181 |
/******/ if (cachedModule !== undefined) { |
|
182 |
/******/ return cachedModule.exports; |
|
183 |
/******/ } |
|
184 |
/******/ // Create a new module (and put it into the cache) |
|
185 |
/******/ var module = __webpack_module_cache__[moduleId] = { |
|
186 |
/******/ // no module.id needed |
|
187 |
/******/ // no module.loaded needed |
|
188 |
/******/ exports: {} |
|
189 |
/******/ }; |
|
190 |
/******/ |
|
191 |
/******/ // Execute the module function |
|
192 |
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
|
193 |
/******/ |
|
194 |
/******/ // Return the exports of the module |
|
195 |
/******/ return module.exports; |
|
196 |
/******/ } |
|
197 |
/******/ |
|
198 |
/************************************************************************/ |
|
199 |
/******/ /* webpack/runtime/compat get default export */ |
|
200 |
/******/ !function() { |
|
201 |
/******/ // getDefaultExport function for compatibility with non-harmony modules |
|
202 |
/******/ __webpack_require__.n = function(module) { |
|
203 |
/******/ var getter = module && module.__esModule ? |
|
204 |
/******/ function() { return module['default']; } : |
|
205 |
/******/ function() { return module; }; |
|
206 |
/******/ __webpack_require__.d(getter, { a: getter }); |
|
207 |
/******/ return getter; |
|
208 |
/******/ }; |
|
209 |
/******/ }(); |
|
210 |
/******/ |
|
211 |
/******/ /* webpack/runtime/define property getters */ |
|
212 |
/******/ !function() { |
|
213 |
/******/ // define getter functions for harmony exports |
|
214 |
/******/ __webpack_require__.d = function(exports, definition) { |
|
215 |
/******/ for(var key in definition) { |
|
216 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
|
217 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
|
218 |
/******/ } |
|
219 |
/******/ } |
|
220 |
/******/ }; |
|
221 |
/******/ }(); |
|
222 |
/******/ |
|
223 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
|
224 |
/******/ !function() { |
|
225 |
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
|
226 |
/******/ }(); |
|
227 |
/******/ |
|
228 |
/******/ /* webpack/runtime/make namespace object */ |
|
229 |
/******/ !function() { |
|
230 |
/******/ // define __esModule on exports |
|
231 |
/******/ __webpack_require__.r = function(exports) { |
|
232 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
233 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
234 |
/******/ } |
|
235 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
236 |
/******/ }; |
|
237 |
/******/ }(); |
|
238 |
/******/ |
|
239 |
/************************************************************************/ |
|
240 |
var __webpack_exports__ = {}; |
|
241 |
// This entry need to be wrapped in an IIFE because it need to be in strict mode. |
|
242 |
!function() { |
9
|
243 |
"use strict"; |
16
|
244 |
// ESM COMPAT FLAG |
9
|
245 |
__webpack_require__.r(__webpack_exports__); |
|
246 |
|
16
|
247 |
// EXPORTS |
19
|
248 |
__webpack_require__.d(__webpack_exports__, { |
|
249 |
"PluginArea": function() { return /* reexport */ plugin_area; }, |
|
250 |
"getPlugin": function() { return /* reexport */ getPlugin; }, |
|
251 |
"getPlugins": function() { return /* reexport */ getPlugins; }, |
|
252 |
"registerPlugin": function() { return /* reexport */ registerPlugin; }, |
|
253 |
"unregisterPlugin": function() { return /* reexport */ unregisterPlugin; }, |
|
254 |
"withPluginContext": function() { return /* reexport */ withPluginContext; } |
|
255 |
}); |
16
|
256 |
|
19
|
257 |
;// CONCATENATED MODULE: external ["wp","element"] |
|
258 |
var external_wp_element_namespaceObject = window["wp"]["element"]; |
|
259 |
;// CONCATENATED MODULE: external "lodash" |
|
260 |
var external_lodash_namespaceObject = window["lodash"]; |
18
|
261 |
// EXTERNAL MODULE: ./node_modules/memize/index.js |
19
|
262 |
var memize = __webpack_require__(9756); |
18
|
263 |
var memize_default = /*#__PURE__*/__webpack_require__.n(memize); |
19
|
264 |
;// CONCATENATED MODULE: external ["wp","hooks"] |
|
265 |
var external_wp_hooks_namespaceObject = window["wp"]["hooks"]; |
|
266 |
;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
|
267 |
function _extends() { |
|
268 |
_extends = Object.assign ? Object.assign.bind() : function (target) { |
|
269 |
for (var i = 1; i < arguments.length; i++) { |
|
270 |
var source = arguments[i]; |
9
|
271 |
|
19
|
272 |
for (var key in source) { |
|
273 |
if (Object.prototype.hasOwnProperty.call(source, key)) { |
|
274 |
target[key] = source[key]; |
|
275 |
} |
|
276 |
} |
|
277 |
} |
9
|
278 |
|
19
|
279 |
return target; |
|
280 |
}; |
|
281 |
return _extends.apply(this, arguments); |
|
282 |
} |
|
283 |
;// CONCATENATED MODULE: external ["wp","compose"] |
|
284 |
var external_wp_compose_namespaceObject = window["wp"]["compose"]; |
|
285 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/components/plugin-context/index.js |
9
|
286 |
|
|
287 |
|
|
288 |
|
|
289 |
/** |
|
290 |
* WordPress dependencies |
|
291 |
*/ |
|
292 |
|
|
293 |
|
18
|
294 |
const { |
|
295 |
Consumer, |
|
296 |
Provider |
19
|
297 |
} = (0,external_wp_element_namespaceObject.createContext)({ |
9
|
298 |
name: null, |
|
299 |
icon: null |
18
|
300 |
}); |
9
|
301 |
|
|
302 |
/** |
|
303 |
* A Higher Order Component used to inject Plugin context to the |
|
304 |
* wrapped component. |
|
305 |
* |
|
306 |
* @param {Function} mapContextToProps Function called on every context change, |
|
307 |
* expected to return object of props to |
|
308 |
* merge with the component's own props. |
|
309 |
* |
16
|
310 |
* @return {WPComponent} Enhanced component with injected context as props. |
9
|
311 |
*/ |
|
312 |
|
19
|
313 |
const withPluginContext = mapContextToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => { |
|
314 |
return props => (0,external_wp_element_namespaceObject.createElement)(Consumer, null, context => (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, _extends({}, props, mapContextToProps(context, props)))); |
18
|
315 |
}, 'withPluginContext'); |
|
316 |
|
19
|
317 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/components/plugin-error-boundary/index.js |
|
318 |
/** |
|
319 |
* WordPress dependencies |
|
320 |
*/ |
|
321 |
|
|
322 |
class PluginErrorBoundary extends external_wp_element_namespaceObject.Component { |
|
323 |
constructor(props) { |
|
324 |
super(props); |
|
325 |
this.state = { |
|
326 |
hasError: false |
|
327 |
}; |
|
328 |
} |
|
329 |
|
|
330 |
static getDerivedStateFromError() { |
|
331 |
return { |
|
332 |
hasError: true |
|
333 |
}; |
|
334 |
} |
18
|
335 |
|
19
|
336 |
componentDidCatch(error) { |
|
337 |
const { |
|
338 |
name, |
|
339 |
onError |
|
340 |
} = this.props; |
|
341 |
|
|
342 |
if (onError) { |
|
343 |
onError(name, error); |
|
344 |
} |
|
345 |
} |
|
346 |
|
|
347 |
render() { |
|
348 |
if (!this.state.hasError) { |
|
349 |
return this.props.children; |
|
350 |
} |
|
351 |
|
|
352 |
return null; |
|
353 |
} |
|
354 |
|
|
355 |
} |
|
356 |
|
|
357 |
;// CONCATENATED MODULE: external ["wp","primitives"] |
|
358 |
var external_wp_primitives_namespaceObject = window["wp"]["primitives"]; |
|
359 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plugins.js |
18
|
360 |
|
9
|
361 |
|
18
|
362 |
/** |
|
363 |
* WordPress dependencies |
|
364 |
*/ |
9
|
365 |
|
19
|
366 |
const plugins = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
18
|
367 |
xmlns: "http://www.w3.org/2000/svg", |
|
368 |
viewBox: "0 0 24 24" |
19
|
369 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
18
|
370 |
d: "M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z" |
|
371 |
})); |
|
372 |
/* harmony default export */ var library_plugins = (plugins); |
9
|
373 |
|
19
|
374 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/api/index.js |
9
|
375 |
/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */ |
|
376 |
|
|
377 |
/** |
|
378 |
* WordPress dependencies |
|
379 |
*/ |
|
380 |
|
16
|
381 |
|
9
|
382 |
/** |
|
383 |
* External dependencies |
|
384 |
*/ |
|
385 |
|
|
386 |
|
|
387 |
/** |
16
|
388 |
* Defined behavior of a plugin type. |
|
389 |
* |
|
390 |
* @typedef {Object} WPPlugin |
|
391 |
* |
18
|
392 |
* @property {string} name A string identifying the plugin. Must be |
|
393 |
* unique across all registered plugins. |
|
394 |
* @property {string|WPElement|Function} [icon] An icon to be shown in the UI. It can |
|
395 |
* be a slug of the Dashicon, or an element |
|
396 |
* (or function returning an element) if you |
|
397 |
* choose to render your own SVG. |
|
398 |
* @property {Function} render A component containing the UI elements |
|
399 |
* to be rendered. |
|
400 |
* @property {string} [scope] The optional scope to be used when rendering inside |
|
401 |
* a plugin area. No scope by default. |
16
|
402 |
*/ |
|
403 |
|
|
404 |
/** |
9
|
405 |
* Plugin definitions keyed by plugin name. |
|
406 |
* |
|
407 |
* @type {Object.<string,WPPlugin>} |
|
408 |
*/ |
|
409 |
|
18
|
410 |
const api_plugins = {}; |
9
|
411 |
/** |
|
412 |
* Registers a plugin to the editor. |
|
413 |
* |
16
|
414 |
* @param {string} name A string identifying the plugin.Must be |
|
415 |
* unique across all registered plugins. |
|
416 |
* @param {WPPlugin} settings The settings for this plugin. |
9
|
417 |
* |
16
|
418 |
* @example |
9
|
419 |
* ```js |
|
420 |
* // Using ES5 syntax |
|
421 |
* var el = wp.element.createElement; |
|
422 |
* var Fragment = wp.element.Fragment; |
|
423 |
* var PluginSidebar = wp.editPost.PluginSidebar; |
|
424 |
* var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem; |
|
425 |
* var registerPlugin = wp.plugins.registerPlugin; |
16
|
426 |
* var moreIcon = wp.element.createElement( 'svg' ); //... svg element. |
9
|
427 |
* |
|
428 |
* function Component() { |
|
429 |
* return el( |
|
430 |
* Fragment, |
|
431 |
* {}, |
|
432 |
* el( |
|
433 |
* PluginSidebarMoreMenuItem, |
|
434 |
* { |
|
435 |
* target: 'sidebar-name', |
|
436 |
* }, |
|
437 |
* 'My Sidebar' |
|
438 |
* ), |
|
439 |
* el( |
|
440 |
* PluginSidebar, |
|
441 |
* { |
|
442 |
* name: 'sidebar-name', |
|
443 |
* title: 'My Sidebar', |
|
444 |
* }, |
|
445 |
* 'Content of the sidebar' |
|
446 |
* ) |
|
447 |
* ); |
|
448 |
* } |
|
449 |
* registerPlugin( 'plugin-name', { |
16
|
450 |
* icon: moreIcon, |
9
|
451 |
* render: Component, |
18
|
452 |
* scope: 'my-page', |
9
|
453 |
* } ); |
|
454 |
* ``` |
|
455 |
* |
16
|
456 |
* @example |
9
|
457 |
* ```js |
|
458 |
* // Using ESNext syntax |
16
|
459 |
* import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/edit-post'; |
|
460 |
* import { registerPlugin } from '@wordpress/plugins'; |
|
461 |
* import { more } from '@wordpress/icons'; |
9
|
462 |
* |
|
463 |
* const Component = () => ( |
16
|
464 |
* <> |
9
|
465 |
* <PluginSidebarMoreMenuItem |
|
466 |
* target="sidebar-name" |
|
467 |
* > |
|
468 |
* My Sidebar |
|
469 |
* </PluginSidebarMoreMenuItem> |
|
470 |
* <PluginSidebar |
|
471 |
* name="sidebar-name" |
|
472 |
* title="My Sidebar" |
|
473 |
* > |
|
474 |
* Content of the sidebar |
|
475 |
* </PluginSidebar> |
16
|
476 |
* </> |
9
|
477 |
* ); |
|
478 |
* |
|
479 |
* registerPlugin( 'plugin-name', { |
16
|
480 |
* icon: more, |
9
|
481 |
* render: Component, |
18
|
482 |
* scope: 'my-page', |
9
|
483 |
* } ); |
|
484 |
* ``` |
|
485 |
* |
16
|
486 |
* @return {WPPlugin} The final plugin settings object. |
9
|
487 |
*/ |
|
488 |
|
|
489 |
function registerPlugin(name, settings) { |
18
|
490 |
if (typeof settings !== 'object') { |
9
|
491 |
console.error('No settings object provided!'); |
|
492 |
return null; |
|
493 |
} |
|
494 |
|
|
495 |
if (typeof name !== 'string') { |
18
|
496 |
console.error('Plugin name must be string.'); |
9
|
497 |
return null; |
|
498 |
} |
|
499 |
|
|
500 |
if (!/^[a-z][a-z0-9-]*$/.test(name)) { |
18
|
501 |
console.error('Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".'); |
9
|
502 |
return null; |
|
503 |
} |
|
504 |
|
16
|
505 |
if (api_plugins[name]) { |
18
|
506 |
console.error(`Plugin "${name}" is already registered.`); |
9
|
507 |
} |
|
508 |
|
19
|
509 |
settings = (0,external_wp_hooks_namespaceObject.applyFilters)('plugins.registerPlugin', settings, name); |
18
|
510 |
const { |
|
511 |
render, |
|
512 |
scope |
|
513 |
} = settings; |
9
|
514 |
|
19
|
515 |
if (!(0,external_lodash_namespaceObject.isFunction)(render)) { |
9
|
516 |
console.error('The "render" property must be specified and must be a valid function.'); |
|
517 |
return null; |
|
518 |
} |
|
519 |
|
18
|
520 |
if (scope) { |
|
521 |
if (typeof scope !== 'string') { |
|
522 |
console.error('Plugin scope must be string.'); |
|
523 |
return null; |
|
524 |
} |
|
525 |
|
|
526 |
if (!/^[a-z][a-z0-9-]*$/.test(scope)) { |
|
527 |
console.error('Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".'); |
|
528 |
return null; |
|
529 |
} |
|
530 |
} |
|
531 |
|
|
532 |
api_plugins[name] = { |
|
533 |
name, |
|
534 |
icon: library_plugins, |
|
535 |
...settings |
|
536 |
}; |
19
|
537 |
(0,external_wp_hooks_namespaceObject.doAction)('plugins.pluginRegistered', settings, name); |
9
|
538 |
return settings; |
|
539 |
} |
|
540 |
/** |
|
541 |
* Unregisters a plugin by name. |
|
542 |
* |
|
543 |
* @param {string} name Plugin name. |
|
544 |
* |
16
|
545 |
* @example |
9
|
546 |
* ```js |
|
547 |
* // Using ES5 syntax |
|
548 |
* var unregisterPlugin = wp.plugins.unregisterPlugin; |
|
549 |
* |
|
550 |
* unregisterPlugin( 'plugin-name' ); |
|
551 |
* ``` |
|
552 |
* |
16
|
553 |
* @example |
9
|
554 |
* ```js |
|
555 |
* // Using ESNext syntax |
16
|
556 |
* import { unregisterPlugin } from '@wordpress/plugins'; |
9
|
557 |
* |
|
558 |
* unregisterPlugin( 'plugin-name' ); |
|
559 |
* ``` |
|
560 |
* |
|
561 |
* @return {?WPPlugin} The previous plugin settings object, if it has been |
|
562 |
* successfully unregistered; otherwise `undefined`. |
|
563 |
*/ |
|
564 |
|
|
565 |
function unregisterPlugin(name) { |
16
|
566 |
if (!api_plugins[name]) { |
9
|
567 |
console.error('Plugin "' + name + '" is not registered.'); |
|
568 |
return; |
|
569 |
} |
|
570 |
|
18
|
571 |
const oldPlugin = api_plugins[name]; |
16
|
572 |
delete api_plugins[name]; |
19
|
573 |
(0,external_wp_hooks_namespaceObject.doAction)('plugins.pluginUnregistered', oldPlugin, name); |
9
|
574 |
return oldPlugin; |
|
575 |
} |
|
576 |
/** |
|
577 |
* Returns a registered plugin settings. |
|
578 |
* |
|
579 |
* @param {string} name Plugin name. |
|
580 |
* |
16
|
581 |
* @return {?WPPlugin} Plugin setting. |
9
|
582 |
*/ |
|
583 |
|
|
584 |
function getPlugin(name) { |
16
|
585 |
return api_plugins[name]; |
9
|
586 |
} |
|
587 |
/** |
18
|
588 |
* Returns all registered plugins without a scope or for a given scope. |
9
|
589 |
* |
18
|
590 |
* @param {string} [scope] The scope to be used when rendering inside |
|
591 |
* a plugin area. No scope by default. |
|
592 |
* |
|
593 |
* @return {WPPlugin[]} The list of plugins without a scope or for a given scope. |
9
|
594 |
*/ |
|
595 |
|
18
|
596 |
function getPlugins(scope) { |
|
597 |
return Object.values(api_plugins).filter(plugin => plugin.scope === scope); |
9
|
598 |
} |
|
599 |
|
19
|
600 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/components/plugin-area/index.js |
9
|
601 |
|
|
602 |
|
|
603 |
/** |
|
604 |
* External dependencies |
|
605 |
*/ |
|
606 |
|
18
|
607 |
|
9
|
608 |
/** |
|
609 |
* WordPress dependencies |
|
610 |
*/ |
|
611 |
|
|
612 |
|
|
613 |
|
|
614 |
/** |
|
615 |
* Internal dependencies |
|
616 |
*/ |
|
617 |
|
|
618 |
|
|
619 |
|
19
|
620 |
|
9
|
621 |
/** |
|
622 |
* A component that renders all plugin fills in a hidden div. |
|
623 |
* |
16
|
624 |
* @example |
9
|
625 |
* ```js |
|
626 |
* // Using ES5 syntax |
|
627 |
* var el = wp.element.createElement; |
|
628 |
* var PluginArea = wp.plugins.PluginArea; |
|
629 |
* |
|
630 |
* function Layout() { |
|
631 |
* return el( |
|
632 |
* 'div', |
18
|
633 |
* { scope: 'my-page' }, |
9
|
634 |
* 'Content of the page', |
|
635 |
* PluginArea |
|
636 |
* ); |
|
637 |
* } |
|
638 |
* ``` |
|
639 |
* |
16
|
640 |
* @example |
9
|
641 |
* ```js |
|
642 |
* // Using ESNext syntax |
16
|
643 |
* import { PluginArea } from '@wordpress/plugins'; |
9
|
644 |
* |
|
645 |
* const Layout = () => ( |
|
646 |
* <div> |
|
647 |
* Content of the page |
18
|
648 |
* <PluginArea scope="my-page" /> |
9
|
649 |
* </div> |
|
650 |
* ); |
|
651 |
* ``` |
|
652 |
* |
16
|
653 |
* @return {WPComponent} The component to be rendered. |
9
|
654 |
*/ |
|
655 |
|
19
|
656 |
class PluginArea extends external_wp_element_namespaceObject.Component { |
18
|
657 |
constructor() { |
|
658 |
super(...arguments); |
|
659 |
this.setPlugins = this.setPlugins.bind(this); |
|
660 |
this.memoizedContext = memize_default()((name, icon) => { |
|
661 |
return { |
|
662 |
name, |
|
663 |
icon |
|
664 |
}; |
|
665 |
}); |
|
666 |
this.state = this.getCurrentPluginsState(); |
|
667 |
} |
16
|
668 |
|
18
|
669 |
getCurrentPluginsState() { |
|
670 |
return { |
19
|
671 |
plugins: (0,external_lodash_namespaceObject.map)(getPlugins(this.props.scope), _ref => { |
|
672 |
let { |
|
673 |
icon, |
|
674 |
name, |
|
675 |
render |
|
676 |
} = _ref; |
18
|
677 |
return { |
|
678 |
Plugin: render, |
|
679 |
context: this.memoizedContext(name, icon) |
|
680 |
}; |
|
681 |
}) |
|
682 |
}; |
9
|
683 |
} |
|
684 |
|
18
|
685 |
componentDidMount() { |
19
|
686 |
(0,external_wp_hooks_namespaceObject.addAction)('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered', this.setPlugins); |
|
687 |
(0,external_wp_hooks_namespaceObject.addAction)('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered', this.setPlugins); |
18
|
688 |
} |
|
689 |
|
|
690 |
componentWillUnmount() { |
19
|
691 |
(0,external_wp_hooks_namespaceObject.removeAction)('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered'); |
|
692 |
(0,external_wp_hooks_namespaceObject.removeAction)('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered'); |
18
|
693 |
} |
|
694 |
|
|
695 |
setPlugins() { |
|
696 |
this.setState(this.getCurrentPluginsState); |
|
697 |
} |
9
|
698 |
|
18
|
699 |
render() { |
19
|
700 |
return (0,external_wp_element_namespaceObject.createElement)("div", { |
18
|
701 |
style: { |
|
702 |
display: 'none' |
|
703 |
} |
19
|
704 |
}, (0,external_lodash_namespaceObject.map)(this.state.plugins, _ref2 => { |
|
705 |
let { |
|
706 |
context, |
|
707 |
Plugin |
|
708 |
} = _ref2; |
|
709 |
return (0,external_wp_element_namespaceObject.createElement)(Provider, { |
|
710 |
key: context.name, |
|
711 |
value: context |
|
712 |
}, (0,external_wp_element_namespaceObject.createElement)(PluginErrorBoundary, { |
|
713 |
name: context.name, |
|
714 |
onError: this.props.onError |
|
715 |
}, (0,external_wp_element_namespaceObject.createElement)(Plugin, null))); |
|
716 |
})); |
18
|
717 |
} |
|
718 |
|
|
719 |
} |
9
|
720 |
|
19
|
721 |
/* harmony default export */ var plugin_area = (PluginArea); |
9
|
722 |
|
19
|
723 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/components/index.js |
9
|
724 |
|
|
725 |
|
|
726 |
|
19
|
727 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/index.js |
16
|
728 |
|
9
|
729 |
|
|
730 |
|
19
|
731 |
}(); |
|
732 |
(window.wp = window.wp || {}).plugins = __webpack_exports__; |
|
733 |
/******/ })() |
|
734 |
; |