* * @link https://developer.wordpress.org/themes/functionality/custom-headers/ * * @package Toocheke */ /** * Set up the WordPress core custom header feature. * * @uses toocheke_header_style() */ if ( ! function_exists( 'toocheke_custom_header_setup' ) ) : function toocheke_custom_header_setup() { add_theme_support( 'custom-header', apply_filters( 'toocheke_custom_header_args', array( 'default-image' => '', 'default-text-color' => 'ffffff', 'width' => 1920, 'height' => 320, 'flex-height' => true, 'wp-head-callback' => 'toocheke_header_style', ) ) ); } endif; add_action( 'after_setup_theme', 'toocheke_custom_header_setup' ); /** * Convert HEX to RGB. * * @since Toocheke 1.0 * * @param string $color The original color, in 3- or 6-digit hexadecimal form. * @return array Array containing RGB (red, green, and blue) values for the given * HEX code, empty array otherwise. */ function toocheke_hex2rgb( $color ) { $color = trim( $color, '#' ); if ( strlen( $color ) == 3 ) { $r = hexdec( substr( $color, 0, 1 ) . substr( $color, 0, 1 ) ); $g = hexdec( substr( $color, 1, 1 ) . substr( $color, 1, 1 ) ); $b = hexdec( substr( $color, 2, 1 ) . substr( $color, 2, 1 ) ); } elseif ( strlen( $color ) == 6 ) { $r = hexdec( substr( $color, 0, 2 ) ); $g = hexdec( substr( $color, 2, 2 ) ); $b = hexdec( substr( $color, 4, 2 ) ); } else { return array(); } return array( 'red' => $r, 'green' => $g, 'blue' => $b, ); } if ( ! function_exists( 'toocheke_header_style' ) ) : /** * Styles the header image and text displayed on the blog. * * @since Toocheke 1.0 * * @see toocheke_custom_header_setup() */ function toocheke_header_style() { $header_image = get_header_image(); // If no custom options for text are set, let's bail. if ( empty( $header_image ) && display_header_text() ) { return; } // If we get this far, we have custom styles. Let's do this. ?>