Skip to content

Instantly share code, notes, and snippets.

@carolinan
Created July 12, 2023 07:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carolinan/7e93ee0299bca696538747e6aee6a8f5 to your computer and use it in GitHub Desktop.
Save carolinan/7e93ee0299bca696538747e6aee6a8f5 to your computer and use it in GitHub Desktop.
filter block supports
-enqueue the JS file with the enqueue_block_editor_assets hook.
JS file:
function removeAlignment( settings, name ) {
if ( name !== 'core/group' ) {
return settings;
}
return Object.assign( {}, settings, {
supports: Object.assign( {}, settings.supports, {
align: ['center', 'left', 'right','wide'], // Whatever is wanted here
} ),
} );
}
wp.hooks.addFilter(
'blocks.registerBlockType',
'prefix/remove-alignment/group-block',
removeAlignment
);
function removeLayout( settings, name ) {
if ( name !== 'core/buttons' ) {
return settings;
}
return Object.assign( {}, settings, {
supports: Object.assign( {}, settings.supports, {
layout: false,
} ),
} );
}
wp.hooks.addFilter(
'blocks.registerBlockType',
'prefix/remove-layout/buttons-block',
removeLayout
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment