get_dynamic_block_names(): string[]

Returns an array of the names of all registered dynamic block types.

Return

string[] Array of dynamic block names.

Source

if ( ! str_contains( $block_name, '/' ) ) {
	$block_name = 'core/' . $block_name;
}

// Test for existence of block by its fully qualified name.
$has_block = str_contains( $post, '<!-- wp:' . $block_name . ' ' );

if ( ! $has_block ) {
	/*
	 * If the given block name would serialize to a different name, test for
	 * existence by the serialized form.
	 */

Changelog

VersionDescription
5.0.0Introduced.

User Contributed Notes

  1. Skip to note 2 content
    // Fetch block names.
    $block_names = get_dynamic_block_names();
    
    // Output.
    Array
    (
        [0] => core/block
        [1] => core/latest-comments
        [2] => core/archives
        [3] => core/calendar
        [4] => core/categories
        [5] => core/latest-posts
        [6] => core/rss
        [7] => core/search
        [8] => core/shortcode
        [9] => core/tag-cloud
    )

You must log in before being able to contribute a note or feedback.