Sanitation(validation) in wordpress

Backend side:
For url and image:  esc_url_raw();
For text:           sanitize_text_field();
For email:          sanitize_email();

Frontend side:
For url and image:   esc_url();
For email and text:  esc_attr();

/* Validation for uploaded image */

function advent_image_validation($advent_imge_url) {
$advent_filetype = wp_check_filetype($advent_imge_url);

$advent_supported_image = array(‘gif’, ‘jpg’, ‘jpeg’, ‘png’, ‘ico’);

if (in_array($advent_filetype[‘ext’], $advent_supported_image)) {
return $advent_imge_url;
} else {
return ”;
/* sanitation */


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: