Further restrict media access
This commit is contained in:
parent
5e746bcc2d
commit
9466b9d444
@ -647,7 +647,7 @@ function fictioneer_enqueue_block_editor_scripts() {
|
||||
wp_register_script(
|
||||
'fictioneer-block-editor-scripts',
|
||||
get_template_directory_uri() . '/js/block-editor.min.js',
|
||||
['wp-blocks', 'wp-element', 'wp-components', 'wp-editor', 'wp-data', 'jquery'],
|
||||
['wp-dom-ready', 'wp-edit-post', 'wp-blocks', 'wp-element', 'wp-components', 'wp-editor', 'wp-data', 'jquery'],
|
||||
FICTIONEER_VERSION,
|
||||
true
|
||||
);
|
||||
|
2
js/block-editor.min.js
vendored
2
js/block-editor.min.js
vendored
@ -1 +1 @@
|
||||
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)}));
|
||||
wp.domReady((()=>{if(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"),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),!fictioneerData.userCapabilities?.fcn_read_others_files){new MutationObserver((e=>{e.forEach((e=>{if(e.addedNodes&&e.addedNodes.length>0){const e=document.querySelector(".block-editor-inserter__tabs > .components-tab-panel__tabs");e&&e.remove()}}))})).observe(document.querySelector("#editor"),{childList:!0,subtree:!0})}}));
|
@ -6,6 +6,7 @@
|
||||
// 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');
|
||||
@ -20,12 +21,8 @@ wp.domReady(() => {
|
||||
if (!fictioneerData.userCapabilities?.fcn_select_page_template) {
|
||||
wp.data.dispatch('core/edit-post').removeEditorPanel('template');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
wp.domReady(function() {
|
||||
|
||||
// Sticky checkbox and pink-/trackbacks
|
||||
setTimeout(() => {
|
||||
document.querySelectorAll('label').forEach(element => {
|
||||
if (element.textContent === 'Stick to the top of the blog') {
|
||||
@ -38,6 +35,26 @@ wp.domReady(function() {
|
||||
element.closest('.components-panel__row').remove();
|
||||
}
|
||||
});
|
||||
}, 200); // Wait for async; not great, not terrible solution
|
||||
}, 200);
|
||||
|
||||
// Inserter media tab (insufficient but I cannot do better =/)
|
||||
if (!fictioneerData.userCapabilities?.fcn_read_others_files) {
|
||||
const fcn_editorObserver = new MutationObserver(mutations => {
|
||||
mutations.forEach(mutation => {
|
||||
if (mutation.addedNodes && mutation.addedNodes.length > 0) {
|
||||
const hasMediaTab = document.querySelector('.block-editor-inserter__tabs > .components-tab-panel__tabs');
|
||||
|
||||
if (hasMediaTab) {
|
||||
hasMediaTab.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
fcn_editorObserver.observe(
|
||||
document.querySelector('#editor'),
|
||||
{ childList: true, subtree: true }
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user