add_style($main_color); } function add_style($main_color) { $rgb_main_color = $this->hex2rgb($main_color); $custom_style = ':root { --apadana-color-3: ' . esc_html($main_color) . '; --apadana-color-3-rgb: ' . esc_html($rgb_main_color) . '; }'; wp_add_inline_style('apadana-main-style-file', $custom_style); } // // function hex2rgb($hex) // { // $hex = str_replace("#", "", $hex); // // if (strlen($hex) == 3) { // $r = hexdec(substr($hex, 0, 1) . substr($hex, 0, 1)); // $g = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1)); // $b = hexdec(substr($hex, 2, 1) . substr($hex, 2, 1)); // } else { // $r = hexdec(substr($hex, 0, 2)); // $g = hexdec(substr($hex, 2, 2)); // $b = hexdec(substr($hex, 4, 2)); // } // $rgb = array($r, $g, $b); // // return implode(",", $rgb); // returns the rgb values separated by commas // // return $rgb; // returns an array with the rgb values // } }