Created
January 18, 2017 06:40
-
-
Save dmtrmrv/9eaccd96f2f841f6120c25289c6cbe37 to your computer and use it in GitHub Desktop.
Sanitize image upload in Customizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Sanitizes Image Upload. | |
* | |
* @param string $input potentially dangerous data. | |
*/ | |
function themepatio_sanitize_image( $input ) { | |
$filetype = wp_check_filetype( $input ); | |
if ( $filetype['ext'] && wp_ext2type( $filetype['ext'] ) === 'image' ) { | |
return esc_url( $input ); | |
} | |
return ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment