Is there any way to hide specific Gutenberg block settings from users?
For example: "Crop Images", "Link To", and "Additional CSS Class"
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityIs there any way to hide specific Gutenberg block settings from users?
For example: "Crop Images", "Link To", and "Additional CSS Class"
As far as I know, as of right now there isn't a built-in way of removing unwanted inspector controls.
You can read THIS POST, but the gist is that there are proposed solutions out there and devs are aware but they have bigger fish to fry atm, apparently.
With that said, I guess you are left with 2 options.
1 - Copy the block in question and remake it without the options
This could be difficult, especially if you don't have any JS and/or block editor dev experience.
2 - Use some crazy CSS selector to add display:none to the options
This is probably easier but you still have to figure out the right CSS selector, which is difficult due to no IDs or classes on the option elements.
Neither of these solutions are great but I think thats what we have, for now...
let controls = {///}
, and when i added function removeGalleryControls( controls, block ) {}
in theme function I got error on the comma between ( control , block )
! Should i adding let control
within javascript or on my theme function.php
? Gutenberg is so complicated to me :(
Mar 21, 2019 at 9:47
'enqueue_block_editor_assets'
and in the styles, you can hide pretty much everything withdisplay: none;
. This can be a solution until you figure a solid way to handle the issue. Another thing that might work but I don't have time to research is theremove_meta_box()
function. I think that will give you something to look into or some ideas to the people with more time for a complete in-depth answer. Cheers!remove_meta_box()
Thanks so much.enqueue_block_editor_assets
hook a script too. Get theeditor-block-styles__item-label
inner text, check if it matches the one you want to hide, and then add a class to the card that hides whatever you want. The last step is to write aMutationObserver
to look for changes and toggle the class that hides the card. Last-last step should be to ask for card specific classes for the block editor from the Gutenberg team...