diff --git a/js/block-editor.min.js b/js/block-editor.min.js index 08c9c5a0..1aadb0d7 100644 --- a/js/block-editor.min.js +++ b/js/block-editor.min.js @@ -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)})); \ No newline at end of file +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)})); \ No newline at end of file diff --git a/src/js/block-editor.js b/src/js/block-editor.js index bc787296..df2749cd 100644 --- a/src/js/block-editor.js +++ b/src/js/block-editor.js @@ -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(() => {