diff --git a/themes/wds_headless/functions.php b/themes/wds_headless/functions.php index c8f41f81..b33d184f 100644 --- a/themes/wds_headless/functions.php +++ b/themes/wds_headless/functions.php @@ -51,7 +51,6 @@ function wds_theme_setup() { ); // Disable background color gradient presets. - // See note above re: 'editor-color-palette'. add_theme_support( 'editor-gradient-presets', [] ); // Reset available font size presets to only "normal" (16px). diff --git a/themes/wds_headless/js/blocks.js b/themes/wds_headless/js/blocks.js index 43593dde..9a43aa15 100644 --- a/themes/wds_headless/js/blocks.js +++ b/themes/wds_headless/js/blocks.js @@ -1,6 +1,6 @@ const { validateThemeColors } = wp.blockEditor; const { useEffect } = wp.element; -const { addFilter } = wp.hooks; +const { addFilter, applyFilters } = wp.hooks; /** * Additional Gutenberg block functionality. @@ -21,12 +21,12 @@ wp.domReady(() => { addFilter( "blocks.registerBlockType", - "wds/filterParagraphBlockAttrs1", + "wds/filterBlockColorAttrs", wdsAddColorPaletteHexValues ); /** - * Filter block registration to add custom color attributes to paragraph block. + * Filter block registration to add custom color attributes to specified blocks. * * TODO: Extend this to apply to other blocks that use the color palette. * @@ -35,7 +35,18 @@ addFilter( * @return {object} Block settings config. */ function wdsAddColorPaletteHexValues(settings, name) { - if ("core/paragraph" !== name) { + /** + * Filter the array of blocks to receive hex color values. + * + * @author WebDevStudios + * @param {array} allowedBlocks Array of blocks. + */ + const allowedBlocks = applyFilters( + "wds/colorPaletteHexValuesAllowedBlocks", + ["core/button", "core/paragraph"] + ); + + if (!allowedBlocks.includes(name)) { return settings; }