| 1 | Index: src/wp-includes/theme.php
|
|---|
| 2 | ===================================================================
|
|---|
| 3 | --- src/wp-includes/theme.php (revision 60000)
|
|---|
| 4 | +++ src/wp-includes/theme.php (working copy)
|
|---|
| 5 | @@
|
|---|
| 6 | function get_uploaded_header_images() {
|
|---|
| 7 | - $header_images = array();
|
|---|
| 8 | -
|
|---|
| 9 | - // Grab the header images from the database.
|
|---|
| 10 | - $custom_headers = get_posts(
|
|---|
| 11 | - array(
|
|---|
| 12 | - 'post_type' => 'attachment',
|
|---|
| 13 | - 'post_mime_type' => 'image',
|
|---|
| 14 | - 'meta_key' => '_wp_attachment_is_custom_header',
|
|---|
| 15 | - 'meta_value' => get_stylesheet(),
|
|---|
| 16 | - 'orderby' => 'menu_order',
|
|---|
| 17 | - 'order' => 'ASC',
|
|---|
| 18 | - 'numberposts' => -1,
|
|---|
| 19 | - )
|
|---|
| 20 | - );
|
|---|
| 21 | -
|
|---|
| 22 | - foreach ( (array) $custom_headers as $header ) {
|
|---|
| 23 | - $url = wp_get_attachment_url( $header->ID );
|
|---|
| 24 | - $header_images[ $header->ID ] = array(
|
|---|
| 25 | - 'url' => $url,
|
|---|
| 26 | - 'thumbnail_url' => wp_get_attachment_thumb_url( $header->ID ),
|
|---|
| 27 | - 'description' => $header->post_content,
|
|---|
| 28 | - );
|
|---|
| 29 | - }
|
|---|
| 30 | -
|
|---|
| 31 | - return $header_images;
|
|---|
| 32 | + static $cached_header_images = null;
|
|---|
| 33 | + if ( null !== $cached_header_images ) {
|
|---|
| 34 | + return $cached_header_images;
|
|---|
| 35 | + }
|
|---|
| 36 | +
|
|---|
| 37 | + $header_images = array();
|
|---|
| 38 | +
|
|---|
| 39 | + // Grab the header images from the database.
|
|---|
| 40 | + $custom_headers = get_posts(
|
|---|
| 41 | + array(
|
|---|
| 42 | + 'post_type' => 'attachment',
|
|---|
| 43 | + 'post_mime_type' => 'image',
|
|---|
| 44 | + 'meta_key' => '_wp_attachment_is_custom_header',
|
|---|
| 45 | + 'meta_value' => get_stylesheet(),
|
|---|
| 46 | + 'orderby' => 'menu_order',
|
|---|
| 47 | + 'order' => 'ASC',
|
|---|
| 48 | + 'numberposts' => -1,
|
|---|
| 49 | + )
|
|---|
| 50 | + );
|
|---|
| 51 | +
|
|---|
| 52 | + foreach ( (array) $custom_headers as $header ) {
|
|---|
| 53 | + $url = wp_get_attachment_url( $header->ID );
|
|---|
| 54 | + $header_images[ $header->ID ] = array(
|
|---|
| 55 | + 'url' => $url,
|
|---|
| 56 | + 'thumbnail_url' => wp_get_attachment_thumb_url( $header->ID ),
|
|---|
| 57 | + 'description' => $header->post_content,
|
|---|
| 58 | + );
|
|---|
| 59 | + }
|
|---|
| 60 | +
|
|---|
| 61 | + $cached_header_images = $header_images;
|
|---|
| 62 | + return $cached_header_images;
|
|---|
| 63 | }
|
|---|