W3cubDocs

/WordPress

wp_normalize_remote_block_pattern( array $pattern ): array

Normalize the pattern properties to camelCase.

Description

The API’s format is snake_case, register_block_pattern() expects camelCase.

Parameters

$patternarrayrequired
Pattern as returned from the Pattern Directory API.

Return

array Normalized pattern.

Source

function wp_normalize_remote_block_pattern( $pattern ) {
	if ( isset( $pattern['block_types'] ) ) {
		$pattern['blockTypes'] = $pattern['block_types'];
		unset( $pattern['block_types'] );
	}

	if ( isset( $pattern['viewport_width'] ) ) {
		$pattern['viewportWidth'] = $pattern['viewport_width'];
		unset( $pattern['viewport_width'] );
	}

	return (array) $pattern;
}

Changelog

Version Description
6.2.0 Introduced.

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