Extra removal of editor panels

This commit is contained in:
Tetrakern 2023-08-15 17:57:34 +02:00
parent e8894b5db7
commit 2645b09ea3
2 changed files with 22 additions and 1 deletions

View File

@ -1 +1 @@
wp.domReady((function(){setTimeout((()=>{document.querySelectorAll("label").forEach((e=>{"Stick to the top of the blog"===e.textContent&&(fictioneerData.userCapabilities?.fcn_make_sticky||e.closest(".components-panel__row").remove()),"Allow pingbacks & trackbacks"===e.textContent&&e.closest(".components-panel__row").remove()}))}),200)}));
wp.domReady((()=>{fictioneerData.userCapabilities?.manage_options||wp.data.dispatch("core/edit-post").removeEditorPanel("page-attributes"),fictioneerData.userCapabilities?.fcn_edit_permalink||wp.data.dispatch("core/edit-post").removeEditorPanel("post-link"),fictioneerData.userCapabilities?.fcn_select_page_template||wp.data.dispatch("core/edit-post").removeEditorPanel("template")})),wp.domReady((function(){setTimeout((()=>{document.querySelectorAll("label").forEach((e=>{"Stick to the top of the blog"===e.textContent&&(fictioneerData.userCapabilities?.fcn_make_sticky||e.closest(".components-panel__row").remove()),"Allow pingbacks & trackbacks"===e.textContent&&e.closest(".components-panel__row").remove()}))}),200)}));

View File

@ -3,6 +3,27 @@
// RESTRICT EDITOR ELEMENTS (ENGLISH ONLY)
// =============================================================================
// https://github.com/WordPress/gutenberg/tree/trunk/packages/edit-post/src/components/sidebar
wp.domReady(() => {
// Page attributes
if (!fictioneerData.userCapabilities?.manage_options) {
wp.data.dispatch('core/edit-post').removeEditorPanel('page-attributes');
}
// Permalink
if (!fictioneerData.userCapabilities?.fcn_edit_permalink) {
wp.data.dispatch('core/edit-post').removeEditorPanel('post-link');
}
// Template
if (!fictioneerData.userCapabilities?.fcn_select_page_template) {
wp.data.dispatch('core/edit-post').removeEditorPanel('template');
}
});
wp.domReady(function() {
setTimeout(() => {