Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1/wp-includes/theme.php

    r18325 r18018  
    8080function get_stylesheet_uri() {
    8181    $stylesheet_dir_uri = get_stylesheet_directory_uri();
    82     $stylesheet_uri = $stylesheet_dir_uri . '/style.css';
     82    $stylesheet_uri = $stylesheet_dir_uri . "/style.css";
    8383    return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
    8484}
     
    397397        // a new theme directory and the theme header is not updated.  Whichever
    398398        // theme is first keeps the name.  Subsequent themes get a suffix applied.
    399         // The Twenty Eleven, Twenty Ten, Default and Classic themes always trump
    400         // their pretenders.
     399        // The Twenty Ten, Default and Classic themes always trump their pretenders.
    401400        if ( isset($wp_themes[$name]) ) {
    402401            $trump_cards = array(
    403                 'classic'      => 'WordPress Classic',
    404                 'default'      => 'WordPress Default',
    405                 'twentyten'    => 'Twenty Ten',
    406                 'twentyeleven' => 'Twenty Eleven',
     402                'classic'   => 'WordPress Classic',
     403                'default'   => 'WordPress Default',
     404                'twentyten' => 'Twenty Ten',
    407405            );
    408406            if ( isset( $trump_cards[ $stylesheet ] ) && $name == $trump_cards[ $stylesheet ] ) {
     
    830828    $templates[] = "category-{$category->slug}.php";
    831829    $templates[] = "category-{$category->term_id}.php";
    832     $templates[] = 'category.php';
     830    $templates[] = "category.php";
    833831
    834832    return get_query_template( 'category', $templates );
     
    854852    $templates[] = "tag-{$tag->slug}.php";
    855853    $templates[] = "tag-{$tag->term_id}.php";
    856     $templates[] = 'tag.php';
     854    $templates[] = "tag.php";
    857855
    858856    return get_query_template( 'tag', $templates );
     
    884882    $templates[] = "taxonomy-$taxonomy-{$term->slug}.php";
    885883    $templates[] = "taxonomy-$taxonomy.php";
    886     $templates[] = 'taxonomy.php';
     884    $templates[] = "taxonomy.php";
    887885
    888886    return get_query_template( 'taxonomy', $templates );
     
    966964    if ( $id )
    967965        $templates[] = "page-$id.php";
    968     $templates[] = 'page.php';
     966    $templates[] = "page.php";
    969967
    970968    return get_query_template( 'page', $templates );
     
    14301428function get_header_image() {
    14311429    $default = defined( 'HEADER_IMAGE' ) ? HEADER_IMAGE : '';
     1430
    14321431    $url = get_theme_mod( 'header_image', $default );
    1433 
    1434     if ( 'remove-header' == $url )
    1435         return false;
    1436 
    1437     if ( is_random_header_image() )
    1438         $url = get_random_header_image();
    14391432
    14401433    if ( is_ssl() )
     
    14471440
    14481441/**
    1449  * Get random header image from registered images in theme.
    1450  *
    1451  * @since 3.2.0
    1452  *
    1453  * @return string Path to header image
    1454  */
    1455 function get_random_header_image() {
    1456     global $_wp_default_headers;
    1457 
    1458     $header_image_mod = get_theme_mod( 'header_image', '' );
    1459     $headers = array();
    1460 
    1461     if ( 'random-uploaded-image' == $header_image_mod )
    1462         $headers = get_uploaded_header_images();
    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     }
    1472 
    1473     if ( empty( $headers ) )
    1474         return '';
    1475 
    1476     $random_image = array_rand( $headers );
    1477     $header_url = sprintf( $headers[$random_image]['url'], get_template_directory_uri(), get_stylesheet_directory_uri() );
    1478 
    1479     return $header_url;
    1480 }
    1481 
    1482 /**
    1483  * Check if random header image is in use.
    1484  *
    1485  * Always true if user expressly chooses the option in Appearance > Header.
    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().
    1488  *
    1489  * @since 3.2.0
    1490  * @uses HEADER_IMAGE
    1491  *
    1492  * @param string $type The random pool to use. any|default|uploaded
    1493  * @return boolean
    1494  */
    1495 function is_random_header_image( $type = 'any' ) {
    1496     $default = defined( 'HEADER_IMAGE' ) ? HEADER_IMAGE : '';
    1497     $header_image_mod = get_theme_mod( 'header_image', $default );
    1498 
    1499     if ( 'any' == $type ) {
    1500         if ( 'random-default-image' == $header_image_mod || 'random-uploaded-image' == $header_image_mod || ( '' != get_random_header_image() && empty( $header_image_mod ) ) )
    1501             return true;
    1502     } else {
    1503         if ( "random-$type-image" == $header_image_mod )
    1504             return true;
    1505         elseif ( 'default' == $type && empty( $header_image_mod ) && '' != get_random_header_image() )
    1506             return true;
    1507     }
    1508 
    1509     return false;
    1510 }
    1511 
    1512 /**
    15131442 * Display header image path.
    15141443 *
     
    15171446function header_image() {
    15181447    echo get_header_image();
    1519 }
    1520 
    1521 /**
    1522  * Get the header images uploaded for the current theme.
    1523  *
    1524  * @since 3.2.0
    1525  *
    1526  * @return array
    1527  */
    1528 function get_uploaded_header_images() {
    1529     $header_images = array();
    1530 
    1531     // @todo caching
    1532     $headers = get_posts( array( 'post_type' => 'attachment', 'meta_key' => '_wp_attachment_is_custom_header', 'meta_value' => get_option('stylesheet'), 'orderby' => 'none', 'nopaging' => true ) );
    1533 
    1534     if ( empty( $headers ) )
    1535         return array();
    1536 
    1537     foreach ( (array) $headers as $header ) {
    1538         $url = esc_url_raw( $header->guid );
    1539         $header = basename($url);
    1540         $header_images[$header] = array();
    1541         $header_images[$header]['url'] =  $url;
    1542         $header_images[$header]['thumbnail_url'] =  $url;
    1543         $header_images[$header]['uploaded'] = true;
    1544     }
    1545 
    1546     return $header_images;
    15471448}
    15481449
     
    15661467        add_action('wp_head', $header_callback);
    15671468
    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 );
     1469    add_theme_support( 'custom-header', array( 'callback' => $header_callback ) );
    15731470    add_theme_support( 'custom-header-uploads' );
    15741471
Note: See TracChangeset for help on using the changeset viewer.