Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Created May 20, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/8edbf9a45d168d7d71a6 to your computer and use it in GitHub Desktop.
Save tommcfarlin/8edbf9a45d168d7d71a6 to your computer and use it in GitHub Desktop.
<?php
/**
* A santization function that will take the incoming input, and make
* sure that it's secure before saving it to the database.
*
* @since 1.0.0
*
* @param array $input The name input.
* @return array $new_input The sanitized input.
*/
public function sanitize( $input ) {
// Prepare the new array to save
$new_input = array();
// Set the name to save to the database
$new_input['name'] =
( $this->validator->is_valid_name( $input['name'] ) ) ?
$this->validator->sanitize_input( $input['name'] ) :
'';
return $new_input;
}
<?php
/**
* A santization function that will take the incoming input, and make
* sure that it's secure before saving it to the database.
*
* @since 1.0.0
*
* @param array $input The name input.
* @return array $new_input The sanitized input.
*/
public function sanitize( $input ) {
// Prepare the new array to save
$new_input = array();
// Set the name to save to the database
$new_input['name'] =
( $this->validator->is_valid_name( $input['name'] ) ) ?
$this->validator->sanitize_input( $input['name'] ) :
'';
// Return false if the 'name' index isn't set
return ( empty( $new_input['name'] ) ) ? false : $new_input;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment