diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 9966d31e38..b3f00c1979 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -204,7 +204,7 @@ function _wp_ajax_add_hierarchical_term() { $action = $_POST['action']; $taxonomy = get_taxonomy(substr($action, 4)); check_ajax_referer( $action ); - if ( !current_user_can( 'manage_categories' ) ) + if ( !current_user_can( $taxonomy->manage_cap ) ) die('-1'); $names = explode(',', $_POST['new'.$taxonomy->name]); $parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0; @@ -329,10 +329,12 @@ case 'delete-cat' : case 'delete-tag' : $tag_id = (int) $_POST['tag_ID']; check_ajax_referer( "delete-tag_$tag_id" ); - if ( !current_user_can( 'manage_categories' ) ) - die('-1'); $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; + $tax = get_taxonomy($taxonomy); + + if ( !current_user_can( $tax->delete_cap ) ) + die('-1'); $tag = get_term( $tag_id, $taxonomy ); if ( !$tag || is_wp_error( $tag ) ) @@ -599,10 +601,13 @@ case 'add-link-cat' : // From Blogroll -> Categories break; case 'add-tag' : // From Manage->Tags check_ajax_referer( 'add-tag' ); - if ( !current_user_can( 'manage_categories' ) ) - die('-1'); $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; + $tax = get_taxonomy($taxonomy); + + if ( !current_user_can( $tax->edit_cap ) ) + die('-1'); + $tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST ); if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) { @@ -1175,7 +1180,12 @@ case 'inline-save': case 'inline-save-tax': check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' ); - if ( ! current_user_can('manage_categories') ) + $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : false; + if ( ! $taxonomy ) + die( __('Cheatin’ uh?') ); + $tax = get_taxonomy($taxonomy); + + if ( ! current_user_can( $tax->edit_cap ) ) die( __('Cheatin’ uh?') ); if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) ) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 4419723939..714f617e1a 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -97,10 +97,13 @@ foreach ( get_object_taxonomies($post_type) as $tax_name ) { $taxonomy = get_taxonomy($tax_name); $label = isset($taxonomy->label) ? esc_attr($taxonomy->label) : $tax_name; + if ( !current_user_can($taxonomy->manage_cap) ) + continue; + if ( !is_taxonomy_hierarchical($tax_name) ) add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', $post_type, 'side', 'core'); else - add_meta_box($tax_name.'div', $label, 'post_categories_meta_box', 'post', 'side', 'core', array( 'taxonomy' => $tax_name )); + add_meta_box($tax_name . 'div', $label, 'post_categories_meta_box', 'post', 'side', 'core', array( 'taxonomy' => $tax_name )); } if ( post_type_supports($post_type, 'page-attributes') ) diff --git a/wp-admin/edit-tags.php b/wp-admin/edit-tags.php index 57ee50b8e1..798443bddd 100644 --- a/wp-admin/edit-tags.php +++ b/wp-admin/edit-tags.php @@ -19,6 +19,8 @@ if ( empty($taxonomy) ) if ( !is_taxonomy($taxonomy) ) wp_die(__('Invalid taxonomy')); +$tax = get_taxonomy($taxonomy); + if ( empty($post_type) || !in_array( $post_type, get_post_types( array('_show' => true) ) ) ) $post_type = 'post'; @@ -39,7 +41,7 @@ case 'add-tag': check_admin_referer('add-tag'); - if ( !current_user_can('manage_categories') ) + if ( !current_user_can($tax->edit_cap) ) wp_die(__('Cheatin’ uh?')); $ret = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST); @@ -60,7 +62,7 @@ case 'delete': $tag_ID = (int) $_GET['tag_ID']; check_admin_referer('delete-tag_' . $tag_ID); - if ( !current_user_can('manage_categories') ) + if ( !current_user_can($tax->delete_cap) ) wp_die(__('Cheatin’ uh?')); wp_delete_term( $tag_ID, $taxonomy); @@ -80,7 +82,7 @@ break; case 'bulk-delete': check_admin_referer('bulk-tags'); - if ( !current_user_can('manage_categories') ) + if ( !current_user_can($tax->delete_cap) ) wp_die(__('Cheatin’ uh?')); $tags = (array) $_GET['delete_tags']; @@ -115,7 +117,7 @@ case 'editedtag': $tag_ID = (int) $_POST['tag_ID']; check_admin_referer('update-tag_' . $tag_ID); - if ( !current_user_can('manage_categories') ) + if ( !current_user_can($tax->edit_cap) ) wp_die(__('Cheatin’ uh?')); $ret = wp_update_term($tag_ID, $taxonomy, $_POST); @@ -142,10 +144,8 @@ if ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { exit; } -$can_manage = current_user_can('manage_categories'); - wp_enqueue_script('admin-tags'); -if ( $can_manage ) +if ( current_user_can($tax->edit_cap) ) wp_enqueue_script('inline-edit-tax'); require_once ('admin-header.php'); @@ -249,10 +249,7 @@ if ( $page_links )
- + @@ -284,15 +281,15 @@ if ( $page_links )