Changeset 12927
- Timestamp:
- 02/02/2010 05:37:03 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-form-advanced.php
r12887 r12927 86 86 87 87 $post_type_object = get_post_type_object($post_type); 88 $post_type_cap = $post_type_object->capability_type;89 88 90 89 // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). … … 129 128 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core'); 130 129 131 if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts') ) )130 if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->publish_cap ) ) ) 132 131 add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core'); 133 132 … … 193 192 <?php 194 193 $sample_permalink_html = get_sample_permalink_html($post->ID); 195 if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_' . $post_type_cap . 's') ) ) { ?>194 if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->publish_cap ) ) ) { ?> 196 195 <div id="edit-slug-box"> 197 196 <?php -
trunk/wp-admin/edit.php
r12819 r12927 28 28 29 29 $post_type_object = get_post_type_object($post_type); 30 $post_type_cap = $post_type_object->capability_type;31 30 32 31 if ( 'post' != $post_type ) { … … 73 72 $trashed = 0; 74 73 foreach( (array) $post_ids as $post_id ) { 75 if ( !current_user_can( 'delete_' . $post_type_cap, $post_id) )74 if ( !current_user_can($post_type_object->delete_cap, $post_id) ) 76 75 wp_die( __('You are not allowed to move this item to the trash.') ); 77 76 … … 86 85 $untrashed = 0; 87 86 foreach( (array) $post_ids as $post_id ) { 88 if ( !current_user_can( 'delete_' . $post_type_cap, $post_id) )87 if ( !current_user_can($post_type_object->delete_cap, $post_id) ) 89 88 wp_die( __('You are not allowed to restore this item from the trash.') ); 90 89 … … 101 100 $post_del = & get_post($post_id); 102 101 103 if ( !current_user_can( 'delete_' . $post_type_cap, $post_id) )102 if ( !current_user_can($post_type_object->delete_cap, $post_id) ) 104 103 wp_die( __('You are not allowed to delete this item.') ); 105 104 … … 142 141 143 142 $user_posts = false; 144 if ( !current_user_can( 'edit_others_' . $post_type_cap . 's') ) {143 if ( !current_user_can($post_type_object->edit_others_cap) ) { 145 144 $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = '%s' AND post_status != 'trash' AND post_author = %d", $post_type, $current_user->ID) ); 146 145 $user_posts = true; … … 342 341 <?php } 343 342 344 if ( $is_trash && current_user_can( 'edit_others_' . $post_type_cap .'s') ) { ?>343 if ( $is_trash && current_user_can($post_type_object->edit_others_cap) ) { ?> 345 344 <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 346 345 <?php } ?> … … 389 388 </select> 390 389 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 391 <?php if ( $is_trash && current_user_can( 'edit_others_' . $post_type_cap . 's') ) { ?>390 <?php if ( $is_trash && current_user_can($post_type_object->edit_others_cap) ) { ?> 392 391 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 393 392 <?php } ?> -
trunk/wp-admin/includes/template.php
r12859 r12927 1129 1129 $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list'; 1130 1130 // @todo use capability_type 1131 $can_publish = current_user_can( "publish_{$screen->post_type}s");1131 $can_publish = current_user_can($post_type_object->publish_cap); 1132 1132 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); 1133 1133 … … 1336 1336 </label> 1337 1337 1338 <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( 'edit_others_posts') ) : ?>1338 <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->edit_others_cap ) ) : ?> 1339 1339 1340 1340 <?php if ( $bulk ) : ?> … … 1358 1358 <?php endif; // $bulk ?> 1359 1359 1360 <?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_ posts' ) ?>1360 <?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_cap' ) ?> 1361 1361 1362 1362 </div> … … 1405 1405 */ 1406 1406 function get_inline_data($post) { 1407 1408 if ( ! current_user_can( 'edit_' . $post->post_type, $post->ID) )1407 $post_type_object = get_post_type_object($post->post_type); 1408 if ( ! current_user_can($post_type_object->edit_cap, $post->ID) ) 1409 1409 return; 1410 1410 … … 1427 1427 <div class="post_password">' . esc_html( $post->post_password ) . '</div>'; 1428 1428 1429 if ( $post_type_object->hierarchical ) 1430 echo '<div class="post_parent">' . $post->post_parent . '</div>'; 1431 1429 1432 if ( $post->post_type == 'page' ) 1430 echo ' 1431 <div class="post_parent">' . $post->post_parent . '</div> 1432 <div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div> 1433 <div class="menu_order">' . $post->menu_order . '</div>'; 1433 echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>'; 1434 1435 if ( $post_type_object->hierarchical ) 1436 echo '<div class="menu_order">' . $post->menu_order . '</div>'; 1437 1438 if ( is_object_in_taxonomy($post->post_type, 'post_tag') ) 1439 echo '<div class="tags_input">' . esc_html( str_replace( ',', ', ', get_tags_to_edit($post->ID) ) ) . '</div>'; 1440 1441 if ( is_object_in_taxonomy($post->post_type, 'post_tag') ) 1442 echo '<div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div>'; 1434 1443 1435 1444 if ( $post->post_type == 'post' ) 1436 echo ' 1437 <div class="tags_input">' . esc_html( str_replace( ',', ', ', get_tags_to_edit($post->ID) ) ) . '</div> 1438 <div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div> 1439 <div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>'; 1445 echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>'; 1440 1446 1441 1447 echo '</div>'; … … 1496 1502 $edit_link = get_edit_post_link( $post->ID ); 1497 1503 $title = _draft_or_post_title(); 1504 $post_type_object = get_post_type_object($post->post_type); 1498 1505 ?> 1499 1506 <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top"> … … 1514 1521 case 'cb': 1515 1522 ?> 1516 <th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th>1523 <th scope="row" class="check-column"><?php if ( current_user_can( $post_type_object->edit_cap, $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th> 1517 1524 <?php 1518 1525 break; … … 1557 1564 $attributes = 'class="post-title column-title"' . $style; 1558 1565 ?> 1559 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $post->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>1566 <td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->edit_cap, $post->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong> 1560 1567 <?php 1561 1568 if ( 'excerpt' == $mode ) … … 1563 1570 1564 1571 $actions = array(); 1565 if ( current_user_can( 'edit_post', $post->ID) && 'trash' != $post->post_status ) {1572 if ( current_user_can($post_type_object->edit_cap, $post->ID) && 'trash' != $post->post_status ) { 1566 1573 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>'; 1567 1574 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick Edit') . '</a>'; 1568 1575 } 1569 if ( current_user_can( 'delete_post', $post->ID) ) {1576 if ( current_user_can($post_type_object->delete_cap, $post->ID) ) { 1570 1577 if ( 'trash' == $post->post_status ) 1571 1578 $actions['untrash'] = "<a title='" . esc_attr(__('Restore this post from the Trash')) . "' href='" . wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>"; … … 1576 1583 } 1577 1584 if ( in_array($post->post_status, array('pending', 'draft')) ) { 1578 if ( current_user_can( 'edit_post', $post->ID) )1585 if ( current_user_can($post_type_object->edit_cap, $post->ID) ) 1579 1586 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 1580 1587 } elseif ( 'trash' != $post->post_status ) { … … 1659 1666 case 'control_edit': 1660 1667 ?> 1661 <td><?php if ( current_user_can( 'edit_post', $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>1668 <td><?php if ( current_user_can($post_type_object->edit_cap, $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td> 1662 1669 <?php 1663 1670 break; … … 1665 1672 case 'control_delete': 1666 1673 ?> 1667 <td><?php if ( current_user_can( 'delete_post', $post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>1674 <td><?php if ( current_user_can($post_type_object->delete_cap, $post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td> 1668 1675 <?php 1669 1676 break; … … 1726 1733 $title = _draft_or_post_title(); 1727 1734 $post_type = $page->post_type; 1735 $post_type_object = get_post_type_object($post_type); 1728 1736 ?> 1729 1737 <tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit"> 1730 1738 <?php 1731 1739 1732 foreach ( $posts_columns as $column_name=>$column_display_name) {1740 foreach ( $posts_columns as $column_name => $column_display_name ) { 1733 1741 $class = "class=\"$column_name column-$column_name\""; 1734 1742 … … 1781 1789 $edit_link = get_edit_post_link( $page->ID ); 1782 1790 ?> 1783 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_page', $page->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . __('Parent Page: ') . esc_html($parent_name) : ''; ?></strong>1791 <td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->edit_cap, $page->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . __('Parent Page: ') . esc_html($parent_name) : ''; ?></strong> 1784 1792 <?php 1785 1793 $actions = array(); 1786 if ( current_user_can( 'edit_page', $page->ID) && $post->post_status != 'trash' ) {1794 if ( current_user_can($post_type_object->edit_cap, $page->ID) && $post->post_status != 'trash' ) { 1787 1795 $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>'; 1788 1796 $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; 1789 1797 } 1790 if ( current_user_can( 'delete_page', $page->ID) ) {1798 if ( current_user_can($post_type_object->delete_cap, $page->ID) ) { 1791 1799 if ( $post->post_status == 'trash' ) 1792 1800 $actions['untrash'] = "<a title='" . esc_attr(__('Remove this page from the Trash')) . "' href='" . wp_nonce_url("post.php?post_type=$post_type&action=untrash&post=$page->ID", 'untrash-page_' . $page->ID) . "'>" . __('Restore') . "</a>"; … … 1797 1805 } 1798 1806 if ( in_array($post->post_status, array('pending', 'draft')) ) { 1799 if ( current_user_can( 'edit_page', $page->ID) )1807 if ( current_user_can($post_type_object->edit_cap, $page->ID) ) 1800 1808 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 1801 1809 } elseif ( $post->post_status != 'trash' ) { … … 2215 2223 $post = get_post($comment->comment_post_ID); 2216 2224 $the_comment_status = wp_get_comment_status($comment->comment_ID); 2217 $user_can = current_user_can('edit_post', $post->ID); 2225 $post_type_object = get_post_type_object($post->post_type); 2226 $user_can = current_user_can($post_type_object->edit_cap, $post->ID); 2218 2227 2219 2228 $author_url = get_comment_author_url(); -
trunk/wp-admin/post-new.php
r12728 r12927 50 50 51 51 // Show post form. 52 if ( current_user_can( 'edit_' . $post_type_object->capability_type . 's') ) {52 if ( current_user_can($post_type_object->edit_type_cap) ) { 53 53 $post = get_default_post_to_edit( $post_type ); 54 54 include('edit-form-advanced.php'); -
trunk/wp-admin/post.php
r12820 r12927 26 26 $post = null; 27 27 $post_type_object = null; 28 $post_type_cap = null;29 28 $post_type = null; 30 29 if ( $post_id ) { … … 36 35 $current_screen->post_type = $post->post_type; 37 36 $current_screen->id = $current_screen->post_type; 38 $post_type_cap = $post_type_object->capability_type;39 37 } 40 38 } … … 45 43 $current_screen->post_type = $post_type; 46 44 $current_screen->id = $current_screen->post_type; 47 $post_type_cap = $post_type_object->capability_type;48 45 } 49 46 } … … 234 231 $post = & get_post($post_id); 235 232 236 if ( !current_user_can( 'delete_' . $post_type_cap, $post_id) )233 if ( !current_user_can($post_type_object->delete_cap, $post_id) ) 237 234 wp_die( __('You are not allowed to move this item to the trash.') ); 238 235 … … 247 244 check_admin_referer('untrash-' . $post_type . '_' . $post_id); 248 245 249 if ( !current_user_can( 'delete_' . $post_type_cap, $post_id) )246 if ( !current_user_can($post_type_object->delete_cap, $post_id) ) 250 247 wp_die( __('You are not allowed to move this item out of the trash.') ); 251 248 … … 260 257 check_admin_referer('delete-' . $post_type . '_' . $post_id); 261 258 262 if ( !current_user_can( 'delete_' . $post_type_cap, $post_id) )259 if ( !current_user_can($post_type_object->delete_cap, $post_id) ) 263 260 wp_die( __('You are not allowed to delete this item.') ); 264 261 -
trunk/wp-includes/post.php
r12923 r12927 701 701 * inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none. 702 702 * capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post". 703 * edit_cap - The capability that controls editing a particular object of this post type. Defaults to "edit_$capability_type" (edit_post). 704 * edit_type_cap - The capability that controls editing objects of this post type as a class. Defaults to "edit_ . $capability_type . s" (edit_posts). 705 * edit_others_cap - The capability that controls editing objects of this post type that are owned by other users. Defaults to "edit_others_ . $capability_type . s" (edit_others_posts). 706 * edit_others_cap - The capability that controls publishing objects of this post type. Defaults to "publish_ . $capability_type . s" (publish_posts). 707 * read_cap - The capability that controls reading a particular object of this post type. Defaults to "read_$capability_type" (read_post). 708 * delete_cap - The capability that controls deleting a particular object of this post type. Defaults to "delete_$capability_type" (delete_post). 703 709 * hierarchical - Whether the post type is hierarchical. Defaults to false. 704 710 * supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none. … … 737 743 $args->label = $post_type; 738 744 739 if ( empty($args->capability_type) ) { 740 $args->edit_cap = ''; 741 $args->read_cap = ''; 742 $args->delete_cap = ''; 743 } else { 745 if ( empty($args->capability_type) ) 746 $args->capability_type = 'post'; 747 if ( empty($args->edit_cap) ) 744 748 $args->edit_cap = 'edit_' . $args->capability_type; 749 if ( empty($args->edit_type_cap) ) 750 $args->edit_type_cap = 'edit_' . $args->capability_type . 's'; 751 if ( empty($args->edit_others_cap) ) 752 $args->edit_others_cap = 'edit_others_' . $args->capability_type . 's'; 753 if ( empty($args->publish_cap) ) 754 $args->publish_cap = 'publish_' . $args->capability_type . 's'; 755 if ( empty($args->read_cap) ) 745 756 $args->read_cap = 'read_' . $args->capability_type; 757 if ( empty($args->delete_cap) ) 746 758 $args->delete_cap = 'delete_' . $args->capability_type; 747 }748 759 749 760 if ( !$args->_builtin && $args->public )
Note: See TracChangeset
for help on using the changeset viewer.