Working with user-centric fields in WordPress – such as input elements, textarea elements, or any type of field in which a user can supply their own values is a place that should always be a target of sanitization.

Fortunately, the WordPress API provides a number of functions to help with this. Depending on your use case, you may need to do one of the following:
And those are all well and good but there are also ways in which you can work to sanitize the data using functions provided by PHP.
Sure, sometimes regular expressions are the way to go but, other times, you may want to use facilities that are built into the language, easier to understand, and easier to follow.
When writing my own code (and when reviewing others) I try to keep that in mind. So with that said, here’s a process that you can use that may make your efforts easier when working with URLs in WordPress.





