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:
Andrew Nacin
2010-05-13 04:10:17 +00:00
parent 39edf881e0
commit 4f689c8309
11 changed files with 41 additions and 38 deletions
+5 -5
View File
@@ -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"' : '';
?>
<div class="tagsdiv" id="<?php echo $tax_name; ?>">
<div class="jaxtag">
<div class="nojs-tags hide-if-js">
<p><?php echo $help_nojs; ?></p>
<textarea name="<?php echo "tax_input[$tax_name]"; ?>" class="the-tags" id="tax-input[<?php echo $tax_name; ?>]" <?php echo $disabled; ?>><?php echo esc_attr(get_terms_to_edit( $post->ID, $tax_name )); ?></textarea></div>
<?php if ( current_user_can($taxonomy->assign_cap) ) : ?>
<?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
<div class="ajaxtag hide-if-no-js">
<label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label>
<div class="taghint"><?php echo $help_hint; ?></div>
@@ -268,7 +268,7 @@ function post_tags_meta_box($post, $box) {
</div>
<div class="tagchecklist"></div>
</div>
<?php if ( current_user_can($taxonomy->assign_cap) ) : ?>
<?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
<p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php printf( $help_cloud, $box['title'] ); ?></a></p>
<?php else : ?>
<p><em><?php _e('You cannot modify this Taxonomy.'); ?></em></p>
@@ -315,10 +315,10 @@ function post_categories_meta_box( $post, $box ) {
<?php wp_terms_checklist($post->ID, array( 'taxonomy' => $taxonomy, 'popular_cats' => $popular_ids ) ) ?>
</ul>
</div>
<?php if ( !current_user_can($tax->assign_cap) ) : ?>
<?php if ( !current_user_can($tax->cap->assign_terms) ) : ?>
<p><em><?php _e('You cannot modify this Taxonomy.'); ?></em></p>
<?php endif; ?>
<?php if ( current_user_can($tax->edit_cap) ) : ?>
<?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
<div id="<?php echo $taxonomy; ?>-adder" class="wp-hidden-children">
<h4><a id="<?php echo $taxonomy; ?>-add-toggle" href="#<?php echo $taxonomy; ?>-add" class="hide-if-no-js" tabindex="3"><?php printf( __( '+ Add New %s' ), $tax->singular_label ); ?></a></h4>
<p id="<?php echo $taxonomy; ?>-add" class="category-add wp-hidden-child">
+1 -1
View File
@@ -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();
+6 -6
View File
@@ -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 .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>';
else
$out .= '<th scope="row" class="check-column">&nbsp;</th>';
@@ -444,11 +444,11 @@ function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) {
case 'name':
$out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $name)) . '">' . $name . '</a></strong><br />';
$actions = array();
if ( current_user_can($tax->edit_cap) ) {
if ( current_user_can($tax->cap->edit_terms) ) {
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>';
}
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'] = "<a class='delete-tag' href='" . wp_nonce_url("edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>";
$actions = apply_filters('tag_row_actions', $actions, $tag);