- // The next four constants set how Twenty Eleven supports custom headers.
-
- // The default header text color
- define( 'HEADER_TEXTCOLOR', '000' );
-
- // By leaving empty, we allow for random image rotation.
- define( 'HEADER_IMAGE', '' );
-
- // The height and width of your custom header.
- // Add a filter to twentyeleven_header_image_width and twentyeleven_header_image_height to change these values.
- define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyeleven_header_image_width', 1000 ) );
- define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyeleven_header_image_height', 288 ) );
+ // Add support for custom headers.
+ $custom_header_support = array(
+ // The default header text color.
+ 'default-text-color' => '000',
+ // The height and width of our custom header.
+ 'width' => apply_filters( 'twentyeleven_header_image_width', 1000 ),
+ 'height' => apply_filters( 'twentyeleven_header_image_height', 288 ),
+ // Support flexible heights.
+ 'flex-height' => true,
+ // Random image rotation by default.
+ 'random-default' => true,
+ // Callback for styling the header.
+ 'wp-head-callback' => 'twentyeleven_header_style',
+ // Callback for styling the header preview in the admin.
+ 'admin-head-callback' => 'twentyeleven_admin_header_style',
+ // Callback used to display the header preview in the admin.
+ 'admin-preview-callback' => 'twentyeleven_admin_header_image',
+ );
+
+ add_theme_support( 'custom-header', $custom_header_support );
+
+ if ( ! function_exists( 'get_custom_header' ) ) {
+ // This is all for compatibility with versions of WordPress prior to 3.4.
+ define( 'HEADER_TEXTCOLOR', $custom_header_support['default-text-color'] );
+ define( 'HEADER_IMAGE', '' );
+ define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
+ define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
+ add_custom_image_header( $custom_header_support['wp-head-callback'], $custom_header_support['admin-head-callback'], $custom_header_support['admin-preview-callback'] );
+ add_custom_background();
+ }