Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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