The replacement process is always done with the following code. You can also use filter hooks, but some themes are hard-coded and you can't use filters. So I'm using this code (template_redirect action) so that I can replace even hard-coded parts.
function my_replace_html($content) {
$content = str_replace('<div class="aaa">',<div class="aaa bbb">', $content );
return $content;
}
add_action('template_redirect', function(){ ob_start('my_replace_html'); });
However, this does not work for mobile themes set with the "Multi Device Switcher" plugin.
It has been replaced as usual with themes for PC.
HTML compression such as the "Autoptimize" plugin is also applied to the mobile theme set by the "Multi Device Switcher" plugin.
What's wrong with my method?