Created
December 27, 2024 18:09
-
-
Save vandanojan/20443d2d03e379403364c45c13fd872a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function fix_wp_sitemap_whitespace($input) { | |
$allowed = false; | |
$found = false; | |
foreach (headers_list() as $header) { | |
if (preg_match("/^content-type:\s+(text\/(html|application\/(xhtml\+xml|atom\+xml|xml)))/i", $header)) { | |
$allowed = true; | |
} | |
if (preg_match("/^content-type:\s+/i", $header)) { | |
$found = true; | |
} | |
} | |
if ($allowed || $found) { | |
return preg_replace("/^\s*/m", "", $input); | |
} else { | |
return $input; | |
} | |
} | |
ob_start("fix_wp_sitemap_whitespace"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment