diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index da72288d0..c286dde42 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -219,7 +219,7 @@ function _wp_ajax_add_hierarchical_term() { $action = $_POST['action']; $taxonomy = get_taxonomy(substr($action, 4)); check_ajax_referer( $action ); - if ( !current_user_can( $taxonomy->edit_cap ) ) + if ( !current_user_can( $taxonomy->cap->edit_terms ) ) die('-1'); $names = explode(',', $_POST['new'.$taxonomy->name]); $parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0; @@ -334,7 +334,7 @@ case 'delete-tag' : $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; $tax = get_taxonomy($taxonomy); - if ( !current_user_can( $tax->delete_cap ) ) + if ( !current_user_can( $tax->cap->delete_terms ) ) die('-1'); $tag = get_term( $tag_id, $taxonomy ); @@ -566,7 +566,7 @@ case 'add-tag' : // From Manage->Tags $x = new WP_Ajax_Response(); - if ( !current_user_can( $tax->edit_cap ) ) + if ( !current_user_can( $tax->cap->edit_terms ) ) die('-1'); $tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST ); @@ -1204,7 +1204,7 @@ case 'inline-save-tax': die( __('Cheatin’ uh?') ); $tax = get_taxonomy($taxonomy); - if ( ! current_user_can( $tax->edit_cap ) ) + if ( ! current_user_can( $tax->cap->edit_terms ) ) die( __('Cheatin’ uh?') ); if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) ) diff --git a/wp-admin/edit-tags.php b/wp-admin/edit-tags.php index 8fee1ed4e..b1717cf23 100644 --- a/wp-admin/edit-tags.php +++ b/wp-admin/edit-tags.php @@ -41,7 +41,7 @@ case 'add-tag': check_admin_referer('add-tag'); - if ( !current_user_can($tax->edit_cap) ) + if ( !current_user_can($tax->cap->edit_terms) ) wp_die(__('Cheatin’ uh?')); $ret = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST); @@ -79,7 +79,7 @@ case 'delete': $tag_ID = (int) $_GET['tag_ID']; check_admin_referer('delete-tag_' . $tag_ID); - if ( !current_user_can($tax->delete_cap) ) + if ( !current_user_can($tax->cap->delete_terms) ) wp_die(__('Cheatin’ uh?')); wp_delete_term( $tag_ID, $taxonomy); @@ -93,7 +93,7 @@ break; case 'bulk-delete': check_admin_referer('bulk-tags'); - if ( !current_user_can($tax->delete_cap) ) + if ( !current_user_can($tax->cap->delete_terms) ) wp_die(__('Cheatin’ uh?')); $tags = (array) $_GET['delete_tags']; @@ -130,7 +130,7 @@ case 'editedtag': $tag_ID = (int) $_POST['tag_ID']; check_admin_referer('update-tag_' . $tag_ID); - if ( !current_user_can($tax->edit_cap) ) + if ( !current_user_can($tax->cap->edit_terms) ) wp_die(__('Cheatin’ uh?')); $ret = wp_update_term($tag_ID, $taxonomy, $_POST); @@ -161,7 +161,7 @@ if ( ! empty($_GET['_wp_http_referer']) ) { } wp_enqueue_script('admin-tags'); -if ( current_user_can($tax->edit_cap) ) +if ( current_user_can($tax->cap->edit_terms) ) wp_enqueue_script('inline-edit-tax'); require_once ('admin-header.php'); @@ -318,7 +318,7 @@ do_action('after-' . $taxonomy . '-table', $taxonomy);
edit_cap ) ) +if ( current_user_can( $tax->cap->edit_terms ) ) $tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false, 'link' => 'edit' ) ); else $tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false ) ); @@ -332,7 +332,7 @@ if ( $tag_cloud ) : edit_cap) ) { +if ( current_user_can($tax->cap->edit_terms) ) { if ( 'category' == $taxonomy ) do_action('add_category_form_pre', (object)array('parent' => 0) ); // Back compat hook. Deprecated in preference to $taxonomy_pre_add_form else diff --git a/wp-admin/includes/meta-boxes.php b/wp-admin/includes/meta-boxes.php index 0459cd6d1..c5649ecae 100644 --- a/wp-admin/includes/meta-boxes.php +++ b/wp-admin/includes/meta-boxes.php @@ -249,14 +249,14 @@ function post_tags_meta_box($post, $box) { $help_nojs = isset( $taxonomy->help_nojs ) ? $taxonomy->help_nojs : __('Add or remove tags'); $help_cloud = isset( $taxonomy->help_cloud ) ? $taxonomy->help_cloud : __('Choose from the most used tags in %s'); - $disabled = !current_user_can($taxonomy->assign_cap) ? 'disabled="disabled"' : ''; + $disabled = !current_user_can($taxonomy->cap->assign_terms) ? 'disabled="disabled"' : ''; ?>

- assign_cap) ) : ?> + cap->assign_terms) ) : ?>
@@ -268,7 +268,7 @@ function post_tags_meta_box($post, $box) {
-assign_cap) ) : ?> +cap->assign_terms) ) : ?>

