Escaping strings for WordPress is something that developers should be doing at any place in which the user can be sending information across the wire to the database.
Core offers some nice API functions for this. But if you’re writing a raw database query using $wpdb (which is something that I recommend only when an API doesn’t offer what’s needed), then there are still options, but you may need to fall back to a native PHP function.
Case in point: mysqli_real_escape_string.
