Including a function into a theme

If you mean to attach it to any and all $_POST inputs in WordPress that’s probably falls under Bad Ideas. WordPress has some kinks in how it works with that data (for example it emulates “magic quotes” mode, long deprecated in PHP itself) and some cases of POST in WP are extremely heavy (saving menus in admin for example).

You can (and should) sanitize data in WP context, but it should be handled case-by-case, for specific tasks and logic.

If you want to review which options WP API has for data sanitization there is a good overview in Data Validation article in Codex.

Leave a Comment