From 4be90150227167dca737f69eb21e3316487f2d5f Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Fri, 18 Mar 2022 17:33:26 +0100 Subject: [PATCH 1/7] fix search block widget styles --- inc/widgets.php | 38 ++++++++++++++++++++++++++ src/sass/theme/_understrap.scss | 48 +++++++++++++++------------------ 2 files changed, 60 insertions(+), 26 deletions(-) diff --git a/inc/widgets.php b/inc/widgets.php index a8116e8f..6e4c4a46 100644 --- a/inc/widgets.php +++ b/inc/widgets.php @@ -8,6 +8,44 @@ // Exit if accessed directly. defined( 'ABSPATH' ) || exit; +/** + * Adds Bootstrap classes to search block 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 understap_add_block_widget_search_classes( $block_content, $block ) { + + $search = array( + 'wp-block-search__input ', + 'wp-block-search__input"', + 'wp-block-search__button ', + ); + $replace = array( + 'wp-block-search__input form-control ', + 'wp-block-search__input form-control"', + 'wp-block-search__button btn btn-primary ', + ); + + if ( isset( $block['attrs']['buttonPosition'] ) && 'button-inside' === $block['attrs']['buttonPosition'] ) { + $search[] = 'wp-block-search__inside-wrapper'; + $replace[] = 'wp-block-search__inside-wrapper input-group'; + + if ( 'bootstrap4' === get_theme_mod( 'understrap_bootstrap_version', 'bootstrap4' ) ) { + $search[] = '