Action uncanny-automator

automator_after_blocks_init

Fires after WordPress core blocks are initialized, allowing for custom block modifications and registrations.

add_action( 'automator_after_blocks_init', $callback, 10, 1 );

Description

Fires after core Automator blocks have been initialized. Developers can use this hook to add custom block definitions or modify existing ones before the Gutenberg editor fully loads them. This is a crucial point for integrating custom block functionality.


Usage

add_action( 'automator_after_blocks_init', 'your_function_name', 10, 1 );

Examples

add_action( 'automator_after_blocks_init', 'my_automator_handle_blocks_init', 10, 0 );

/**
 * Example callback function for the 'automator_after_blocks_init' hook.
 * This function demonstrates adding custom functionality after blocks are initialized.
 * For instance, you might want to register additional block patterns or styles here.
 */
function my_automator_handle_blocks_init() {
    // In a real-world scenario, you might enqueue custom block styles or scripts.
    // For demonstration purposes, we'll simply log a message.
    error_log( 'Automator blocks have finished initializing. You can now add custom block logic.' );

    // Example: Registering a custom block pattern
    if ( function_exists( 'register_block_pattern' ) ) {
        register_block_pattern(
            'my-plugin/my-custom-pattern',
            array(
                'title'       => __( 'My Custom Block Pattern', 'my-plugin-textdomain' ),
                'description' => __( 'A simple custom block pattern for demonstration.', 'my-plugin-textdomain' ),
                'content'     => '<!-- wp:paragraph --><p>This is a custom block pattern.</p><!-- /wp:paragraph -->',
                'categories'  => array( 'my-plugin' ),
            )
        );
    }
}

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/class-automator-load.php:720

public function gutenberg_block_classes( $classes = array() ) {

		do_action( 'automator_before_blocks_init' );

		$classes['Blocks'] = UA_ABSPATH . 'src/core/blocks/class-blocks.php';

		do_action( 'automator_after_blocks_init' );

		return $classes;
	}


Scroll to Top