@@ -315,10 +315,10 @@ function post_categories_meta_box( $post, $box ) { ID, array( 'taxonomy' => $taxonomy, 'popular_cats' => $popular_ids ) ) ?>
- assign_cap) ) : ?> + cap->assign_terms) ) : ?>

- edit_cap) ) : ?> + cap->edit_terms) ) : ?>

singular_label ); ?>

diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 20e9119a0..e17839764 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -318,7 +318,7 @@ function bulk_edit_posts( $post_data = null ) { foreach ( $tax_names as $tax_name ) { $taxonomy_obj = get_taxonomy($tax_name); - if( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->assign_cap ) ) + if( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) $new_terms = $tax_input[$tax_name]; else $new_terms = array(); diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index ed7c0e8de..cc27ee59f 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -22,7 +22,7 @@ function inline_edit_term_row($type, $taxonomy) { $tax = get_taxonomy($taxonomy); - if ( ! current_user_can( $tax->edit_cap ) ) + if ( ! current_user_can( $tax->cap->edit_terms ) ) return; $columns = get_column_headers($type); @@ -261,7 +261,7 @@ function wp_terms_checklist($post_id = 0, $args = array()) { $args = array('taxonomy' => $taxonomy); $tax = get_taxonomy($taxonomy); - $args['disabled'] = !current_user_can($tax->assign_cap); + $args['disabled'] = !current_user_can($tax->cap->assign_terms); if ( is_array( $selected_cats ) ) $args['selected_cats'] = $selected_cats; @@ -324,7 +324,7 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ech $terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) ); $tax = get_taxonomy($taxonomy); - if ( ! current_user_can($tax->assign_cap) ) + if ( ! current_user_can($tax->cap->assign_terms) ) $disabled = 'disabled="disabled"'; else $disabled = ''; @@ -436,7 +436,7 @@ function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) { switch ($column_name) { case 'cb': - if ( current_user_can($tax->delete_cap) && $tag->term_id != $default_term ) + if ( current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term ) $out .= ' '; else $out .= ' '; @@ -444,11 +444,11 @@ function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) { case 'name': $out .= '' . $name . '
'; $actions = array(); - if ( current_user_can($tax->edit_cap) ) { + if ( current_user_can($tax->cap->edit_terms) ) { $actions['edit'] = '' . __('Edit') . ''; $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; } - if ( current_user_can($tax->delete_cap) && $tag->term_id != $default_term ) + if ( current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term ) $actions['delete'] = "term_id) . "'>" . __('Delete') . ""; $actions = apply_filters('tag_row_actions', $actions, $tag); diff --git a/wp-admin/menu.php b/wp-admin/menu.php index 8d03e777c..2bbc18ea3 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -89,7 +89,7 @@ $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu if ( ! $tax->show_ui || ! in_array('post', (array) $tax->object_type, true) ) continue; - $submenu['edit.php'][$i++] = array( esc_attr($tax->label), $tax->manage_cap, 'edit-tags.php?taxonomy=' . $tax->name ); + $submenu['edit.php'][$i++] = array( esc_attr($tax->label), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name ); } unset($tax); @@ -138,7 +138,7 @@ foreach ( (array) get_post_types( array('show_ui' => true) ) as $ptype ) { if ( ! $tax->show_ui || ! in_array($ptype, (array) $tax->object_type, true) ) continue; - $submenu["edit.php?post_type=$ptype"][$i++] = array( esc_attr($tax->label), $tax->manage_cap, "edit-tags.php?taxonomy=$tax->name&post_type=$ptype" ); + $submenu["edit.php?post_type=$ptype"][$i++] = array( esc_attr($tax->label), $tax->cap->manage_terms, "edit-tags.php?taxonomy=$tax->name&post_type=$ptype" ); } } unset($ptype, $ptype_obj); diff --git a/wp-admin/press-this.php b/wp-admin/press-this.php index 5ecc39f66..23f7989b2 100644 --- a/wp-admin/press-this.php +++ b/wp-admin/press-this.php @@ -504,10 +504,10 @@ var photostorage = false;

- assign_cap) ) : ?> + cap->assign_terms) ) : ?>

