Advertisement
Guest User

xoakhoangtrang

a guest
Jun 10th, 2015
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. function ___wejns_wp_whitespace_fix($input) {
  2.     /* valid content-type? */
  3.     $allowed = false;
  4.  
  5.     /* found content-type header? */
  6.     $found = false;
  7.  
  8.     /* we mangle the output if (and only if) output type is text/* */
  9.     foreach (headers_list() as $header) {
  10.         if (preg_match("/^content-type:\\s+(text\\/|application\\/((xhtml|atom|rss)\\+xml|xml))/i", $header)) {
  11.             $allowed = true;
  12.         }
  13.  
  14.         if (preg_match("/^content-type:\\s+/i", $header)) {
  15.             $found = true;
  16.         }
  17.     }
  18.  
  19.     /* do the actual work */
  20.     if ($allowed || !$found) {
  21.         return preg_replace("/\\A\\s*/m", "", $input);
  22.     } else {
  23.         return $input;
  24.     }
  25. }
  26.  
  27. /* start output buffering using custom callback */
  28. ob_start("___wejns_wp_whitespace_fix");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement