wp_render_elements_support_styles
函数
      wp_render_elements_support_styles ( $pre_render, $block )    
  - Access
 - Private
 
- 参数
 - 
- 
                (string|null)
$pre_render
The pre-rendered content. Default null.- Required: 是
 
 - 
                (array)
$block
The block being rendered.- Required: 是
 
 
 - 
                (string|null)
 
- 返回值
 - 
- (null)
 
 
- 定义位置
 - 
- 
                                  wp-includes/block-supports/elements.php
, line 100 
 - 
                                  wp-includes/block-supports/elements.php
 
- 引入
 - 6.0.0
 
- 弃用
 - –
 
Render the elements stylesheet.
In the case of nested blocks we want the parent element styles to be rendered before their descendants.
This solves the issue of an element (e.g.: link color) being styled in both the parent and a descendant:
we want the descendant style to take priority, and this is done by loading it after, in DOM order.
function wp_render_elements_support_styles( $pre_render, $block ) {
	$block_type           = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
	$element_block_styles = isset( $block['attrs']['style']['elements'] ) ? $block['attrs']['style']['elements'] : null;
	/*
	* For now we only care about link color.
	*/
	$skip_link_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' );
	if ( $skip_link_color_serialization ) {
		return null;
	}
	$class_name        = wp_get_elements_class_name( $block );
	$link_block_styles = isset( $element_block_styles['link'] ) ? $element_block_styles['link'] : null;
	wp_style_engine_get_styles(
		$link_block_styles,
		array(
			'selector' => ".$class_name a",
			'context'  => 'block-supports',
		)
	);
	return null;
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。