wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_apply_dimensions_support is private and should not be used in themes or plugins directly.
wp_apply_dimensions_support › WordPress Function
Since5.9.0
Deprecatedn/a
› wp_apply_dimensions_support ( $block_type, $block_attributes )
| Access: |
|
| Parameters: (2) |
|
| Returns: |
|
| Defined at: | |
| Codex: | |
| Change Log: |
|
Adds CSS classes for block dimensions to the incoming attributes array.
This will be applied to the block markup in the front-end.Source
function wp_apply_dimensions_support( $block_type, $block_attributes ) {
$attributes = array();
if ( wp_should_skip_block_supports_serialization( $block_type, 'dimensions' ) ) {
return $attributes;
}
$block_styles = $block_attributes['style'] ?? null;
if ( ! $block_styles ) {
return $attributes;
}
$dimensions_block_styles = array();
$supported_features = array( 'minHeight', 'height', 'width' );
foreach ( $supported_features as $feature ) {
$has_support = block_has_support( $block_type, array( 'dimensions', $feature ), false );
$skip_serialization = wp_should_skip_block_supports_serialization( $block_type, 'dimensions', $feature );
$dimensions_block_styles[ $feature ] = null;
if ( $has_support && ! $skip_serialization ) {
$dimensions_block_styles[ $feature ] = $block_styles['dimensions'][ $feature ] ?? null;
}
}
$styles = wp_style_engine_get_styles( array( 'dimensions' => $dimensions_block_styles ) );
if ( ! empty( $styles['css'] ) ) {
$attributes['style'] = $styles['css'];
}
return $attributes;
}