Get This Message:
Sanitize http://envato.d.pr/1dYDX/1F78EE4u
https://developer.wordpress.org/reference/functions/sanitize_hex_color/
What is it?
Get This Message:
Sanitize http://envato.d.pr/1dYDX/1F78EE4u
https://developer.wordpress.org/reference/functions/sanitize_hex_color/
What is it?
Try to use:
$hex = trim( sanitize_hex_color( $hex ), '#' );
instead
$hex = str_replace("#", "", #hex);
sanitize_hex_color only access in wp-customaizer.php and this error when run top code :
Fatal error: Call to undefined function sanitize_hex_color() in /home/
My mistake. You don’t need to sanitize the data in this function (cannot understand why you’ve got this message from reviewer). This function uses like:
$wp_customize->add_setting( 'link_color', array(
'default' => '#FFFFFF',
**'sanitize_callback' => 'sanitize_hex_color',**
'transport' => 'postMessage',
) );
my theme ni use customizer and only use admin panel !
If you’re not using the customizer and don’t have access to the customizer sanitization functions then you can create your own.
thank you jami…
finally use :
$clean_color = (empty($color) || !preg_match(’|^#([A-Fa-f0-9]{3}){1,2}$|’, $color)) ? ‘’ : $color;
use it like this:
if ( ! function_exists( 'sanitize_hex_color' ) ) {
function sanitize_hex_color( $color ) {
if ( '' === $color ) {
return '';
}
// 3 or 6 hex digits, or the empty string.
if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
return $color;
}
}
}