I am using Options Framework to build a list of theme options (using code from the theme, not the plugin).
I have a colour picker as an option, and I can set and call this colour okay.
I'd like to convert the RGB value to HSV, and I found the code to do that here.
I entered this code into my functions.php, in a function called convert_RGA_HSV (on pastebin). It accepts a RGB colour, and returns an array($H, $S, $V).
Also in functions.php I have:
function set_HSV () {
$varcolour = of_get_option('custom_colour');
$varhsv = convert_RGA_HSV($varcolour);
add_option( 'hsv', $varhsv, '', 'yes' );
}
add_action( 'after_setup_theme', 'set_HSV' );
of_get_option is the function built into the Options Framework to return a value of an option.
I don't know if this set_HSV function is being run, or if it is not working properly, as no option called hsv is being inserted into theme options.
hsv
option in your code?$varcolour = of_get_option('custom_colour');
actually set before you are trying to retrieve it?convert_RGA_HSV
accessible to yourset_HSV
function? Check by dumping the$varhsv
variable. If you don't needadd_option
's extra parameters then its also OK to useupdate_option
which will create the option if it does not exist and or update the option if it already exists. Syntax:update_option( $option, $new_value );
hsv
option,of_get_option('hsv')
will not work, as it's not part of your array of theme options, you've saved it under its own key so you have to use WordPress'get_option