Changeset 12833
- Timestamp:
- 01/26/2010 11:32:04 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r12818 r12833 205 205 $taxonomy = get_taxonomy(substr($action, 4)); 206 206 check_ajax_referer( $action ); 207 if ( !current_user_can( 'manage_categories') )207 if ( !current_user_can( $taxonomy->manage_cap ) ) 208 208 die('-1'); 209 209 $names = explode(',', $_POST['new'.$taxonomy->name]); … … 330 330 $tag_id = (int) $_POST['tag_ID']; 331 331 check_ajax_referer( "delete-tag_$tag_id" ); 332 if ( !current_user_can( 'manage_categories' ) )333 die('-1');334 332 335 333 $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; 334 $tax = get_taxonomy($taxonomy); 335 336 if ( !current_user_can( $tax->delete_cap ) ) 337 die('-1'); 336 338 337 339 $tag = get_term( $tag_id, $taxonomy ); … … 600 602 case 'add-tag' : // From Manage->Tags 601 603 check_ajax_referer( 'add-tag' ); 602 if ( !current_user_can( 'manage_categories' ) )603 die('-1');604 604 605 605 $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; 606 $tax = get_taxonomy($taxonomy); 607 608 if ( !current_user_can( $tax->edit_cap ) ) 609 die('-1'); 610 606 611 $tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST ); 607 612 … … 1176 1181 check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' ); 1177 1182 1178 if ( ! current_user_can('manage_categories') ) 1183 $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : false; 1184 if ( ! $taxonomy ) 1185 die( __('Cheatin’ uh?') ); 1186 $tax = get_taxonomy($taxonomy); 1187 1188 if ( ! current_user_can( $tax->edit_cap ) ) 1179 1189 die( __('Cheatin’ uh?') ); 1180 1190 -
trunk/wp-admin/edit-form-advanced.php
r12798 r12833 98 98 $label = isset($taxonomy->label) ? esc_attr($taxonomy->label) : $tax_name; 99 99 100 if ( !current_user_can($taxonomy->manage_cap) ) 101 continue; 102 100 103 if ( !is_taxonomy_hierarchical($tax_name) ) 101 104 add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', $post_type, 'side', 'core'); 102 105 else 103 add_meta_box($tax_name .'div', $label, 'post_categories_meta_box', 'post', 'side', 'core', array( 'taxonomy' => $tax_name ));106 add_meta_box($tax_name . 'div', $label, 'post_categories_meta_box', 'post', 'side', 'core', array( 'taxonomy' => $tax_name )); 104 107 } 105 108 -
trunk/wp-admin/edit-tags.php
r12818 r12833 19 19 if ( !is_taxonomy($taxonomy) ) 20 20 wp_die(__('Invalid taxonomy')); 21 22 $tax = get_taxonomy($taxonomy); 21 23 22 24 if ( empty($post_type) || !in_array( $post_type, get_post_types( array('_show' => true) ) ) ) … … 40 42 check_admin_referer('add-tag'); 41 43 42 if ( !current_user_can( 'manage_categories') )44 if ( !current_user_can($tax->edit_cap) ) 43 45 wp_die(__('Cheatin’ uh?')); 44 46 … … 61 63 check_admin_referer('delete-tag_' . $tag_ID); 62 64 63 if ( !current_user_can( 'manage_categories') )65 if ( !current_user_can($tax->delete_cap) ) 64 66 wp_die(__('Cheatin’ uh?')); 65 67 … … 81 83 check_admin_referer('bulk-tags'); 82 84 83 if ( !current_user_can( 'manage_categories') )85 if ( !current_user_can($tax->delete_cap) ) 84 86 wp_die(__('Cheatin’ uh?')); 85 87 … … 116 118 check_admin_referer('update-tag_' . $tag_ID); 117 119 118 if ( !current_user_can( 'manage_categories') )120 if ( !current_user_can($tax->edit_cap) ) 119 121 wp_die(__('Cheatin’ uh?')); 120 122 … … 143 145 } 144 146 145 $can_manage = current_user_can('manage_categories');146 147 147 wp_enqueue_script('admin-tags'); 148 if ( $can_manage)148 if ( current_user_can($tax->edit_cap) ) 149 149 wp_enqueue_script('inline-edit-tax'); 150 150 … … 250 250 251 251 <tbody id="the-list" class="list:tag"> 252 <?php 253 254 $count = tag_rows( $pagenum, $tags_per_page, $searchterms, $taxonomy ); 255 ?> 252 <?php tag_rows( $pagenum, $tags_per_page, $searchterms, $taxonomy ); ?> 256 253 </tbody> 257 254 </table> … … 285 282 <h3><?php _e('Popular Tags'); ?></h3> 286 283 <?php 287 if ( $can_manage)284 if ( current_user_can($tax->edit_cap) ) 288 285 wp_tag_cloud(array('taxonomy' => $taxonomy, 'link' => 'edit')); 289 286 else … … 292 289 </div> 293 290 294 <?php if ( $can_manage) {295 do_action('add_tag_form_pre' ); ?>291 <?php if ( current_user_can($tax->edit_cap) ) { 292 do_action('add_tag_form_pre', $taxonomy); ?> 296 293 297 294 <div class="form-wrap"> … … 328 325 329 326 <p class="submit"><input type="submit" class="button" name="submit" id="submit" value="<?php esc_attr_e('Add Tag'); ?>" /></p> 330 <?php do_action('add_tag_form' ); ?>327 <?php do_action('add_tag_form', $taxonomy); ?> 331 328 </form></div> 332 329 <?php } ?> -
trunk/wp-admin/includes/meta-boxes.php
r12798 r12833 240 240 $tax_name = esc_attr(substr($box['id'], 8)); 241 241 $taxonomy = get_taxonomy($tax_name); 242 if ( !current_user_can($taxonomy->manage_cap) ) 243 return; 242 244 $helps = isset($taxonomy->helps) ? esc_attr($taxonomy->helps) : __('Separate tags with commas.'); 243 245 ?> … … 276 278 $args = $box['args']; 277 279 extract( wp_parse_args($args, $defaults), EXTR_SKIP ); 280 $tax = get_taxonomy($taxonomy); 281 282 if ( !current_user_can($tax->manage_cap) ) 283 return; 278 284 ?> 279 285 <div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv"> … … 295 301 </div> 296 302 297 <?php if ( current_user_can( 'manage_categories') ) : ?>303 <?php if ( current_user_can($tax->edit_cap) ) : ?> 298 304 <div id="<?php echo $taxonomy; ?>-adder" class="wp-hidden-children"> 299 305 <h4><a id="<?php echo $taxonomy; ?>-add-toggle" href="#<?php echo $taxonomy; ?>-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4> -
trunk/wp-admin/includes/template.php
r12818 r12833 212 212 function inline_edit_term_row($type, $taxonomy) { 213 213 214 if ( ! current_user_can( 'manage_categories' ) ) 214 $tax = get_taxonomy($taxonomy); 215 if ( ! current_user_can( $tax->edit_cap ) ) 215 216 return; 216 217 … … 679 680 else 680 681 $tagsel = $taxonomy; 682 683 $tax = get_taxonomy($taxonomy); 684 681 685 $count = ( $count > 0 ) ? "<a href='edit.php?$tagsel=$tag->slug'>$count</a>" : $count; 682 686 … … 685 689 $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit'); 686 690 $edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&tag_ID=$tag->term_id"; 691 687 692 $out = ''; 688 693 $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>'; 694 689 695 $columns = get_column_headers('edit-tags'); 690 696 $hidden = get_hidden_columns('edit-tags'); 697 $default_term = get_option('default_' . $taxonomy); 691 698 foreach ( $columns as $column_name => $column_display_name ) { 692 699 $class = "class=\"$column_name column-$column_name\""; … … 700 707 switch ($column_name) { 701 708 case 'cb': 702 if ( $tag->term_id != get_option('default_' . $taxonomy))709 if ( current_user_can($tax->delete_cap) && $tag->term_id != $default_term ) 703 710 $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>'; 704 711 else … … 708 715 $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit “%s”'), $name)) . '">' . $name . '</a></strong><br />'; 709 716 $actions = array(); 710 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; 711 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; 712 if ( $tag->term_id != get_option('default_' . $taxonomy) ) 717 if ( current_user_can($tax->edit_cap) ) { 718 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; 719 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; 720 } 721 if ( current_user_can($tax->delete_cap) && $tag->term_id != $default_term ) 713 722 $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url("edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>"; 714 723 … … 747 756 } 748 757 749 $out .= '</tr>';758 $out .= "</tr>\n"; 750 759 751 760 return $out; … … 796 805 } 797 806 798 // filter and send to screen799 807 echo $out; 800 808 return $count; … … 1136 1144 1137 1145 <fieldset class="inline-edit-col-left"><div class="inline-edit-col"> 1138 <h4><?php echo $bulk ? ( __( 'Bulk Edit' )) : __( 'Quick Edit' ); ?></h4>1146 <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4> 1139 1147 1140 1148 -
trunk/wp-includes/taxonomy.php
r12818 r12833 16 16 */ 17 17 function create_initial_taxonomies() { 18 register_taxonomy( 'category', 'post', array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Categories'), 'query_var' => false, 'rewrite' => false) ) ; 19 register_taxonomy( 'post_tag', 'post', array('hierarchical' => false, 'update_count_callback' => '_update_post_term_count', 'label' => __('Post Tags'), 'query_var' => false, 'rewrite' => false) ) ; 20 register_taxonomy( 'link_category', 'link', array('hierarchical' => false, 'label' => __('Categories'), 'query_var' => false, 'rewrite' => false) ) ; 18 register_taxonomy( 'category', 'post', array( 'hierarchical' => true, 19 'update_count_callback' => '_update_post_term_count', 20 'label' => __('Categories'), 21 'query_var' => false, 22 'rewrite' => false, 23 'edit_cap' => 'no_priv' 24 ) ) ; 25 26 register_taxonomy( 'post_tag', 'post', array( 27 'hierarchical' => false, 28 'update_count_callback' => '_update_post_term_count', 29 'label' => __('Post Tags'), 30 'query_var' => false, 31 'rewrite' => false 32 ) ) ; 33 34 register_taxonomy( 'link_category', 'link', array( 'hierarchical' => false, 35 'label' => __('Categories'), 36 'query_var' => false, 37 'rewrite' => false 38 ) ) ; 21 39 } 22 40 add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority … … 168 186 global $wp_taxonomies, $wp_rewrite, $wp; 169 187 170 if ( !is_array($wp_taxonomies))188 if ( ! is_array($wp_taxonomies) ) 171 189 $wp_taxonomies = array(); 172 190 … … 190 208 $wp_rewrite->add_rewrite_tag("%$taxonomy%", '([^/]+)', $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=$term"); 191 209 $wp_rewrite->add_permastruct($taxonomy, "/{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front']); 210 } 211 212 foreach ( array('manage_cap', 'edit_cap', 'delete_cap') as $cap ) { 213 if ( empty($args[$cap]) ) 214 $args[$cap] = 'manage_categories'; 192 215 } 193 216
Note: See TracChangeset
for help on using the changeset viewer.