with this code I remove every spaces in a string.
public function callback_register_settings_remove_spaces( $input ) {
// New Input
$new_input = array();
$new_input = $input;
// Sanitize the input actually
$new_input = preg_replace("/\s+/", " ", $new_input);
// Sanitize the input actually
$new_input = str_replace(" " , "" , $new_input);
return $new_input;
}
But, I need to NO REMOVE spaces if in a string exists a substring like this:
<script async src
So, if initial string is:
<script async src="http">Bla.js</script>
<script>window.dataLayer = window.dataLayer;</script>
Need to be:
<script async src="http">Bla.js</script><script>window.dataLayer=window.dataLayer;</script>
And not
<scriptasyncsrc="http">Bla.js</script><script>window.dataLayer=window.dataLayer;</script>
Thank you