Fixes inconsistency on attachments sorting when menu_order is not defined. #992.
This commit is contained in:
parent
a36cbecc7a
commit
fe43d298fa
|
@ -404,7 +404,7 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
$args['post_parent'] = $item_id;
|
$args['post_parent'] = $item_id;
|
||||||
$args['post_type'] = 'attachment';
|
$args['post_type'] = 'attachment';
|
||||||
$args['post_status'] = 'any';
|
$args['post_status'] = 'any';
|
||||||
|
$args['orderby'] .= ' title ID';
|
||||||
unset($args['perm']);
|
unset($args['perm']);
|
||||||
|
|
||||||
$posts_query = new \WP_Query();
|
$posts_query = new \WP_Query();
|
||||||
|
@ -429,6 +429,7 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
'date' => $post->post_date,
|
'date' => $post->post_date,
|
||||||
'date_gmt' => $post->post_date_gmt,
|
'date_gmt' => $post->post_date_gmt,
|
||||||
'author' => $post->post_author,
|
'author' => $post->post_author,
|
||||||
|
'menu_order' => $post->menu_order,
|
||||||
'url' => wp_get_attachment_url( $post->ID ),
|
'url' => wp_get_attachment_url( $post->ID ),
|
||||||
'media_type' => wp_attachment_is_image( $post->ID ) ? 'image' : 'file',
|
'media_type' => wp_attachment_is_image( $post->ID ) ? 'image' : 'file',
|
||||||
'alt_text' => get_post_meta( $post->ID, '_wp_attachment_image_alt', true ),
|
'alt_text' => get_post_meta( $post->ID, '_wp_attachment_image_alt', true ),
|
||||||
|
|
|
@ -84,7 +84,7 @@ class Item extends Entity {
|
||||||
function get_attachments($exclude = null){
|
function get_attachments($exclude = null){
|
||||||
$item_id = $this->get_id();
|
$item_id = $this->get_id();
|
||||||
|
|
||||||
if(!$exclude){
|
if (!$exclude) {
|
||||||
$to_exclude = [get_post_thumbnail_id( $item_id )];
|
$to_exclude = [get_post_thumbnail_id( $item_id )];
|
||||||
if ($this->get_document_type() == 'attachment') {
|
if ($this->get_document_type() == 'attachment') {
|
||||||
$to_exclude[] = $this->get_document();
|
$to_exclude[] = $this->get_document();
|
||||||
|
@ -94,7 +94,7 @@ class Item extends Entity {
|
||||||
}
|
}
|
||||||
|
|
||||||
$attachments_query = [
|
$attachments_query = [
|
||||||
'orderby' => 'menu_order',
|
'orderby' => 'menu_order title ID',
|
||||||
'order' => 'ASC',
|
'order' => 'ASC',
|
||||||
'post_type' => 'attachment',
|
'post_type' => 'attachment',
|
||||||
'posts_per_page' => -1,
|
'posts_per_page' => -1,
|
||||||
|
|
|
@ -30,7 +30,7 @@ export default {
|
||||||
}),
|
}),
|
||||||
autoSelect: true,
|
autoSelect: true,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: 'unattached',
|
filterable: false,
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
}).open();
|
}).open();
|
||||||
|
|
Loading…
Reference in New Issue