-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy patheditor.js
More file actions
97 lines (85 loc) · 2.91 KB
/
editor.js
File metadata and controls
97 lines (85 loc) · 2.91 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const ThemeNamespace = 'yournamespace'
/**
* Remove styles from blocks
*/
wp.hooks.addFilter(
'blocks.registerBlockType',
`${ThemeNamespace}/editor`,
function (settings, name) {
switch (name) {
// Image bock
case 'core/file': {
settings.attributes.showDownloadButton.default = false // Hide download button from file links
break
}
case 'core/video': {
settings.attributes.loop.default = true
settings.attributes.playsInline.default = true
settings.attributes.muted.default = true
settings.attributes.autoplay.default = true
settings.attributes.controls.default = false
}
case 'core/image': {
settings.styles = []
}
}
return settings
}
)
wp.domReady(function () {
/**
* Remove editor panels
*/
wp.data.dispatch('core/editor').removeEditorPanel('taxonomy-panel-post_tag')
wp.data.dispatch('core/editor').removeEditorPanel('page-attributes')
wp.data.dispatch('core/edit-post').removeEditorPanel('post-excerpt')
wp.data.dispatch('core/edit-post').removeEditorPanel('advanced')
/**
* Remove rich text formats from rich text blocks.
*/
wp.richText.unregisterFormatType('core/bold')
wp.richText.unregisterFormatType('core/code')
wp.richText.unregisterFormatType('core/image')
wp.richText.unregisterFormatType('core/italic')
wp.richText.unregisterFormatType('core/keyboard')
wp.richText.unregisterFormatType('core/link')
wp.richText.unregisterFormatType('core/math')
wp.richText.unregisterFormatType('core/strikethrough')
wp.richText.unregisterFormatType('core/subscript')
wp.richText.unregisterFormatType('core/superscript')
wp.richText.unregisterFormatType('core/text-color')
wp.richText.unregisterFormatType('core/underline')
})
/**
* Disable fullscreen mode
*/
wp.domReady(function () {
const isFullscreenMode = wp.data
.select('core/edit-post')
.isFeatureActive('fullscreenMode')
if (isFullscreenMode) {
wp.data.dispatch('core/edit-post').toggleFeature('fullscreenMode')
}
})
/**
* Unregister plugin features
*/
wp.domReady(function () {
// You can log the IDs registered plugins to see which you can remove
console.log(wp.plugins.getPlugins())
// Unregister jetpack plugins
wp.plugins.unregisterPlugin('jetpack-sidebar')
wp.plugins.unregisterPlugin('jetpack-social-previews')
wp.plugins.unregisterPlugin('jetpack-likes-and-sharing-panel')
// Unregister all embed blocks
wp.blocks.getBlockVariations('core/embed').forEach(function (blockVariation) {
wp.blocks.unregisterBlockVariation('core/embed', blockVariation.name)
})
// Unregister all embeds but the ones you want
const allowedEmbedBlocks = ['vimeo', 'youtube']
wp.blocks.getBlockVariations('core/embed').forEach(function (blockVariation) {
if (!allowedEmbedBlocks.includes(blockVariation.name)) {
wp.blocks.unregisterBlockVariation('core/embed', blockVariation.name)
}
})
})