Skip to content
Custom fields for WordPress that are quick to build and quick to load. Get Pro
Docs

Hooks and filters

Blocks

1 minute to read Updated 1 week ago

On this page

ugly_blocks_off

Filter. The names of the blocks (their folder) that are turned off. They are not registered: the editor does not offer them and the site shows nothing in their place. Files and fields stay.

PHP
add_filter( 'ugly_blocks_off', fn ( $off ) => array( ...$off, 'hero', 'faq' ) );

ugly_layouts_off

Filter. Layouts of a flexible content to hide from the "Add" menu, as 'group_key.field_name' => array( 'layout', ... ).

PHP
add_filter( 'ugly_layouts_off', function ( $off ) {
	$off['group_page.blocks'] = array( 'hero', 'faq' );
	return $off;
} );

ugly_register_block_args

Filter. The arguments a block is registered with. Receives the arguments and the name of the block (the folder, without ugly/).

PHP
add_filter( 'ugly_register_block_args', function ( array $args, string $name ) {
	if ( 'hero' === $name ) {
		$args['category'] = 'design';
	}
	return $args;
}, 10, 2 );

ugly_block_template

Filter. The render file of a block. Receives the file name and the block name.

PHP
add_filter( 'ugly_block_template', function ( string $file, string $name ) {
	return 'hero' === $name ? 'render-hero.php' : $file;
}, 10, 2 );

Did this article answer your question?