@secretstache/wordpress-gutenberg 0.6.1 → 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 +1173 -1152
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/helpers.js +22 -4
package/package.json
CHANGED
package/src/utils/helpers.js
CHANGED
@@ -217,7 +217,7 @@ export const getSpacingClasses = (
|
|
217
217
|
* @param {string} namespace - Filter namespace to search for
|
218
218
|
* @returns {Array<{filterName: string, namespace: string}>} Array of matching filters
|
219
219
|
*/
|
220
|
-
const getFiltersByNamespace = (namespace) => {
|
220
|
+
export const getFiltersByNamespace = (namespace) => {
|
221
221
|
const list = [];
|
222
222
|
|
223
223
|
Object.entries(filters).forEach(([filterName, filterData]) => {
|
@@ -234,15 +234,33 @@ const getFiltersByNamespace = (namespace) => {
|
|
234
234
|
};
|
235
235
|
|
236
236
|
/**
|
237
|
-
*
|
237
|
+
* Allow a block for a specific post type
|
238
238
|
* @param {string} blockName - Name of the block to unregister
|
239
239
|
* @param {string} postType - Post type to check against
|
240
240
|
*/
|
241
|
-
const
|
241
|
+
export const setBlockForPostType = (blockName, postType) => {
|
242
242
|
const unsubscribe = subscribe(
|
243
243
|
() => {
|
244
244
|
const currentPostType = select('core/editor').getCurrentPostType();
|
245
|
-
if (currentPostType
|
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
|
256
|
+
* @param {string} blockName - Name of the block to unregister
|
257
|
+
* @param {string} postType - Post type to check against
|
258
|
+
*/
|
259
|
+
export const unsetBlockForPostType = (blockName, postType) => {
|
260
|
+
const unsubscribe = subscribe(
|
261
|
+
() => {
|
262
|
+
const currentPostType = select('core/editor').getCurrentPostType();
|
263
|
+
if (currentPostType && currentPostType === postType && getBlockType(blockName)) {
|
246
264
|
unregisterBlockType(blockName);
|
247
265
|
unsubscribe();
|
248
266
|
}
|