var Attachment, Attachments, Query, PostImage, compare, l10n, media;
/**
- * wp.media( attributes )
+ * Create and return a media frame.
*
* Handles the default media experience. Automatically creates
* and opens a media frame, and returns the result.
frame = new MediaFrame.Select( attributes );
} else if ( 'post' === attributes.frame && MediaFrame.Post ) {
frame = new MediaFrame.Post( attributes );
+ } else if ( 'manage' === attributes.frame && MediaFrame.Manage ) {
+ frame = new MediaFrame.Manage( attributes );
} else if ( 'image' === attributes.frame && MediaFrame.ImageDetails ) {
frame = new MediaFrame.ImageDetails( attributes );
} else if ( 'audio' === attributes.frame && MediaFrame.AudioDetails ) {
frame = new MediaFrame.AudioDetails( attributes );
} else if ( 'video' === attributes.frame && MediaFrame.VideoDetails ) {
frame = new MediaFrame.VideoDetails( attributes );
+ } else if ( 'edit-attachments' === attributes.frame && MediaFrame.EditAttachments ) {
+ frame = new MediaFrame.EditAttachments( attributes );
}
delete attributes.frame;
/**
* @access private
*/
- _requery: function() {
+ _requery: function( refresh ) {
+ var props;
if ( this.props.get('query') ) {
- this.mirror( Query.get( this.props.toJSON() ) );
+ props = this.props.toJSON();
+ props.cache = ( true !== refresh );
+ this.mirror( Query.get( props ) );
}
},
/**
}
return uploadedTo === attachment.get('uploadedTo');
+ },
+ /**
+ * @static
+ * @param {wp.media.model.Attachment} attachment
+ *
+ * @this wp.media.model.Attachments
+ *
+ * @returns {Boolean}
+ */
+ status: function( attachment ) {
+ var status = this.props.get('status');
+ if ( _.isUndefined( status ) ) {
+ return true;
+ }
+
+ return status === attachment.get('status');
}
}
});
'type': 'post_mime_type',
'perPage': 'posts_per_page',
'menuOrder': 'menu_order',
- 'uploadedTo': 'post_parent'
+ 'uploadedTo': 'post_parent',
+ 'status': 'post_status'
},
/**
* @static
var args = {},
orderby = Query.orderby,
defaults = Query.defaultProps,
- query;
+ query,
+ cache = !! props.cache || _.isUndefined( props.cache );
// Remove the `query` property. This isn't linked to a query,
// this *is* the query.
delete props.query;
+ delete props.cache;
// Fill default args.
_.defaults( props, defaults );
args.orderby = orderby.valuemap[ props.orderby ] || props.orderby;
// Search the query cache for matches.
- query = _.find( queries, function( query ) {
- return _.isEqual( query.args, args );
- });
+ if ( cache ) {
+ query = _.find( queries, function( query ) {
+ return _.isEqual( query.args, args );
+ });
+ } else {
+ queries = [];
+ }
// Otherwise, create a new query and add it to the cache.
if ( ! query ) {