wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_should_add_elements_class_name is private and should not be used in themes or plugins directly.
wp_should_add_elements_class_name › WordPress Function
Since6.6.0
Deprecatedn/a
› wp_should_add_elements_class_name ( $block, $options )
Access: |
|
Parameters: (2) |
|
Returns: |
|
Defined at: |
|
Codex: |
Determines whether an elements class name should be added to the block.
Source
function wp_should_add_elements_class_name( $block, $options ) {
if ( ! isset( $block['attrs']['style']['elements'] ) ) {
return false;
}
$element_color_properties = array(
'button' => array(
'skip' => isset( $options['button']['skip'] ) ? $options['button']['skip'] : false,
'paths' => array(
array( 'button', 'color', 'text' ),
array( 'button', 'color', 'background' ),
array( 'button', 'color', 'gradient' ),
),
),
'link' => array(
'skip' => isset( $options['link']['skip'] ) ? $options['link']['skip'] : false,
'paths' => array(
array( 'link', 'color', 'text' ),
array( 'link', ':hover', 'color', 'text' ),
),
),
'heading' => array(
'skip' => isset( $options['heading']['skip'] ) ? $options['heading']['skip'] : false,
'paths' => array(
array( 'heading', 'color', 'text' ),
array( 'heading', 'color', 'background' ),
array( 'heading', 'color', 'gradient' ),
array( 'h1', 'color', 'text' ),
array( 'h1', 'color', 'background' ),
array( 'h1', 'color', 'gradient' ),
array( 'h2', 'color', 'text' ),
array( 'h2', 'color', 'background' ),
array( 'h2', 'color', 'gradient' ),
array( 'h3', 'color', 'text' ),
array( 'h3', 'color', 'background' ),
array( 'h3', 'color', 'gradient' ),
array( 'h4', 'color', 'text' ),
array( 'h4', 'color', 'background' ),
array( 'h4', 'color', 'gradient' ),
array( 'h5', 'color', 'text' ),
array( 'h5', 'color', 'background' ),
array( 'h5', 'color', 'gradient' ),
array( 'h6', 'color', 'text' ),
array( 'h6', 'color', 'background' ),
array( 'h6', 'color', 'gradient' ),
),
),
);
$elements_style_attributes = $block['attrs']['style']['elements'];
foreach ( $element_color_properties as $element_config ) {
if ( $element_config['skip'] ) {
continue;
}
foreach ( $element_config['paths'] as $path ) {
if ( null !== _wp_array_get( $elements_style_attributes, $path, null ) ) {
return true;
}
}
}
return false;
}