mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Move taxonomy object properties for capabilities into a cap object. Capabilities can be specified via ['capabilities'] (an array keyed by the generic cap name) for register_taxonomy. fixes #13358.
git-svn-id: https://develop.svn.wordpress.org/trunk@14593 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'];
|
||||
|
||||
Reference in New Issue
Block a user