wp_normalize_remote_block_pattern

函数
wp_normalize_remote_block_pattern ( $pattern )
Access
Private
参数
  • (array) $pattern Pattern as returned from the Pattern Directory API.
    Required:
返回值
  • (array) Normalized pattern.
定义位置
相关方法
_load_remote_block_patternswp_normalize_site_datawp_normalize_path_wp_normalize_relative_css_links_register_theme_block_patterns
引入
6.2.0
弃用
-

wp_normalize_remote_block_pattern(): 这个函数将WordPress中的远程块模式规范化。

将模式属性规范化为camelCase。

API的格式是snake_case,`register_block_pattern()`希望是camelCase。

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;
}

常见问题

FAQs
查看更多 >