diff --git a/src/wp-admin/custom-header.php b/src/wp-admin/custom-header.php
index aad5472..8a07aa7 100644
a
|
b
|
wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> |
1278 | 1278 | return $header_images; |
1279 | 1279 | } |
1280 | 1280 | |
| 1281 | private function cmp_headers($a, $b) { |
| 1282 | $a_timestamp = absint( $a->_wp_attachment_custom_header_last_used ); |
| 1283 | $b_timestamp = absint( $b->_wp_attachment_custom_header_last_used ); |
| 1284 | if ( $a_timestamp == $b_timestamp ) { |
| 1285 | return 0; |
| 1286 | } |
| 1287 | return ( $a_timestamp > $b_timestamp ) ? -1 : 1; |
| 1288 | } |
| 1289 | |
1281 | 1290 | public function get_uploaded_header_images() { |
1282 | 1291 | $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
1283 | | $header_images = array(); |
1284 | 1292 | |
1285 | | $headers_not_dated = get_posts( array( |
| 1293 | $headers_all = get_posts( array( |
1286 | 1294 | 'post_type' => 'attachment', |
1287 | 1295 | 'meta_key' => '_wp_attachment_is_custom_header', |
1288 | 1296 | 'meta_value' => get_option('stylesheet'), |
1289 | 1297 | 'orderby' => 'none', |
1290 | 1298 | '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 | | ) |
1303 | 1299 | ) ); |
1304 | 1300 | |
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 | | ) ); |
| 1301 | $headers = array(); |
| 1302 | foreach ( $headers_all as $header ) { |
| 1303 | $header->_wp_attachment_custom_header_last_used = get_post_meta( $header->ID, $key, true ); |
| 1304 | $headers[] = $header; |
| 1305 | } |
1319 | 1306 | |
| 1307 | usort( $headers, array( $this, 'cmp_headers' ) ); |
1320 | 1308 | $limit = apply_filters( 'custom_header_uploaded_limit', 15 ); |
1321 | | $headers = array_merge( $headers_dated, $headers_not_dated ); |
1322 | 1309 | $headers = array_slice( $headers, 0, $limit ); |
1323 | 1310 | |
| 1311 | $header_images = array(); |
1324 | 1312 | foreach ( (array) $headers as $header ) { |
1325 | 1313 | $url = esc_url_raw( $header->guid ); |
1326 | 1314 | $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 ); |
| 1315 | $timestamp = $header->_wp_attachment_custom_header_last_used; |
1330 | 1316 | |
1331 | 1317 | $h = array( |
1332 | 1318 | 'attachment_id' => $header->ID, |