Changes from branches/3.1/wp-includes/theme.php at r18018 to trunk/wp-includes/theme.php at r18268
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/theme.php
r18018 r18268 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 } … … 828 828 $templates[] = "category-{$category->slug}.php"; 829 829 $templates[] = "category-{$category->term_id}.php"; 830 $templates[] = "category.php";830 $templates[] = 'category.php'; 831 831 832 832 return get_query_template( 'category', $templates ); … … 852 852 $templates[] = "tag-{$tag->slug}.php"; 853 853 $templates[] = "tag-{$tag->term_id}.php"; 854 $templates[] = "tag.php";854 $templates[] = 'tag.php'; 855 855 856 856 return get_query_template( 'tag', $templates ); … … 882 882 $templates[] = "taxonomy-$taxonomy-{$term->slug}.php"; 883 883 $templates[] = "taxonomy-$taxonomy.php"; 884 $templates[] = "taxonomy.php";884 $templates[] = 'taxonomy.php'; 885 885 886 886 return get_query_template( 'taxonomy', $templates ); … … 964 964 if ( $id ) 965 965 $templates[] = "page-$id.php"; 966 $templates[] = "page.php";966 $templates[] = 'page.php'; 967 967 968 968 return get_query_template( 'page', $templates ); … … 1428 1428 function get_header_image() { 1429 1429 $default = defined( 'HEADER_IMAGE' ) ? HEADER_IMAGE : ''; 1430 1431 1430 $url = get_theme_mod( 'header_image', $default ); 1431 1432 if ( 'remove-header' == $url ) 1433 return false; 1434 1435 if ( is_random_header_image() ) 1436 $url = get_random_header_image(); 1432 1437 1433 1438 if ( is_ssl() ) … … 1440 1445 1441 1446 /** 1447 * Get random header image from registered images in theme. 1448 * 1449 * @since 3.2.0 1450 * 1451 * @return string Path to header image 1452 */ 1453 function get_random_header_image() { 1454 global $_wp_default_headers; 1455 1456 $header_image_mod = get_theme_mod( 'header_image', '' ); 1457 $headers = array(); 1458 1459 if ( 'random-uploaded-image' == $header_image_mod ) 1460 $headers = get_uploaded_header_images(); 1461 elseif ( ! empty( $_wp_default_headers ) ) 1462 $headers = $_wp_default_headers; 1463 1464 if ( empty( $headers ) ) 1465 return ''; 1466 1467 $random_image = array_rand( $headers ); 1468 $header_url = sprintf( $headers[$random_image]['url'], get_template_directory_uri(), get_stylesheet_directory_uri() ); 1469 1470 return $header_url; 1471 } 1472 1473 /** 1474 * Check if random header image is in use. 1475 * 1476 * Always true if user expressly chooses the option in Appearance > Header. 1477 * Also true if theme has multiple header images registered and no specific header image is chosen. 1478 * 1479 * @since 3.2.0 1480 * @uses HEADER_IMAGE 1481 * 1482 * @param string $type The random pool to use. any|default|uploaded 1483 * @return boolean 1484 */ 1485 function is_random_header_image( $type = 'any' ) { 1486 $default = defined( 'HEADER_IMAGE' ) ? HEADER_IMAGE : ''; 1487 $header_image_mod = get_theme_mod( 'header_image', $default ); 1488 1489 if ( 'any' == $type ) { 1490 if ( 'random-default-image' == $header_image_mod || 'random-uploaded-image' == $header_image_mod || ( '' != get_random_header_image() && empty( $header_image_mod ) ) ) 1491 return true; 1492 } else { 1493 if ( "random-$type-image" == $header_image_mod ) 1494 return true; 1495 elseif ( 'default' == $type && empty( $header_image_mod ) && '' != get_random_header_image() ) 1496 return true; 1497 } 1498 1499 return false; 1500 } 1501 1502 /** 1442 1503 * Display header image path. 1443 1504 * … … 1446 1507 function header_image() { 1447 1508 echo get_header_image(); 1509 } 1510 1511 /** 1512 * Get the header images uploaded for the current theme. 1513 * 1514 * @since 3.2.0 1515 * 1516 * @return array 1517 */ 1518 function get_uploaded_header_images() { 1519 $header_images = array(); 1520 1521 // @todo caching 1522 $headers = get_posts( array( 'post_type' => 'attachment', 'meta_key' => '_wp_attachment_is_custom_header', 'meta_value' => get_option('stylesheet'), 'orderby' => 'none', 'nopaging' => true ) ); 1523 1524 if ( empty( $headers ) ) 1525 return array(); 1526 1527 foreach ( (array) $headers as $header ) { 1528 $url = esc_url_raw( $header->guid ); 1529 $header = basename($url); 1530 $header_images[$header] = array(); 1531 $header_images[$header]['url'] = $url; 1532 $header_images[$header]['thumbnail_url'] = $url; 1533 $header_images[$header]['uploaded'] = true; 1534 } 1535 1536 return $header_images; 1448 1537 } 1449 1538
Note: See TracChangeset
for help on using the changeset viewer.