Last active
August 29, 2015 14:21
-
-
Save christophherr/79de3d3a650b563ae729 to your computer and use it in GitHub Desktop.
WPDevelopersClub Code Challenge May 19,2015
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
//1. | |
$args = func_get_args(); | |
//2. | |
$numargs = count($args); | |
//3. | |
//This is this weeks brain teaser. | |
//At first I was thinking about using sanitize_meta (the name just seemed so perfect...) but looking at the codex that seemed overly complicated and too much code. | |
//My next thought was to look at esc_html or the kses_"family" but they are only sanitizing/escaping HTML. | |
//Realizing I was only looking at WordPress and not PHP, I started searching for a (general) php function. | |
//I found a bunch of filters that also seemed too complicated and then I stumbled upon a post series on PHP security that mentioned strip_tags. | |
//After reading the PHP manual I believe that this is the simplest way to sanitize: | |
update_user_meta( $user_id, $meta_key, strip_tags($meta_value) ); | |
//Now... there was the "if it is present" part of the questions which seems like an additional condition to the question... | |
//That would mean the if statement has to be changed... But I´ll wait to see if I´m reading too much into that ;) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment