acf-gutenblocks icon indicating copy to clipboard operation
acf-gutenblocks copied to clipboard

Align and supports in the Block constructor options does nothing

Open thomasjulienalain opened this issue 4 years ago • 1 comments

Hello !

Adding align and supports options to the Block constructor doesn't work properly.

The only way I found to make it work is to bypass the plugin (which is sad) and use acf/register_block_type_args filter instead to correctely set those 2 settings.

add_filter('acf/register_block_type_args', function($args){

            if ($args['name'] == 'acf/bio') {
                $args['align'] = 'full';
                $args['supports'] = array(
                    'align' => array('full'),
                    'mode' => false,
                    'multiple' => false,
                );
            }

            return $args;
        });

Would it work better by adding this to the acf_gutenblocks/block_settings filter? Don't know if it's the best way.

$settings = apply_filters('acf_gutenblocks/block_settings', [
...
            'align'       => $settings['align'],
            'supports'    => $settings['support'] ?? [],
...
], $this->name);

thomasjulienalain avatar Jun 02 '20 01:06 thomasjulienalain

Hey @thomasjulienalain,

A filter is a great idea for that location. Feel free to put together a PR and we can look to get that merged.

codepuncher avatar Aug 25 '21 15:08 codepuncher