Title: _wp_enqueue_auto_register_blocks
Published: May 20, 2026

---

# _wp_enqueue_auto_register_blocks()

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/_wp_enqueue_auto_register_blocks/?output_format=md#description)
 * [Source](https://developer.wordpress.org/reference/functions/_wp_enqueue_auto_register_blocks/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/_wp_enqueue_auto_register_blocks/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_wp_enqueue_auto_register_blocks/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/_wp_enqueue_auto_register_blocks/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Exposes blocks with autoRegister flag for ServerSideRender in the editor.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/_wp_enqueue_auto_register_blocks/?output_format=md#description)󠁿

Detects blocks that have the autoRegister flag set in their supports and passes 
them to JavaScript for auto-registration with ServerSideRender.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/_wp_enqueue_auto_register_blocks/?output_format=md#source)󠁿

    ```php
    function _wp_enqueue_auto_register_blocks() {
    	$auto_register_blocks = array();
    	$registered_blocks    = WP_Block_Type_Registry::get_instance()->get_all_registered();

    	foreach ( $registered_blocks as $block_name => $block_type ) {
    		if ( ! empty( $block_type->supports['autoRegister'] ) && ! empty( $block_type->render_callback ) ) {
    			$auto_register_blocks[] = $block_name;
    		}
    	}

    	if ( ! empty( $auto_register_blocks ) ) {
    		wp_add_inline_script(
    			'wp-block-library',
    			sprintf( 'window.__unstableAutoRegisterBlocks = %s;', wp_json_encode( $auto_register_blocks ) ),
    			'before'
    		);
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/blocks.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/blocks.php#L3171)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/blocks.php#L3171-L3188)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/_wp_enqueue_auto_register_blocks/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Block_Type_Registry::get_instance()](https://developer.wordpress.org/reference/classes/wp_block_type_registry/get_instance/)`wp-includes/class-wp-block-type-registry.php` |

Utility method to retrieve the main instance of the class.

  | 
| [wp_add_inline_script()](https://developer.wordpress.org/reference/functions/wp_add_inline_script/)`wp-includes/functions.wp-scripts.php` |

Adds extra code to a registered script.

  | 
| [wp_json_encode()](https://developer.wordpress.org/reference/functions/wp_json_encode/)`wp-includes/functions.php` |

Encodes a variable into JSON, with some confidence checks.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/_wp_enqueue_auto_register_blocks/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/_wp_enqueue_auto_register_blocks/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/_wp_enqueue_auto_register_blocks/?output_format=md#changelog)󠁿

| Version | Description | 
| [7.0.0](https://developer.wordpress.org/reference/since/7.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_wp_enqueue_auto_register_blocks%2F)
before being able to contribute a note or feedback.