# gutenberg/12.6.0/build/block-library/blocks/pattern.php

Gutenberg, version 12.6.0. 45 lines.

- Page: https://pluginprobe.com/plugins/gutenberg/12.6.0/code/build/block-library/blocks/pattern.php
- Raw: https://pluginprobe.com/plugins/gutenberg/12.6.0/raw/build/block-library/blocks/pattern.php
- Modified: 2021-11-11T00:35:08+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/gutenberg/12.6.0/code/build/block-library/blocks/pattern.php#L10-L20`.

```php
<?php
/**
 * Server-side rendering of the `core/pattern` block.
 *
 * @package WordPress
 */

/**
 *  Registers the `core/pattern` block on the server.
 *
 * @return void
 */
function gutenberg_register_block_core_pattern() {
	register_block_type_from_metadata(
		__DIR__ . '/pattern',
		array(
			'render_callback' => 'gutenberg_render_block_core_pattern',
		)
	);
}

/**
 * Renders the `core/pattern` block on the server.
 *
 * @param array $attributes Block attributes.
 *
 * @return string Returns the output of the pattern.
 */
function gutenberg_render_block_core_pattern( $attributes ) {
	if ( empty( $attributes['slug'] ) ) {
		return '';
	}

	$slug     = $attributes['slug'];
	$registry = WP_Block_Patterns_Registry::get_instance();
	if ( ! $registry->is_registered( $slug ) ) {
		return '';
	}

	$pattern = $registry->get_registered( $slug );
	return do_blocks( $pattern['content'] );
}

add_action( 'init', 'gutenberg_register_block_core_pattern', 20 );

```
