fix archives block widget

This commit is contained in:
IanDelMar 2022-03-19 11:33:17 +01:00
parent dfef8b2c9b
commit 39ded2cca2
1 changed files with 22 additions and 0 deletions

View File

@ -8,6 +8,28 @@
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
if ( ! function_exists( 'understrap_add_block_widget_archives_classes' ) ) {
/**
* Adds Bootstrap class to select tag in the Categories widget.
*
* @param string $block_content The block content.
* @param array $block The full block, including name and attributes.
* @return string The filtered block content.
*/
function understrap_add_block_widget_archives_classes( $block_content, $block ) {
if ( isset( $block['attrs']['displayAsDropdown'] ) && true === $block['attrs']['displayAsDropdown'] ) {
return str_replace(
'<select',
'<select class="' . understrap_get_select_control_class() . '"',
$block_content
);
}
return $block_content;
}
}
add_filter( 'render_block_core/archives', 'understrap_add_block_widget_archives_classes', 10, 2 );
/**
* Add filter to the parameters passed to a widget's display callback.
* The filter is evaluated on both the front and the back end!