WP_Block_Patterns_Registry::get_content( string $pattern_name, bool $outside_init_only = false ): string

In this article

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

Retrieves the content of a registered block pattern.

Parameters

$pattern_namestringrequired
Block pattern name including namespace.
$outside_init_onlybooloptional
Return only patterns registered outside the init action.

Default:false

Return

string The content of the block pattern.

Source

private function get_content( $pattern_name, $outside_init_only = false ) {
	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

VersionDescription
6.5.0Introduced.

User Contributed Notes

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