Last active
January 22, 2020 22:42
-
-
Save laras126/84cdb42be91b3bead10afd7160a0ad84 to your computer and use it in GitHub Desktop.
Filtering a block settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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