mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-04 18:01:42 +01:00
Introduce assign_cap for Taxonomies, Defaults to 'edit_posts'. Allows for Authors/Contributors to tag/categorise their posts. See #12035
git-svn-id: http://svn.automattic.com/wordpress/trunk@13289 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
511454bd14
commit
0ec732b34a
@ -208,7 +208,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->manage_cap ) )
|
||||
if ( !current_user_can( $taxonomy->edit_cap ) )
|
||||
die('-1');
|
||||
$names = explode(',', $_POST['new'.$taxonomy->name]);
|
||||
$parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0;
|
||||
|
@ -247,7 +247,7 @@ if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0
|
||||
function post_tags_meta_box($post, $box) {
|
||||
$tax_name = esc_attr(substr($box['id'], 8));
|
||||
$taxonomy = get_taxonomy($tax_name);
|
||||
if ( !current_user_can($taxonomy->manage_cap) ) // @todo: Display the terms, do not edit.
|
||||
if ( !current_user_can($taxonomy->assign_cap) ) // @todo: Display the terms, do not edit.
|
||||
return;
|
||||
$helps = isset($taxonomy->helps) ? esc_attr($taxonomy->helps) : __('Separate tags with commas.');
|
||||
?>
|
||||
|
@ -315,7 +315,7 @@ function wp_terms_checklist($post_id = 0, $args = array()) {
|
||||
$args = array('taxonomy' => $taxonomy);
|
||||
|
||||
$tax = get_taxonomy($taxonomy);
|
||||
$args['disabled'] = !current_user_can($tax->manage_cap);
|
||||
$args['disabled'] = !current_user_can($tax->assign_cap);
|
||||
|
||||
if ( is_array( $selected_cats ) )
|
||||
$args['selected_cats'] = $selected_cats;
|
||||
@ -378,7 +378,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->manage_cap) )
|
||||
if ( ! current_user_can($tax->assign_cap) )
|
||||
$disabled = 'disabled="disabled"';
|
||||
else
|
||||
$disabled = '';
|
||||
|
@ -2185,7 +2185,7 @@ function wp_insert_post($postarr = array(), $wp_error = false) {
|
||||
if ( !empty($tax_input) ) {
|
||||
foreach ( $tax_input as $taxonomy => $tags ) {
|
||||
$taxonomy_obj = get_taxonomy($taxonomy);
|
||||
if ( current_user_can($taxonomy_obj->manage_cap) )
|
||||
if ( current_user_can($taxonomy_obj->assign_cap) )
|
||||
wp_set_post_terms( $post_ID, $tags, $taxonomy );
|
||||
}
|
||||
}
|
||||
|
@ -256,6 +256,8 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
|
||||
if ( empty($args[$cap]) )
|
||||
$args[$cap] = 'manage_categories';
|
||||
}
|
||||
if ( empty($args['assign_cap']) )
|
||||
$args['assign_cap'] = 'edit_posts';
|
||||
|
||||
if ( empty($args['singular_label']) )
|
||||
$args['singular_label'] = $args['label'];
|
||||
|
Loading…
Reference in New Issue
Block a user