[ticket/11538] Add optional switch as argument to hex colour validation

The value of $optional will decide whether an empty string will be
treated as incorrect input or if it is allowed. The optional argument
will default to false and therefore treat an empty string as incorrect
unless explicitly told to not do so.

PHPBB3-11538