I am trying to change the classes in some of the WordPress widgets. Specifically, I want to add bootstrap classes.
For example, I want to add the "form-control" class to "wp-block-search__input" class
I have tried
function replace_widget($text) {
$text = str_replace('wp-block-search__inside-wrapper', 'wp-block-search__inside-wrapper input-group', $text);
$text = str_replace('wp-block-search__input', 'wp-block-search__input form-control', $text);
$text = str_replace('wp-block-search__button', 'wp-block-search__button btn btn-secondary', $text);
return $text;
}
add_filter('dynamic_sidebar_params', 'replace_widget');
But this and similar attempts do not seem to work.
I have tried a fair few different options instead of "dynamic_sidebar_params" and I am not sure if this is what I am doing wrong.
I am not sure if it is not working because the WordPress blocks are created in JS.
I don't want to do it by adding javascript or jquery to the footer if it can be helped. I would prefer to do it in the backend.