WordPress.org

Make WordPress Core

Changeset 18325


Ignore:
Timestamp:
06/22/2011 07:09:23 PM (9 years ago)
Author:
ryan
Message:

Add theme support option for turning on random default headers. fixes #17832

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentyeleven/functions.php

    r18304 r18325  
    110110    add_theme_support( 'post-thumbnails' );
    111111
    112     // The next four constants set how twentyeleven supports custom headers
     112    // The next four constants set how Twenty Eleven supports custom headers.
    113113
    114114    // The default header text color
    115115    define( 'HEADER_TEXTCOLOR', '000' );
    116116
    117     // By leaving empty, we default to random image rotation
     117    // By leaving empty, we allow for random image rotation.
    118118    define( 'HEADER_IMAGE', '' );
    119119
     
    131131    add_image_size( 'large-feature', HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Used for large feature (header) images
    132132    add_image_size( 'small-feature', 500, 300 ); // Used for featured posts if a large-feature doesn't exist
     133
     134    // Turn on random header image rotation by default.
     135    add_theme_support( 'custom-header', array( 'random-default' => true ) );
    133136
    134137    // Add a way for the custom header to be styled in the admin panel that controls
  • trunk/wp-includes/theme.php

    r18322 r18325  
    14611461    if ( 'random-uploaded-image' == $header_image_mod )
    14621462        $headers = get_uploaded_header_images();
    1463     elseif ( ! empty( $_wp_default_headers ) )
    1464         $headers = $_wp_default_headers;
     1463    elseif ( ! empty( $_wp_default_headers ) ) {
     1464        if ( 'random-default-image' == $header_image_mod ) {
     1465            $headers = $_wp_default_headers;
     1466        } else {
     1467            $is_random = get_theme_support( 'custom-header' );
     1468            if ( isset( $is_random[ 0 ] ) && !empty( $is_random[ 0 ][ 'random-default' ] ) )
     1469                $headers = $_wp_default_headers;
     1470        }
     1471    }
    14651472
    14661473    if ( empty( $headers ) )
     
    14771484 *
    14781485 * Always true if user expressly chooses the option in Appearance > Header.
    1479  * Also true if theme has multiple header images registered and no specific header image is chosen.
     1486 * Also true if theme has multiple header images registered, no specific header image
     1487 * is chosen, and theme turns on random headers with add_theme_support().
    14801488 *
    14811489 * @since 3.2.0
     
    14951503        if ( "random-$type-image" == $header_image_mod )
    14961504            return true;
    1497         elseif ( 'default' == $type && empty( $header_image_mod ) && '' != get_random_header_image()  )
     1505        elseif ( 'default' == $type && empty( $header_image_mod ) && '' != get_random_header_image() )
    14981506            return true;
    14991507    }
     
    15581566        add_action('wp_head', $header_callback);
    15591567
    1560     add_theme_support( 'custom-header', array( 'callback' => $header_callback ) );
     1568    $support = array( 'callback' => $header_callback );
     1569    $theme_support = get_theme_support( 'custom-header' );
     1570    if ( ! empty( $theme_support ) && is_array( $theme_support[ 0 ] ) )
     1571        $support = array_merge( $theme_support[ 0 ], $support );
     1572    add_theme_support( 'custom-header',  $support );
    15611573    add_theme_support( 'custom-header-uploads' );
    15621574
Note: See TracChangeset for help on using the changeset viewer.