Processes pseudo-selectors for any node (block or variation).
Parameters
$nodearrayrequired- The node data (block or variation).
$base_selectorstringrequired- The base selector.
$settingsarrayrequired- The theme settings.
$block_namestringrequired- The block name.
$block_metadataarray|nulloptional- Metadata about the block to get styles for.
Default:
null $style_variationarray|nulloptional- Style variation metadata.
Default:
null
Source
private function process_pseudo_selectors( $node, $base_selector, $settings, $block_name, $block_metadata = null, $style_variation = null ) {
$pseudo_declarations = array();
$add_declarations = static function ( $selector, $declarations ) use ( &$pseudo_declarations ) {
if ( empty( $declarations ) ) {
return;
}
if ( isset( $pseudo_declarations[ $selector ] ) ) {
$pseudo_declarations[ $selector ] = array_merge(
$pseudo_declarations[ $selector ],
$declarations
);
} else {
$pseudo_declarations[ $selector ] = $declarations;
}
};
if ( ! isset( static::VALID_BLOCK_PSEUDO_SELECTORS[ $block_name ] ) ) {
return $pseudo_declarations;
}
foreach ( static::VALID_BLOCK_PSEUDO_SELECTORS[ $block_name ] as $pseudo_selector ) {
if ( isset( $node[ $pseudo_selector ] ) ) {
$pseudo_node = $node[ $pseudo_selector ];
if ( is_array( $block_metadata ) ) {
$feature_declarations = $this->get_feature_declarations_for_node( $block_metadata, $pseudo_node );
$feature_declarations = static::update_paragraph_text_indent_selector( $feature_declarations, $settings, $block_name );
$feature_declarations = static::update_button_width_declarations( $feature_declarations, $settings );
foreach ( $feature_declarations as $feature_selector => $declarations ) {
$target_selector = is_array( $style_variation )
? static::get_block_style_variation_feature_selector( $style_variation, $feature_selector )
: $feature_selector;
$combined_selector = static::append_to_selector( $target_selector, $pseudo_selector );
$add_declarations( $combined_selector, $declarations );
}
}
$combined_selector = static::append_to_selector( $base_selector, $pseudo_selector );
$declarations = static::compute_style_properties( $pseudo_node, $settings, null, null );
$add_declarations( $combined_selector, $declarations );
}
}
return $pseudo_declarations;
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.