-
Notifications
You must be signed in to change notification settings - Fork 0
/
block-blocks.js
69 lines (62 loc) · 1.41 KB
/
block-blocks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* global wp */
const coreEmbedRemoveBlocks = [
'spotify',
'collegehumor',
'dailymotion',
'funnyordie',
'hulu',
'imgur',
'issuu',
'kickstarter',
'meetup-com',
'mixcloud',
'photobucket',
'polldaddy',
'reddit',
'reverbnation',
'screencast',
'scribd',
'smugmug',
'speaker',
'tumblr',
'videopress',
'vine',
'wordpress-tv',
'amazon-kindle'
]
const removeBlocks = [
'jetpack/mailchimp',
'jetpack/business-hours',
'jetpack/map',
'jetpack/gif',
'jetpack/recurring-payments',
'jetpack/calendly',
'jetpack/eventbrite',
'jetpack/revue',
'jetpack/opentable',
'jetpack/calendly',
'jetpack/amazon',
'jetpack/wordads',
'jetpack/pinterest',
'jetpack/send-a-message',
'coblocks/opentable'
]
const removeBlocksByNamespace = [
'bp'
]
wp.hooks.addFilter('blocks.registerBlockType', 'hideBlocks', (pSettings, pName) => {
if (removeBlocks.indexOf(pName) !== -1) {
return Object.assign({}, pSettings, {
supports: Object.assign({}, pSettings.supports, { inserter: false })
})
}
if (removeBlocksByNamespace.indexOf(pName.substr(0, pName.indexOf('/'))) !== -1) {
return Object.assign({}, pSettings, {
supports: Object.assign({}, pSettings.supports, { inserter: false })
})
}
if (pName === 'core/embed') {
pSettings.variations = pSettings.variations.filter((block) => coreEmbedRemoveBlocks.indexOf(block.name) === -1)
}
return pSettings
})