Currently I’m using the below snippet, which indent the resulting HTML by using several space characters:
add_filter('get_search_form', 'filter_search_form');
function filter_search_form($form) {
$form = ' <form role="search" method="get" id="searchform" action="' . home_url('/') . '"><input type="text" placeholder="' . __('Search') . '" value="' . get_search_query() . '" name="s" id="s"><input type="submit" id="searchsubmit" value="' . esc_attr__('Search') . '"></form>' . "\n";
return $form;
}
Now I’ve been reading some about whitespace characters (\t for tab, \n for newline, etc.), but I’m not entirely sure how to implement this in this situation.
I’ve tried using \s for a single space, but without any luck thusfar.
Being relatively new to PHP, I hope you could assist (preferably without using a ‘regular’ space character).
According to http://php.net/manual/en/regexp.reference.escape.php, the general hexadecimal escape sequence
\x20should work, as should\040(octal).Personally, though, I don’t see much (if any) benefit to ever specifying spaces in this manner, as it would make your code less readable, IMHO. Just stick literal spaces inside your single- or double-quotes (like you have now) and be done with it.
Alternatively, if you’re trying to use whitespace to indent the resulting HTML code (as it seems you are), doing so in units of
\tisn’t the end of the world.