Changes from branches/3.1/wp-includes/theme.php at r18018 to trunk/wp-includes/theme.php at r18325
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/theme.php
r18018 r18325 80 80 function get_stylesheet_uri() { 81 81 $stylesheet_dir_uri = get_stylesheet_directory_uri(); 82 $stylesheet_uri = $stylesheet_dir_uri . "/style.css";82 $stylesheet_uri = $stylesheet_dir_uri . '/style.css'; 83 83 return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri); 84 84 } … … 397 397 // a new theme directory and the theme header is not updated. Whichever 398 398 // theme is first keeps the name. Subsequent themes get a suffix applied. 399 // The Twenty Ten, Default and Classic themes always trump their pretenders. 399 // The Twenty Eleven, Twenty Ten, Default and Classic themes always trump 400 // their pretenders. 400 401 if ( isset($wp_themes[$name]) ) { 401 402 $trump_cards = array( 402 'classic' => 'WordPress Classic', 403 'default' => 'WordPress Default', 404 'twentyten' => 'Twenty Ten', 403 'classic' => 'WordPress Classic', 404 'default' => 'WordPress Default', 405 'twentyten' => 'Twenty Ten', 406 'twentyeleven' => 'Twenty Eleven', 405 407 ); 406 408 if ( isset( $trump_cards[ $stylesheet ] ) && $name == $trump_cards[ $stylesheet ] ) { … … 828 830 $templates[] = "category-{$category->slug}.php"; 829 831 $templates[] = "category-{$category->term_id}.php"; 830 $templates[] = "category.php";832 $templates[] = 'category.php'; 831 833 832 834 return get_query_template( 'category', $templates ); … … 852 854 $templates[] = "tag-{$tag->slug}.php"; 853 855 $templates[] = "tag-{$tag->term_id}.php"; 854 $templates[] = "tag.php";856 $templates[] = 'tag.php'; 855 857 856 858 return get_query_template( 'tag', $templates ); … … 882 884 $templates[] = "taxonomy-$taxonomy-{$term->slug}.php"; 883 885 $templates[] = "taxonomy-$taxonomy.php"; 884 $templates[] = "taxonomy.php";886 $templates[] = 'taxonomy.php'; 885 887 886 888 return get_query_template( 'taxonomy', $templates ); … … 964 966 if ( $id ) 965 967 $templates[] = "page-$id.php"; 966 $templates[] = "page.php";968 $templates[] = 'page.php'; 967 969 968 970 return get_query_template( 'page', $templates ); … … 1428 1430 function get_header_image() { 1429 1431 $default = defined( 'HEADER_IMAGE' ) ? HEADER_IMAGE : ''; 1430 1431 1432 $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(); 1432 1439 1433 1440 if ( is_ssl() ) … … 1440 1447 1441 1448 /** 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 /** 1442 1513 * Display header image path. 1443 1514 * … … 1446 1517 function header_image() { 1447 1518 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; 1448 1547 } 1449 1548 … … 1467 1566 add_action('wp_head', $header_callback); 1468 1567 1469 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 ); 1470 1573 add_theme_support( 'custom-header-uploads' ); 1471 1574
Note: See TracChangeset
for help on using the changeset viewer.