diff --git a/wp-content/themes/twentyeleven/functions.php b/wp-content/themes/twentyeleven/functions.php index 31f80e4cc..cf3c627f9 100644 --- a/wp-content/themes/twentyeleven/functions.php +++ b/wp-content/themes/twentyeleven/functions.php @@ -109,12 +109,12 @@ function twentyeleven_setup() { // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images add_theme_support( 'post-thumbnails' ); - // The next four constants set how twentyeleven supports custom headers + // The next four constants set how Twenty Eleven supports custom headers. // The default header text color define( 'HEADER_TEXTCOLOR', '000' ); - // By leaving empty, we default to random image rotation + // By leaving empty, we allow for random image rotation. define( 'HEADER_IMAGE', '' ); // The height and width of your custom header. @@ -131,6 +131,9 @@ function twentyeleven_setup() { add_image_size( 'large-feature', HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Used for large feature (header) images add_image_size( 'small-feature', 500, 300 ); // Used for featured posts if a large-feature doesn't exist + // Turn on random header image rotation by default. + add_theme_support( 'custom-header', array( 'random-default' => true ) ); + // Add a way for the custom header to be styled in the admin panel that controls // custom headers. See twentyeleven_admin_header_style(), below. add_custom_image_header( 'twentyeleven_header_style', 'twentyeleven_admin_header_style', 'twentyeleven_admin_header_image' ); diff --git a/wp-includes/theme.php b/wp-includes/theme.php index a5d6150a2..78d97395b 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1460,8 +1460,15 @@ function get_random_header_image() { if ( 'random-uploaded-image' == $header_image_mod ) $headers = get_uploaded_header_images(); - elseif ( ! empty( $_wp_default_headers ) ) - $headers = $_wp_default_headers; + elseif ( ! empty( $_wp_default_headers ) ) { + if ( 'random-default-image' == $header_image_mod ) { + $headers = $_wp_default_headers; + } else { + $is_random = get_theme_support( 'custom-header' ); + if ( isset( $is_random[ 0 ] ) && !empty( $is_random[ 0 ][ 'random-default' ] ) ) + $headers = $_wp_default_headers; + } + } if ( empty( $headers ) ) return ''; @@ -1476,7 +1483,8 @@ function get_random_header_image() { * Check if random header image is in use. * * Always true if user expressly chooses the option in Appearance > Header. - * Also true if theme has multiple header images registered and no specific header image is chosen. + * Also true if theme has multiple header images registered, no specific header image + * is chosen, and theme turns on random headers with add_theme_support(). * * @since 3.2.0 * @uses HEADER_IMAGE @@ -1494,7 +1502,7 @@ function is_random_header_image( $type = 'any' ) { } else { if ( "random-$type-image" == $header_image_mod ) return true; - elseif ( 'default' == $type && empty( $header_image_mod ) && '' != get_random_header_image() ) + elseif ( 'default' == $type && empty( $header_image_mod ) && '' != get_random_header_image() ) return true; } @@ -1557,7 +1565,11 @@ function add_custom_image_header( $header_callback, $admin_header_callback, $adm if ( ! empty( $header_callback ) ) add_action('wp_head', $header_callback); - add_theme_support( 'custom-header', array( 'callback' => $header_callback ) ); + $support = array( 'callback' => $header_callback ); + $theme_support = get_theme_support( 'custom-header' ); + if ( ! empty( $theme_support ) && is_array( $theme_support[ 0 ] ) ) + $support = array_merge( $theme_support[ 0 ], $support ); + add_theme_support( 'custom-header', $support ); add_theme_support( 'custom-header-uploads' ); if ( ! is_admin() )