Fixed the sanitize callback error
This commit is contained in:
parent
b0c1772f4b
commit
2b2bb08390
|
@ -57,6 +57,7 @@ function tainacan_customize_register( $wp_customize ) {
|
||||||
*/
|
*/
|
||||||
$wp_customize->add_setting( 'tainacan_footer_logo', array(
|
$wp_customize->add_setting( 'tainacan_footer_logo', array(
|
||||||
'capability' => 'manage_options',
|
'capability' => 'manage_options',
|
||||||
|
'sanitize_callback' => 'tainacan_sanitize_upload',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$wp_customize->add_control(
|
$wp_customize->add_control(
|
||||||
|
@ -233,18 +234,41 @@ function tainacan_sanitize_email( $email, $setting ) {
|
||||||
* - Sanitization: number
|
* - Sanitization: number
|
||||||
* - Control: text
|
* - Control: text
|
||||||
*
|
*
|
||||||
* @param string $email Email address to sanitize.
|
* @param string $phone Phone to sanitize.
|
||||||
* @param WP_Customize_Setting $setting Setting instance.
|
* @return string The sanitized phone if the number is <= 18; otherwise, the setting default.
|
||||||
* @return string The sanitized email if not null; otherwise, the setting default.
|
|
||||||
*/
|
*/
|
||||||
function tainacan_sanitize_phone( $phone ) {
|
function tainacan_sanitize_phone( $phone ) {
|
||||||
// Strips out all characters that are not allowable in an email address.
|
// Replace out all characters that are not allowable in an phone number.
|
||||||
$phone = preg_replace( '/[^0-9 \\-\\(\\)\\+\\/]/', '', $phone );
|
$phone = preg_replace( '/[^0-9 \\-\\(\\)\\+\\/]/', '', $phone );
|
||||||
|
|
||||||
// If $email is a valid email, return it; otherwise, return the default.
|
// If $phone is a valid number and <= 18, return it; otherwise, ''.
|
||||||
return ( strlen( $phone ) <= 18 ? $phone : '' );
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers color schemes for Tainacan Theme.
|
* Registers color schemes for Tainacan Theme.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue