When editing a plain, legacy [gallery] shortcode, ensure we are sorting its contents using menu_order.
When attachments are sorted, we convert the shortcode to [gallery ids=""], as before. props koopersmith. fixes #22608. git-svn-id: http://core.svn.wordpress.org/trunk@22882 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0464ec77b5
commit
dd3cd96bac
|
@ -157,7 +157,8 @@
|
|||
icontag: 'dt',
|
||||
captiontag: 'dd',
|
||||
columns: 3,
|
||||
size: 'thumbnail'
|
||||
size: 'thumbnail',
|
||||
orderby: 'menu_order ID'
|
||||
},
|
||||
|
||||
attachments: function( shortcode ) {
|
||||
|
@ -170,12 +171,17 @@
|
|||
if ( result )
|
||||
return result;
|
||||
|
||||
attrs = shortcode.attrs.named;
|
||||
// Fill the default shortcode attributes.
|
||||
attrs = _.defaults( shortcode.attrs.named, wp.media.gallery.defaults );
|
||||
args = _.pick( attrs, 'orderby', 'order' );
|
||||
|
||||
args.type = 'image';
|
||||
args.perPage = -1;
|
||||
|
||||
// Map the `orderby` attribute to the corresponding model property.
|
||||
if ( ! attrs.orderby || /^menu_order(?: ID)?$/i.test( attrs.orderby ) )
|
||||
args.orderby = 'menuOrder';
|
||||
|
||||
// Map the `ids` param to the correct query args.
|
||||
if ( attrs.ids ) {
|
||||
args.post__in = attrs.ids.split(',');
|
||||
|
@ -204,14 +210,21 @@
|
|||
|
||||
shortcode: function( attachments ) {
|
||||
var props = attachments.props.toJSON(),
|
||||
attrs = _.pick( props, 'include', 'exclude', 'orderby', 'order' ),
|
||||
attrs = _.pick( props, 'orderby', 'order' ),
|
||||
shortcode, clone;
|
||||
|
||||
if ( attachments.gallery )
|
||||
_.extend( attrs, attachments.gallery.toJSON() );
|
||||
|
||||
// Convert all gallery shortcodes to use the `ids` property.
|
||||
// Ignore `post__in` and `post__not_in`; the attachments in
|
||||
// the collection will already reflect those properties.
|
||||
attrs.ids = attachments.pluck('id');
|
||||
|
||||
// Copy the `parent` post ID.
|
||||
if ( props.parent )
|
||||
attrs.id = props.parent;
|
||||
|
||||
// If the `ids` attribute is set and `orderby` attribute
|
||||
// is the default value, clear it for cleaner output.
|
||||
if ( attrs.ids && 'post__in' === attrs.orderby )
|
||||
|
@ -272,7 +285,12 @@
|
|||
selection.props.unset('orderby');
|
||||
});
|
||||
|
||||
return wp.media({
|
||||
// Destroy the previous gallery frame.
|
||||
if ( this.frame )
|
||||
this.frame.dispose();
|
||||
|
||||
// Store the current gallery frame.
|
||||
this.frame = wp.media({
|
||||
frame: 'post',
|
||||
state: 'gallery-edit',
|
||||
title: wp.media.view.l10n.editGalleryTitle,
|
||||
|
@ -280,6 +298,8 @@
|
|||
multiple: true,
|
||||
selection: selection
|
||||
});
|
||||
|
||||
return this.frame;
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
|
|
@ -659,10 +659,11 @@ window.wp = window.wp || {};
|
|||
},
|
||||
|
||||
orderby: {
|
||||
allowed: [ 'name', 'author', 'date', 'title', 'modified', 'uploadedTo', 'id', 'post__in' ],
|
||||
allowed: [ 'name', 'author', 'date', 'title', 'modified', 'uploadedTo', 'id', 'post__in', 'menuOrder' ],
|
||||
valuemap: {
|
||||
'id': 'ID',
|
||||
'uploadedTo': 'parent'
|
||||
'uploadedTo': 'parent',
|
||||
'menuOrder': 'menu_order ID'
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -670,7 +671,8 @@ window.wp = window.wp || {};
|
|||
'search': 's',
|
||||
'type': 'post_mime_type',
|
||||
'parent': 'post_parent',
|
||||
'perPage': 'posts_per_page'
|
||||
'perPage': 'posts_per_page',
|
||||
'menuOrder': 'menu_order'
|
||||
},
|
||||
|
||||
// Caches query objects so queries can be easily reused.
|
||||
|
|
|
@ -2898,7 +2898,9 @@
|
|||
all: {
|
||||
text: l10n.allMediaItems,
|
||||
props: {
|
||||
parent: null
|
||||
parent: null,
|
||||
orderby: 'date',
|
||||
order: 'DESC'
|
||||
},
|
||||
priority: 10
|
||||
},
|
||||
|
@ -2906,7 +2908,9 @@
|
|||
uploaded: {
|
||||
text: l10n.uploadedToThisPost,
|
||||
props: {
|
||||
parent: media.view.settings.postId
|
||||
parent: media.view.settings.postId,
|
||||
orderby: 'menuOrder',
|
||||
order: 'ASC'
|
||||
},
|
||||
priority: 20
|
||||
}
|
||||
|
@ -2922,7 +2926,9 @@
|
|||
text: text,
|
||||
props: {
|
||||
type: key,
|
||||
parent: null
|
||||
parent: null,
|
||||
orderby: 'date',
|
||||
order: 'DESC'
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -2931,7 +2937,9 @@
|
|||
text: l10n.allMediaItems,
|
||||
props: {
|
||||
type: null,
|
||||
parent: null
|
||||
parent: null,
|
||||
orderby: 'date',
|
||||
order: 'DESC'
|
||||
},
|
||||
priority: 10
|
||||
};
|
||||
|
@ -2940,7 +2948,9 @@
|
|||
text: l10n.uploadedToThisPost,
|
||||
props: {
|
||||
type: null,
|
||||
parent: media.view.settings.postId
|
||||
parent: media.view.settings.postId,
|
||||
orderby: 'menuOrder',
|
||||
order: 'ASC'
|
||||
},
|
||||
priority: 20
|
||||
};
|
||||
|
|
|
@ -1327,6 +1327,7 @@ function wp_prepare_attachment_for_js( $attachment ) {
|
|||
'uploadedTo' => $attachment->post_parent,
|
||||
'date' => strtotime( $attachment->post_date_gmt ) * 1000,
|
||||
'modified' => strtotime( $attachment->post_modified_gmt ) * 1000,
|
||||
'menuOrder' => $attachment->menu_order,
|
||||
'mime' => $attachment->post_mime_type,
|
||||
'type' => $type,
|
||||
'subtype' => $subtype,
|
||||
|
|
Loading…
Reference in New Issue