Changes from trunk/wp-includes/theme.php at r18325 to branches/3.1/wp-includes/theme.php at r18018
- File:
-
- 1 edited
-
branches/3.1/wp-includes/theme.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/wp-includes/theme.php
r18325 r18018 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 Eleven, Twenty Ten, Default and Classic themes always trump 400 // their pretenders. 399 // The Twenty Ten, Default and Classic themes always trump their pretenders. 401 400 if ( isset($wp_themes[$name]) ) { 402 401 $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', 407 405 ); 408 406 if ( isset( $trump_cards[ $stylesheet ] ) && $name == $trump_cards[ $stylesheet ] ) { … … 830 828 $templates[] = "category-{$category->slug}.php"; 831 829 $templates[] = "category-{$category->term_id}.php"; 832 $templates[] = 'category.php';830 $templates[] = "category.php"; 833 831 834 832 return get_query_template( 'category', $templates ); … … 854 852 $templates[] = "tag-{$tag->slug}.php"; 855 853 $templates[] = "tag-{$tag->term_id}.php"; 856 $templates[] = 'tag.php';854 $templates[] = "tag.php"; 857 855 858 856 return get_query_template( 'tag', $templates ); … … 884 882 $templates[] = "taxonomy-$taxonomy-{$term->slug}.php"; 885 883 $templates[] = "taxonomy-$taxonomy.php"; 886 $templates[] = 'taxonomy.php';884 $templates[] = "taxonomy.php"; 887 885 888 886 return get_query_template( 'taxonomy', $templates ); … … 966 964 if ( $id ) 967 965 $templates[] = "page-$id.php"; 968 $templates[] = 'page.php';966 $templates[] = "page.php"; 969 967 970 968 return get_query_template( 'page', $templates ); … … 1430 1428 function get_header_image() { 1431 1429 $default = defined( 'HEADER_IMAGE' ) ? HEADER_IMAGE : ''; 1430 1432 1431 $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();1439 1432 1440 1433 if ( is_ssl() ) … … 1447 1440 1448 1441 /** 1449 * Get random header image from registered images in theme.1450 *1451 * @since 3.2.01452 *1453 * @return string Path to header image1454 */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 image1487 * is chosen, and theme turns on random headers with add_theme_support().1488 *1489 * @since 3.2.01490 * @uses HEADER_IMAGE1491 *1492 * @param string $type The random pool to use. any|default|uploaded1493 * @return boolean1494 */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 /**1513 1442 * Display header image path. 1514 1443 * … … 1517 1446 function header_image() { 1518 1447 echo get_header_image(); 1519 }1520 1521 /**1522 * Get the header images uploaded for the current theme.1523 *1524 * @since 3.2.01525 *1526 * @return array1527 */1528 function get_uploaded_header_images() {1529 $header_images = array();1530 1531 // @todo caching1532 $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;1547 1448 } 1548 1449 … … 1566 1467 add_action('wp_head', $header_callback); 1567 1468 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 ) ); 1573 1470 add_theme_support( 'custom-header-uploads' ); 1574 1471
Note: See TracChangeset
for help on using the changeset viewer.