wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_register_colors_support is private and should not be used in themes or plugins directly.
wp_register_colors_support › WordPress Function
Since5.6.0
Deprecatedn/a
› wp_register_colors_support ( $block_type )
Access: |
|
Parameters: |
|
Defined at: |
|
Codex: | |
Change Log: |
|
Registers the style and colors block attributes for block types that support it.
Source
function wp_register_colors_support( $block_type ) { $color_support = false; if ( $block_type instanceof WP_Block_Type ) { $color_support = isset( $block_type->supports['color'] ) ? $block_type->supports['color'] : false; } $has_text_colors_support = true === $color_support || ( isset( $color_support['text'] ) && $color_support['text'] ) || ( is_array( $color_support ) && ! isset( $color_support['text'] ) ); $has_background_colors_support = true === $color_support || ( isset( $color_support['background'] ) && $color_support['background'] ) || ( is_array( $color_support ) && ! isset( $color_support['background'] ) ); $has_gradients_support = isset( $color_support['gradients'] ) ? $color_support['gradients'] : false; $has_link_colors_support = isset( $color_support['link'] ) ? $color_support['link'] : false; $has_button_colors_support = isset( $color_support['button'] ) ? $color_support['button'] : false; $has_heading_colors_support = isset( $color_support['heading'] ) ? $color_support['heading'] : false; $has_color_support = $has_text_colors_support || $has_background_colors_support || $has_gradients_support || $has_link_colors_support || $has_button_colors_support || $has_heading_colors_support; if ( ! $block_type->attributes ) { $block_type->attributes = array(); } if ( $has_color_support && ! array_key_exists( 'style', $block_type->attributes ) ) { $block_type->attributes['style'] = array( 'type' => 'object', ); } if ( $has_background_colors_support && ! array_key_exists( 'backgroundColor', $block_type->attributes ) ) { $block_type->attributes['backgroundColor'] = array( 'type' => 'string', ); } if ( $has_text_colors_support && ! array_key_exists( 'textColor', $block_type->attributes ) ) { $block_type->attributes['textColor'] = array( 'type' => 'string', ); } if ( $has_gradients_support && ! array_key_exists( 'gradient', $block_type->attributes ) ) { $block_type->attributes['gradient'] = array( 'type' => 'string', ); } }