- edit_cap) ) : ?> + cap->edit_terms) ) : ?>

singular_label ); ?>

diff --git a/wp-admin/tools.php b/wp-admin/tools.php index c73a257ce..e191279ca 100644 --- a/wp-admin/tools.php +++ b/wp-admin/tools.php @@ -33,7 +33,7 @@ endif; $cats = get_taxonomy('category'); $tags = get_taxonomy('post_tag'); -if ( current_user_can($cats->manage_cap) || current_user_can($tags->manage_cap) ) : ?> +if ( current_user_can($cats->cap->manage_terms) || current_user_can($tags->cap->manage_terms) ) : ?>

categories to tags, or tags to categories.'), 'admin.php?import=wp-cat2tag', 'admin.php?import=wp-cat2tag&step=3'); ?>

diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index cdb6b4064..ba961a1cf 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -646,7 +646,7 @@ function get_tag_feed_link($tag_id, $feed = '') { function get_edit_tag_link( $tag_id = 0, $taxonomy = 'post_tag' ) { global $post_type; $tax = get_taxonomy($taxonomy); - if ( !current_user_can($tax->edit_cap) ) + if ( !current_user_can($tax->cap->edit_terms) ) return; $tag = get_term($tag_id, $taxonomy); @@ -668,7 +668,7 @@ function get_edit_tag_link( $tag_id = 0, $taxonomy = 'post_tag' ) { */ function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) { $tax = get_taxonomy('post_tag'); - if ( !current_user_can($tax->edit_cap) ) + if ( !current_user_can($tax->cap->edit_terms) ) return; $tag = get_term($tag, 'post_tag'); diff --git a/wp-includes/post.php b/wp-includes/post.php index b3ae6f2b2..1be49f85c 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -2329,7 +2329,7 @@ function wp_insert_post($postarr = array(), $wp_error = false) { $taxonomy_obj = get_taxonomy($taxonomy); if ( is_array($tags) ) // array = hierarchical, string = non-hierarchical. $tags = array_filter($tags); - if ( current_user_can($taxonomy_obj->assign_cap) ) + if ( current_user_can($taxonomy_obj->cap->assign_terms) ) wp_set_post_terms( $post_ID, $tags, $taxonomy ); } } diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 72cf57495..660387b63 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -256,7 +256,8 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) { 'show_ui' => null, 'label' => null, 'show_tagcloud' => null, - '_builtin' => false + '_builtin' => false, + 'capabilities' => array(), ); $args = wp_parse_args($args, $defaults); @@ -285,12 +286,14 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) { if ( is_null($args['label'] ) ) $args['label'] = $taxonomy; - foreach ( array('manage_cap', 'edit_cap', 'delete_cap') as $cap ) { - if ( empty($args[$cap]) ) - $args[$cap] = 'manage_categories'; - } - if ( empty($args['assign_cap']) ) - $args['assign_cap'] = 'edit_posts'; + $default_caps = array( + 'manage_terms' => 'manage_categories', + 'edit_terms' => 'manage_categories', + 'delete_terms' => 'manage_categories', + 'assign_terms' => 'edit_posts', + ); + $args['cap'] = (object) array_merge( $default_caps, $args['capabilities'] ); + unset( $args['capabilities'] ); if ( empty($args['singular_label']) ) $args['singular_label'] = $args['label'];