Taxonomy: Introduce more fine grained capabilities for managing taxonomy terms.

This introduces the singular `edit_term`, `delete_term`, and `assign_term` meta capabilities for terms, and switches the base capability name for tags from `manage_categories` to `manage_post_tags` and the corresponding `edit_post_tags`, `delete_post_tags`, and `assign_post_tags`.

All of these capabilities ultimately map to `manage_categories` so by default there is no change in the behaviour of the capabilities for categories, tags, or custom taxonomies. The `map_meta_cap` filter and the `capabilities` argument when registering a taxonomy now allow for control over editing, deleting, and assigning individual terms, as well as a separation of capabilities for tags from those of categories.

Fixes #35614
Props johnjamesjacoby for feedback


git-svn-id: https://develop.svn.wordpress.org/trunk@38698 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn
2016-09-30 22:39:32 +00:00
parent ad6ef7c110
commit 17ef6d8cfa
14 changed files with 173 additions and 46 deletions

View File

@@ -31,11 +31,11 @@ $taxonomy = $tax->name;
$title = $tax->labels->edit_item;
if ( ! in_array( $taxonomy, get_taxonomies( array( 'show_ui' => true ) ) ) ||
! current_user_can( $tax->cap->manage_terms )
! current_user_can( 'edit_term', $tag->term_id )
) {
wp_die(
'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
'<p>' . __( 'Sorry, you are not allowed to manage this item.' ) . '</p>',
'<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
403
);
}