WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/30/2016 10:39:32 PM (3 years ago)
Author:
johnbillion
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-tags.php

    r38647 r38698  
    109109    check_admin_referer( 'delete-tag_' . $tag_ID );
    110110
    111     if ( ! current_user_can( $tax->cap->delete_terms ) ) {
     111    if ( ! current_user_can( 'delete_term', $tag_ID ) ) {
    112112        wp_die(
    113113            '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     
    169169    check_admin_referer( 'update-tag_' . $tag_ID );
    170170
    171     if ( ! current_user_can( $tax->cap->edit_terms ) ) {
     171    if ( ! current_user_can( 'edit_term', $tag_ID ) ) {
    172172        wp_die(
    173173            '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     
    314314
    315315require_once( ABSPATH . 'wp-admin/admin-header.php' );
    316 
    317 if ( ! current_user_can( $tax->cap->edit_terms ) ) {
    318     wp_die(
    319         '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
    320         '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
    321         403
    322     );
    323 }
    324316
    325317/** Also used by the Edit Tag  form */
Note: See TracChangeset for help on using the changeset viewer.