Fixed the sanitize callback error

This commit is contained in:
Fabiano 2018-10-05 11:15:45 -03:00
parent b0c1772f4b
commit 2b2bb08390
1 changed files with 33 additions and 9 deletions

View File

@ -57,6 +57,7 @@ function tainacan_customize_register( $wp_customize ) {
*/
$wp_customize->add_setting( 'tainacan_footer_logo', array(
'capability' => 'manage_options',
'sanitize_callback' => 'tainacan_sanitize_upload',
) );
$wp_customize->add_control(
@ -233,16 +234,39 @@ function tainacan_sanitize_email( $email, $setting ) {
* - Sanitization: number
* - Control: text
*
* @param string $email Email address to sanitize.
* @param WP_Customize_Setting $setting Setting instance.
* @return string The sanitized email if not null; otherwise, the setting default.
* @param string $phone Phone to sanitize.
* @return string The sanitized phone if the number is <= 18; otherwise, the setting default.
*/
function tainacan_sanitize_phone( $phone ) {
// Strips out all characters that are not allowable in an email address.
$phone = preg_replace('/[^0-9 \\-\\(\\)\\+\\/]/', '', $phone);
// Replace out all characters that are not allowable in an phone number.
$phone = preg_replace( '/[^0-9 \\-\\(\\)\\+\\/]/', '', $phone );
// If $email is a valid email, return it; otherwise, return the default.
return ( strlen($phone) <= 18 ? $phone : '' );
// If $phone is a valid number and <= 18, return it; otherwise, ''.
return ( strlen( $phone ) <= 18 ? $phone : '' );
}
/**
* Tainacan Upload sanitization callback.
*
* - Sanitization: upload
* - Control: file
*
*/
function tainacan_sanitize_upload( $input ) {
/* default output */
$output = '';
/* check file type */
$filetype = wp_check_filetype( $input );
$mime_type = $filetype['type'];
/* only mime type "image" allowed */
if ( strpos( $mime_type, 'image' ) !== false ) {
$output = $input;
}
return $output;
}
/**