W3cubDocs

/WordPress

WP_Block_Patterns_Registry::prepare_content( array $pattern, array $hooked_blocks ): string

Prepares the content of a block pattern. If hooked blocks are registered, they get injected into the pattern, when they met the defined criteria.

Parameters

$patternarrayrequired
Registered pattern properties.
$hooked_blocksarrayrequired
The list of hooked blocks.

Return

string The content of the block pattern.

Source

	if ( $outside_init_only ) {
		$patterns = &$this->registered_patterns_outside_init;
	} else {
		$patterns = &$this->registered_patterns;
	}
	if ( ! isset( $patterns[ $pattern_name ]['content'] ) && isset( $patterns[ $pattern_name ]['filePath'] ) ) {
		ob_start();
		include $patterns[ $pattern_name ]['filePath'];
		$patterns[ $pattern_name ]['content'] = ob_get_clean();
		unset( $patterns[ $pattern_name ]['filePath'] );
	}
	return $patterns[ $pattern_name ]['content'];
}

Changelog

Version Description
6.4.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_block_patterns_registry/prepare_content