+ add_theme_support( 'custom-header', array( 'callback' => $header_callback ) );
+ add_theme_support( 'custom-header-uploads' );
+
+ if ( ! is_admin() )
+ return;
+
+ global $custom_image_header;
+
+ require_once( ABSPATH . 'wp-admin/custom-header.php' );
+ $custom_image_header = new Custom_Image_Header( $admin_header_callback, $admin_image_div_callback );
+ add_action( 'admin_menu', array( &$custom_image_header, 'init' ) );
+}
+
+/**
+ * Remove image header support.
+ *
+ * @since 3.1.0
+ * @see add_custom_image_header()
+ *
+ * @return bool Whether support was removed.
+ */
+function remove_custom_image_header() {
+ if ( ! current_theme_supports( 'custom-header' ) )
+ return false;
+
+ $callback = get_theme_support( 'custom-header' );
+ remove_action( 'wp_head', $callback[0]['callback'] );
+ _remove_theme_support( 'custom-header' );
+ remove_theme_support( 'custom-header-uploads' );
+
+ if ( is_admin() ) {
+ remove_action( 'admin_menu', array( &$GLOBALS['custom_image_header'], 'init' ) );
+ unset( $GLOBALS['custom_image_header'] );
+ }
+
+ return true;
+}
+
+/**
+ * Register a selection of default headers to be displayed by the custom header admin UI.
+ *
+ * @since 3.0.0
+ *
+ * @param array $headers Array of headers keyed by a string id. The ids point to arrays containing 'url', 'thumbnail_url', and 'description' keys.
+ */
+function register_default_headers( $headers ) {
+ global $_wp_default_headers;
+
+ $_wp_default_headers = array_merge( (array) $_wp_default_headers, (array) $headers );
+}
+
+/**
+ * Unregister default headers.
+ *
+ * This function must be called after register_default_headers() has already added the
+ * header you want to remove.
+ *
+ * @see register_default_headers()
+ * @since 3.0.0
+ *
+ * @param string|array $header The header string id (key of array) to remove, or an array thereof.
+ * @return True on success, false on failure.
+ */
+function unregister_default_headers( $header ) {
+ global $_wp_default_headers;
+ if ( is_array( $header ) ) {
+ array_map( 'unregister_default_headers', $header );
+ } elseif ( isset( $_wp_default_headers[ $header ] ) ) {
+ unset( $_wp_default_headers[ $header ] );
+ return true;
+ } else {
+ return false;
+ }
+}
+
+/**
+ * Retrieve background image for custom background.
+ *
+ * @since 3.0.0
+ *
+ * @return string
+ */
+function get_background_image() {
+ $default = defined('BACKGROUND_IMAGE') ? BACKGROUND_IMAGE : '';
+
+ return get_theme_mod('background_image', $default);
+}
+
+/**
+ * Display background image path.
+ *
+ * @since 3.0.0
+ */
+function background_image() {
+ echo get_background_image();
+}
+
+/**
+ * Retrieve value for custom background color.
+ *
+ * @since 3.0.0
+ * @uses BACKGROUND_COLOR
+ *
+ * @return string
+ */
+function get_background_color() {
+ $default = defined('BACKGROUND_COLOR') ? BACKGROUND_COLOR : '';
+
+ return get_theme_mod('background_color', $default);
+}
+
+/**
+ * Display background color value.
+ *
+ * @since 3.0.0
+ */
+function background_color() {
+ echo get_background_color();
+}
+
+/**
+ * Add callbacks for background image display.
+ *
+ * The parameter $header_callback callback will be required to display the
+ * content for the 'wp_head' action. The parameter $admin_header_callback
+ * callback will be added to Custom_Background class and that will be added
+ * to the 'admin_menu' action.
+ *
+ * @since 3.0.0
+ * @uses Custom_Background Sets up for $admin_header_callback for administration panel display.
+ *
+ * @param callback $header_callback Call on 'wp_head' action.
+ * @param callback $admin_header_callback Call on custom background administration screen.
+ * @param callback $admin_image_div_callback Output a custom background image div on the custom background administration screen. Optional.
+ */
+function add_custom_background( $header_callback = '', $admin_header_callback = '', $admin_image_div_callback = '' ) {
+ if ( isset( $GLOBALS['custom_background'] ) )
+ return;
+
+ if ( empty( $header_callback ) )
+ $header_callback = '_custom_background_cb';
+
+ add_action( 'wp_head', $header_callback );
+
+ add_theme_support( 'custom-background', array( 'callback' => $header_callback ) );
+