• Resolved leiti373

    (@leiti373)


    Hi there,

    is there an easy way to prevent globally the usage of certain blocks?

    Like exclude “Widgets” completely, or just skip embeddings like SoundCloud, Animoto, etc.?

    Thanks for assistance ??

    Cheers,
    Markus

Viewing 6 replies - 1 through 6 (of 6 total)
  • Theme Author Ben Sibley

    (@bensibley)

    Hi Markus,

    That’s a good question. I haven’t tried this before, but it looks like you can actually disable blocks from within the post editor. This tutorial has some screenshots showing how it works: https://wplift.com/restrict-disable-gutenberg-blocks/

    Thread Starter leiti373

    (@leiti373)

    Hi Ben,

    thanks for the link.

    As I understood, going via the admin panel is something just for the logged-in user, and not a global setting.

    I might use one of the suggested plugins probably.

    In the meantime I found a snippet to be placed in the functions.php:

    function whitelist_blocks()
    {
    return array(
    'core/heading',
    'core/paragraph',
    'core/image',
    'core/button',
    'core/buttons',
    'core/list',
    'core/list-item',
    'core/gallery',
    );
    }
    add_filter('allowed_block_types_all', 'whitelist_blocks');

    This works pretty well for my purposes ??

    Only limitation: for embeddings that use additional information to define the block, this doesn’t work.

    Cheers,
    Markus

    Theme Author Ben Sibley

    (@bensibley)

    Nice work!

    One thing I would recommend is to install the Code Snippets plugin and move this function from Apex’s functions.php file into there. The danger with adding code to functions.php is that the next time I release an update for Apex, your code will be overwritten, and you’ll have to add it again.

    Thread Starter leiti373

    (@leiti373)

    Hi Ben,

    thanks for the hint. This also accounts for when using the child theme?

    Cheers,
    Markus

    Theme Author Ben Sibley

    (@bensibley)

    If you’re using a child theme, then that’s fine. You can safely edit the functions.php file in the child theme and you’ll never lose your changes. It’s only an issue if you edit the functions.php file inside the “parent” theme.

    Thread Starter leiti373

    (@leiti373)

    Great! ????

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Prevent globally usage of certain blocks’ is closed to new replies.