Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin tommcfarlin/00-saving-data.php Secret
Created Jun 14, 2018

Embed
What would you like to do?
[WordPress][PHP] Sanitizing URLs in WordPress with Its API and PHP
<?php
$data['url'] = 'https://tommcfarlin.com/<script type="text/javascript">alert(\'hello world!\');</script>';
<?php
if (!isset($data['url']) {
return '';
}
$url = $data['url'];
$data['url'] = strip_tags(
stripslashes(
filter_var($url, FILTER_VALIDATE_URL)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.