Make WordPress Core

Ticket #21785: consolidated-query-logic-1.diff

File consolidated-query-logic-1.diff, 2.0 KB (added by mcsf, 11 years ago)
  • src/wp-admin/custom-header.php

    diff --git a/src/wp-admin/custom-header.php b/src/wp-admin/custom-header.php
    index aad5472..11713c9 100644
    a b wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> 
    12801280
    12811281        public function get_uploaded_header_images() {
    12821282                $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet();
    1283                 $header_images = array();
    12841283
    1285                 $headers_not_dated = get_posts( array(
     1284                $headers_all = get_posts( array(
    12861285                        'post_type' => 'attachment',
    12871286                        'meta_key' => '_wp_attachment_is_custom_header',
    12881287                        'meta_value' => get_option('stylesheet'),
    12891288                        'orderby' => 'none',
    12901289                        'nopaging' => true,
    1291                         'meta_query' => array(
    1292                                 array(
    1293                                         'key' => '_wp_attachment_is_custom_header',
    1294                                         'value' => get_option( 'stylesheet' ),
    1295                                         'compare' => 'LIKE'
    1296                                 ),
    1297                                 array(
    1298                                         'key' => $key,
    1299                                         'value' => 'this string must not be empty',
    1300                                         'compare' => 'NOT EXISTS'
    1301                                 ),
    1302                         )
    13031290                ) );
    13041291
    1305                 $headers_dated = get_posts( array(
    1306                         'post_type' => 'attachment',
    1307                         'meta_key' => $key,
    1308                         'orderby' => 'meta_value_num',
    1309                         'order' => 'DESC',
    1310                         'nopaging' => true,
    1311                         'meta_query' => array(
    1312                                 array(
    1313                                         'key' => '_wp_attachment_is_custom_header',
    1314                                         'value' => get_option( 'stylesheet' ),
    1315                                         'compare' => 'LIKE'
    1316                                 ),
    1317                         ),
    1318                 ) );
    1319 
    1320                 $limit = apply_filters( 'custom_header_uploaded_limit', 15 );
    1321                 $headers = array_merge( $headers_dated, $headers_not_dated );
    1322                 $headers = array_slice( $headers, 0, $limit );
    1323 
    1324                 foreach ( (array) $headers as $header ) {
     1292                $header_images = array();
     1293                foreach ( (array) $headers_all as $header ) {
    13251294                        $url = esc_url_raw( $header->guid );
    13261295                        $header_data = wp_get_attachment_metadata( $header->ID );
    1327                         $timestamp = get_post_meta( $header->ID,
    1328                                 '_wp_attachment_custom_header_last_used_' . get_stylesheet(),
    1329                                 true );
     1296                        $timestamp = get_post_meta( $header->ID, $key, true );
    13301297
    13311298                        $h = array(
    13321299                                'attachment_id' => $header->ID,