su_is_valid_hex

The shortcodes-ultimate su is valid hex function.

Published Date - February 15, 2021

Description

Helper function to check validity of a given HEX color.

su_is_valid_hex( $color );

Parameters

  1. $color


Usage

The following example is for adding a hook callback.

if ( !function_exists( 'su_is_valid_hex' ) ) {
    require_once ABSPATH . PLUGINDIR . 'shortcodes-ultimateshortcodes-ultimate/includes/functions-colors.php';
}

// The input(s). 
$color = null;

// NOTICE! Understand what this does before running.
$result = su_is_valid_hex( $color );
            

Defined

The function is defined in the following location(s).

shortcodes-ultimate/includes/functions-colors.php

function su_is_valid_hex( $color ) {
	return preg_match( '/^#([a-f0-9]{3}){1,2}\b$/i', $color ) === 1;
}