Skip to content

Instantly share code, notes, and snippets.

@laras126
Last active January 22, 2020 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laras126/84cdb42be91b3bead10afd7160a0ad84 to your computer and use it in GitHub Desktop.
Save laras126/84cdb42be91b3bead10afd7160a0ad84 to your computer and use it in GitHub Desktop.
Filtering a block settings
function changeListBlockClassName( settings, name ) {
if ( name !== 'core/list' ) {
return settings;
}
return lodash.assign( {}, settings, {
title: 'Default List' // Changing the title of the block - this lodash helper merges the objects or w/e
} );
}
wp.hooks.addFilter(
'blocks.registerBlockType', // hook to filter
'core/list', // name of registered block
changeListBlockClassName // callback filtering object
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment