I have the following PHP code inside a Wordpress template that gets the user search query text and insert it into a string:
$name = sprintf( esc_html__( 'Search Results for: %s'), get_search_query());
The line as mentioned works, and the result is something like:
"Search Results for Doggy Bags"
What I don't understand is, why does it work? Shouldn't esc_html__()
run first before sprintf()
has had the chance to replace the placeholder (%s) inside the former function to the search query term?
Thanks,