@secretstache/wordpress-gutenberg 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +595 -585
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/helpers.js +20 -2
package/package.json
CHANGED
package/src/utils/helpers.js
CHANGED
@@ -234,7 +234,25 @@ export const getFiltersByNamespace = (namespace) => {
|
|
234
234
|
};
|
235
235
|
|
236
236
|
/**
|
237
|
-
*
|
237
|
+
* Allow a block for a specific post type
|
238
|
+
* @param {string} blockName - Name of the block to unregister
|
239
|
+
* @param {string} postType - Post type to check against
|
240
|
+
*/
|
241
|
+
export const setBlockForPostType = (blockName, postType) => {
|
242
|
+
const unsubscribe = subscribe(
|
243
|
+
() => {
|
244
|
+
const currentPostType = select('core/editor').getCurrentPostType();
|
245
|
+
if (currentPostType && currentPostType !== postType && getBlockType(blockName)) {
|
246
|
+
unregisterBlockType(blockName);
|
247
|
+
unsubscribe();
|
248
|
+
}
|
249
|
+
},
|
250
|
+
'core/editor',
|
251
|
+
);
|
252
|
+
};
|
253
|
+
|
254
|
+
/**
|
255
|
+
* Disallow a block for a specific post type
|
238
256
|
* @param {string} blockName - Name of the block to unregister
|
239
257
|
* @param {string} postType - Post type to check against
|
240
258
|
*/
|
@@ -242,7 +260,7 @@ export const unsetBlockForPostType = (blockName, postType) => {
|
|
242
260
|
const unsubscribe = subscribe(
|
243
261
|
() => {
|
244
262
|
const currentPostType = select('core/editor').getCurrentPostType();
|
245
|
-
if (currentPostType === postType && getBlockType(blockName)) {
|
263
|
+
if (currentPostType && currentPostType === postType && getBlockType(blockName)) {
|
246
264
|
unregisterBlockType(blockName);
|
247
265
|
unsubscribe();
|
248
266
|
}
|