diff --git a/wp-admin/custom-header.php b/wp-admin/custom-header.php index 27afb9c6ee..0f1856d6b5 100644 --- a/wp-admin/custom-header.php +++ b/wp-admin/custom-header.php @@ -42,6 +42,16 @@ class Custom_Image_Header { */ var $default_headers = array(); + + /** + * Holds custom headers uploaded by the user + * + * @var array + * @since 3.2.0 + * @access private + */ + var $uploaded_headers = array(); + /** * Holds the page menu hook. * @@ -199,11 +209,20 @@ class Custom_Image_Header { } } - if ( isset($_POST['default-header']) ) { + if ( isset( $_POST['default-header'] ) ) { check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); - $this->process_default_headers(); - if ( isset($this->default_headers[$_POST['default-header']]) ) - set_theme_mod('header_image', esc_url($this->default_headers[$_POST['default-header']]['url'])); + if ( 'random-default-image' == $_POST['default-header'] ) { + set_theme_mod( 'header_image', 'random-default-image' ); + } elseif ( 'random-uploaded-image' == $_POST['default-header'] ) { + set_theme_mod( 'header_image', 'random-uploaded-image' ); + } else { + $this->process_default_headers(); + $uploaded = get_uploaded_header_images(); + if ( isset( $uploaded[$_POST['default-header']] ) ) + set_theme_mod( 'header_image', esc_url( $uploaded[$_POST['default-header']]['url'] ) ); + elseif ( isset( $this->default_headers[$_POST['default-header']] ) ) + set_theme_mod( 'header_image', esc_url( $this->default_headers[$_POST['default-header']]['url'] ) ); + } } } @@ -226,22 +245,43 @@ class Custom_Image_Header { $this->default_headers[$header]['url'] = sprintf( $this->default_headers[$header]['url'], get_template_directory_uri(), get_stylesheet_directory_uri() ); $this->default_headers[$header]['thumbnail_url'] = sprintf( $this->default_headers[$header]['thumbnail_url'], get_template_directory_uri(), get_stylesheet_directory_uri() ); } + } /** * Display UI for selecting one of several default headers. * + * Show the random image option if this theme has multiple header images. + * Random image option is on by default if no header has been set. + * * @since 3.0.0 */ - function show_default_header_selector() { + function show_header_selector( $type = 'default' ) { echo '