Yes, WordPress will sanitise data on its way to the database, so long as you use the APIs.
If you're using the wpdb
object however you'll need to use the prepare
method to sanitise. I recommend against using the wpdb
object to write rawwriting SQL queries as it bypasses object caches etc, but if you must write your own SQL, use wpdb
to prepare and execute it
For calls such as WP_QueryWP_Query
, get_postsget_posts
, add_post_metaadd_post_meta
etc etc sanitisation occurs
Note that this is purely DB sanitisation, any additional sanitisation or validation you require, such as trimming trailing spaces, validation of URLs, stripping tags, escaping, etc, must all be done in your code