mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-28 15:17:42 +02:00
Privacy: add "Mine" filter for media similarly to posts and comments.
Props audrasjb. See #43820. Built from https://develop.svn.wordpress.org/trunk@43056 git-svn-id: http://core.svn.wordpress.org/trunk@42885 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f4e6b7a29c
commit
3266b10d04
@ -2627,6 +2627,7 @@ function wp_ajax_query_attachments() {
|
|||||||
'paged',
|
'paged',
|
||||||
'post_mime_type',
|
'post_mime_type',
|
||||||
'post_parent',
|
'post_parent',
|
||||||
|
'author',
|
||||||
'post__in',
|
'post__in',
|
||||||
'post__not_in',
|
'post__not_in',
|
||||||
'year',
|
'year',
|
||||||
|
@ -130,6 +130,13 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||||||
_x( 'Trash', 'attachment filter' )
|
_x( 'Trash', 'attachment filter' )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$type_links['mine'] = sprintf(
|
||||||
|
'<option value="mine"%s>%s</option>',
|
||||||
|
selected( 'mine' === $filter, true, false ),
|
||||||
|
__( 'Mine' )
|
||||||
|
);
|
||||||
|
|
||||||
return $type_links;
|
return $type_links;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1211,6 +1211,10 @@ function wp_edit_attachments_query_vars( $q = false ) {
|
|||||||
$q['post_parent'] = 0;
|
$q['post_parent'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( isset( $q['mine'] ) || ( isset( $q['attachment-filter'] ) && 'mine' == $q['attachment-filter'] ) ) {
|
||||||
|
$q['author'] = get_current_user_id();
|
||||||
|
}
|
||||||
|
|
||||||
// Filter query clauses to include filenames.
|
// Filter query clauses to include filenames.
|
||||||
if ( isset( $q['s'] ) ) {
|
if ( isset( $q['s'] ) ) {
|
||||||
add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
|
add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
|
||||||
|
@ -1121,7 +1121,7 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{
|
|||||||
// Only observe when a limited number of query args are set. There
|
// Only observe when a limited number of query args are set. There
|
||||||
// are no filters for other properties, so observing will result in
|
// are no filters for other properties, so observing will result in
|
||||||
// false positives in those queries.
|
// false positives in those queries.
|
||||||
allowed = [ 's', 'order', 'orderby', 'posts_per_page', 'post_mime_type', 'post_parent' ];
|
allowed = [ 's', 'order', 'orderby', 'posts_per_page', 'post_mime_type', 'post_parent', 'author' ];
|
||||||
if ( wp.Uploader && _( this.args ).chain().keys().difference( allowed ).isEmpty().value() ) {
|
if ( wp.Uploader && _( this.args ).chain().keys().difference( allowed ).isEmpty().value() ) {
|
||||||
this.observe( wp.Uploader.queue );
|
this.observe( wp.Uploader.queue );
|
||||||
}
|
}
|
||||||
@ -1238,14 +1238,15 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{
|
|||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
propmap: {
|
propmap: {
|
||||||
'search': 's',
|
'search': 's',
|
||||||
'type': 'post_mime_type',
|
'type': 'post_mime_type',
|
||||||
'perPage': 'posts_per_page',
|
'perPage': 'posts_per_page',
|
||||||
'menuOrder': 'menu_order',
|
'menuOrder': 'menu_order',
|
||||||
'uploadedTo': 'post_parent',
|
'uploadedTo': 'post_parent',
|
||||||
'status': 'post_status',
|
'status': 'post_status',
|
||||||
'include': 'post__in',
|
'include': 'post__in',
|
||||||
'exclude': 'post__not_in'
|
'exclude': 'post__not_in',
|
||||||
|
'author': 'author'
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Creates and returns an Attachments Query collection given the properties.
|
* Creates and returns an Attachments Query collection given the properties.
|
||||||
@ -1267,6 +1268,7 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{
|
|||||||
* @param {Object} [props.menu_order]
|
* @param {Object} [props.menu_order]
|
||||||
* @param {Object} [props.post_parent]
|
* @param {Object} [props.post_parent]
|
||||||
* @param {Object} [props.post_status]
|
* @param {Object} [props.post_status]
|
||||||
|
* @param {Object} [props.author]
|
||||||
* @param {Object} [options]
|
* @param {Object} [options]
|
||||||
*
|
*
|
||||||
* @returns {wp.media.model.Query} A new Attachments Query collection.
|
* @returns {wp.media.model.Query} A new Attachments Query collection.
|
||||||
|
2
wp-includes/js/media-models.min.js
vendored
2
wp-includes/js/media-models.min.js
vendored
File diff suppressed because one or more lines are too long
@ -7251,6 +7251,7 @@ Uploaded = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.Attac
|
|||||||
createFilters: function() {
|
createFilters: function() {
|
||||||
var type = this.model.get('type'),
|
var type = this.model.get('type'),
|
||||||
types = wp.media.view.settings.mimeTypes,
|
types = wp.media.view.settings.mimeTypes,
|
||||||
|
uid = window.userSettings ? parseInt( window.userSettings.uid, 10 ) : 0,
|
||||||
text;
|
text;
|
||||||
|
|
||||||
if ( types && type ) {
|
if ( types && type ) {
|
||||||
@ -7263,7 +7264,8 @@ Uploaded = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.Attac
|
|||||||
props: {
|
props: {
|
||||||
uploadedTo: null,
|
uploadedTo: null,
|
||||||
orderby: 'date',
|
orderby: 'date',
|
||||||
order: 'DESC'
|
order: 'DESC',
|
||||||
|
author: null
|
||||||
},
|
},
|
||||||
priority: 10
|
priority: 10
|
||||||
},
|
},
|
||||||
@ -7273,7 +7275,8 @@ Uploaded = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.Attac
|
|||||||
props: {
|
props: {
|
||||||
uploadedTo: wp.media.view.settings.post.id,
|
uploadedTo: wp.media.view.settings.post.id,
|
||||||
orderby: 'menuOrder',
|
orderby: 'menuOrder',
|
||||||
order: 'ASC'
|
order: 'ASC',
|
||||||
|
author: null
|
||||||
},
|
},
|
||||||
priority: 20
|
priority: 20
|
||||||
},
|
},
|
||||||
@ -7283,11 +7286,24 @@ Uploaded = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.Attac
|
|||||||
props: {
|
props: {
|
||||||
uploadedTo: 0,
|
uploadedTo: 0,
|
||||||
orderby: 'menuOrder',
|
orderby: 'menuOrder',
|
||||||
order: 'ASC'
|
order: 'ASC',
|
||||||
|
author: null
|
||||||
},
|
},
|
||||||
priority: 50
|
priority: 50
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if ( uid ) {
|
||||||
|
this.filters.mine = {
|
||||||
|
text: l10n.mine,
|
||||||
|
props: {
|
||||||
|
orderby: 'date',
|
||||||
|
order: 'DESC',
|
||||||
|
author: uid
|
||||||
|
},
|
||||||
|
priority: 50
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -7314,7 +7330,8 @@ var l10n = wp.media.view.l10n,
|
|||||||
*/
|
*/
|
||||||
All = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.AttachmentFilters.All.prototype */{
|
All = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.AttachmentFilters.All.prototype */{
|
||||||
createFilters: function() {
|
createFilters: function() {
|
||||||
var filters = {};
|
var filters = {},
|
||||||
|
uid = window.userSettings ? parseInt( window.userSettings.uid, 10 ) : 0;
|
||||||
|
|
||||||
_.each( wp.media.view.settings.mimeTypes || {}, function( text, key ) {
|
_.each( wp.media.view.settings.mimeTypes || {}, function( text, key ) {
|
||||||
filters[ key ] = {
|
filters[ key ] = {
|
||||||
@ -7324,7 +7341,8 @@ All = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.Attachment
|
|||||||
type: key,
|
type: key,
|
||||||
uploadedTo: null,
|
uploadedTo: null,
|
||||||
orderby: 'date',
|
orderby: 'date',
|
||||||
order: 'DESC'
|
order: 'DESC',
|
||||||
|
author: null
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -7336,7 +7354,8 @@ All = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.Attachment
|
|||||||
type: null,
|
type: null,
|
||||||
uploadedTo: null,
|
uploadedTo: null,
|
||||||
orderby: 'date',
|
orderby: 'date',
|
||||||
order: 'DESC'
|
order: 'DESC',
|
||||||
|
author: null
|
||||||
},
|
},
|
||||||
priority: 10
|
priority: 10
|
||||||
};
|
};
|
||||||
@ -7349,7 +7368,8 @@ All = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.Attachment
|
|||||||
type: null,
|
type: null,
|
||||||
uploadedTo: wp.media.view.settings.post.id,
|
uploadedTo: wp.media.view.settings.post.id,
|
||||||
orderby: 'menuOrder',
|
orderby: 'menuOrder',
|
||||||
order: 'ASC'
|
order: 'ASC',
|
||||||
|
author: null
|
||||||
},
|
},
|
||||||
priority: 20
|
priority: 20
|
||||||
};
|
};
|
||||||
@ -7362,11 +7382,27 @@ All = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.Attachment
|
|||||||
uploadedTo: 0,
|
uploadedTo: 0,
|
||||||
type: null,
|
type: null,
|
||||||
orderby: 'menuOrder',
|
orderby: 'menuOrder',
|
||||||
order: 'ASC'
|
order: 'ASC',
|
||||||
|
author: null
|
||||||
},
|
},
|
||||||
priority: 50
|
priority: 50
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if ( uid ) {
|
||||||
|
filters.mine = {
|
||||||
|
text: l10n.mine,
|
||||||
|
props: {
|
||||||
|
status: null,
|
||||||
|
type: null,
|
||||||
|
uploadedTo: null,
|
||||||
|
orderby: 'date',
|
||||||
|
order: 'DESC',
|
||||||
|
author: uid
|
||||||
|
},
|
||||||
|
priority: 50
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if ( wp.media.view.settings.mediaTrash &&
|
if ( wp.media.view.settings.mediaTrash &&
|
||||||
this.controller.isModeActive( 'grid' ) ) {
|
this.controller.isModeActive( 'grid' ) ) {
|
||||||
|
|
||||||
@ -7377,7 +7413,8 @@ All = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.Attachment
|
|||||||
status: 'trash',
|
status: 'trash',
|
||||||
type: null,
|
type: null,
|
||||||
orderby: 'date',
|
orderby: 'date',
|
||||||
order: 'DESC'
|
order: 'DESC',
|
||||||
|
author: null
|
||||||
},
|
},
|
||||||
priority: 50
|
priority: 50
|
||||||
};
|
};
|
||||||
|
4
wp-includes/js/media-views.min.js
vendored
4
wp-includes/js/media-views.min.js
vendored
File diff suppressed because one or more lines are too long
@ -3657,6 +3657,7 @@ function wp_enqueue_media( $args = array() ) {
|
|||||||
'noItemsFound' => __( 'No items found.' ),
|
'noItemsFound' => __( 'No items found.' ),
|
||||||
'insertIntoPost' => $post_type_object->labels->insert_into_item,
|
'insertIntoPost' => $post_type_object->labels->insert_into_item,
|
||||||
'unattached' => __( 'Unattached' ),
|
'unattached' => __( 'Unattached' ),
|
||||||
|
'mine' => __( 'Mine' ),
|
||||||
'trash' => _x( 'Trash', 'noun' ),
|
'trash' => _x( 'Trash', 'noun' ),
|
||||||
'uploadedToThisPost' => $post_type_object->labels->uploaded_to_this_item,
|
'uploadedToThisPost' => $post_type_object->labels->uploaded_to_this_item,
|
||||||
'warnDelete' => __( "You are about to permanently delete this item from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ),
|
'warnDelete' => __( "You are about to permanently delete this item from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ),
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.0-alpha-43055';
|
$wp_version = '5.0-alpha-43056';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user