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