Changeset 14585
- Timestamp:
- 05/12/2010 08:45:18 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-form-advanced.php
r14554 r14585 143 143 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core'); 144 144 145 if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object-> publish_cap) ) )145 if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) ) 146 146 add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core'); 147 147 … … 222 222 $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>'; 223 223 224 if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object-> publish_cap) ) ) { ?>224 if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?> 225 225 <div id="edit-slug-box"> 226 226 <?php -
trunk/wp-admin/edit.php
r14571 r14585 20 20 $post_type_object = get_post_type_object($post_type); 21 21 22 if ( !current_user_can($post_type_object-> edit_type_cap) )22 if ( !current_user_can($post_type_object->cap->edit_posts) ) 23 23 wp_die(__('Cheatin’ uh?')); 24 24 … … 74 74 $trashed = 0; 75 75 foreach( (array) $post_ids as $post_id ) { 76 if ( !current_user_can($post_type_object-> delete_cap, $post_id) )76 if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) 77 77 wp_die( __('You are not allowed to move this item to the Trash.') ); 78 78 … … 87 87 $untrashed = 0; 88 88 foreach( (array) $post_ids as $post_id ) { 89 if ( !current_user_can($post_type_object-> delete_cap, $post_id) )89 if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) 90 90 wp_die( __('You are not allowed to restore this item from the Trash.') ); 91 91 … … 102 102 $post_del = & get_post($post_id); 103 103 104 if ( !current_user_can($post_type_object-> delete_cap, $post_id) )104 if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) 105 105 wp_die( __('You are not allowed to delete this item.') ); 106 106 … … 141 141 142 142 $user_posts = false; 143 if ( !current_user_can($post_type_object-> edit_others_cap) ) {143 if ( !current_user_can($post_type_object->cap->edit_other_posts) ) { 144 144 $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = '%s' AND post_status NOT IN ('trash', 'auto-draft') AND post_author = %d", $post_type, $current_user->ID) ); 145 145 $user_posts = true; … … 346 346 <?php } 347 347 348 if ( $is_trash && current_user_can($post_type_object-> edit_others_cap) ) { ?>348 if ( $is_trash && current_user_can($post_type_object->cap->edit_other_posts) ) { ?> 349 349 <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 350 350 <?php } ?> … … 397 397 </select> 398 398 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 399 <?php if ( $is_trash && current_user_can($post_type_object-> edit_others_cap) ) { ?>399 <?php if ( $is_trash && current_user_can($post_type_object->cap->edit_other_posts) ) { ?> 400 400 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 401 401 <?php } ?> -
trunk/wp-admin/includes/meta-boxes.php
r14426 r14585 15 15 $post_type = $post->post_type; 16 16 $post_type_object = get_post_type_object($post_type); 17 $can_publish = current_user_can($post_type_object-> publish_cap);17 $can_publish = current_user_can($post_type_object->cap->publish_posts); 18 18 ?> 19 19 <div class="submitbox" id="submitpost"> -
trunk/wp-admin/includes/post.php
r14580 r14585 47 47 $ptype = get_post_type_object( $post_data['post_type'] ); 48 48 if ( isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) ) { 49 if ( !current_user_can( $ptype-> edit_others_cap) ) {49 if ( !current_user_can( $ptype->cap->edit_other_posts ) ) { 50 50 if ( 'page' == $post_data['post_type'] ) { 51 51 return new WP_Error( 'edit_others_pages', $update ? … … 82 82 // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published. 83 83 // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts. 84 if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $ptype-> publish_cap)) )84 if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $ptype->cap->publish_posts )) ) 85 85 if ( $previous_status != 'publish' || !current_user_can( 'edit_post', $post_id ) ) 86 86 $post_data['post_status'] = 'pending'; … … 139 139 140 140 $ptype = get_post_type_object($post_data['post_type']); 141 if ( !current_user_can( $ptype-> edit_cap, $post_ID ) ) {141 if ( !current_user_can( $ptype->cap->edit_post, $post_ID ) ) { 142 142 if ( 'page' == $post_data['post_type'] ) 143 143 wp_die( __('You are not allowed to edit this page.' )); … … 238 238 $ptype = get_post_type_object('post'); 239 239 240 if ( !current_user_can( $ptype-> edit_type_cap) ) {240 if ( !current_user_can( $ptype->cap->edit_posts ) ) { 241 241 if ( 'page' == $ptype->name ) 242 242 wp_die( __('You are not allowed to edit pages.')); … … 495 495 $ptype = get_post_type_object('post'); 496 496 497 if ( !current_user_can( $ptype-> edit_type_cap) ) {497 if ( !current_user_can( $ptype->cap->edit_posts ) ) { 498 498 if ( 'page' == $ptype->name ) 499 499 return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) ); -
trunk/wp-admin/includes/template.php
r14571 r14585 877 877 $col_count = count($columns) - count($hidden); 878 878 $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list'; 879 $can_publish = current_user_can($post_type_object-> publish_cap);879 $can_publish = current_user_can($post_type_object->cap->publish_posts); 880 880 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); 881 881 … … 1112 1112 </label> 1113 1113 1114 <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object-> edit_others_cap) ) : ?>1114 <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_other_posts ) ) : ?> 1115 1115 1116 1116 <?php if ( $bulk ) : ?> … … 1182 1182 function get_inline_data($post) { 1183 1183 $post_type_object = get_post_type_object($post->post_type); 1184 if ( ! current_user_can($post_type_object-> edit_cap, $post->ID) )1184 if ( ! current_user_can($post_type_object->cap->edit_post, $post->ID) ) 1185 1185 return; 1186 1186 … … 1299 1299 case 'cb': 1300 1300 ?> 1301 <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>1301 <th scope="row" class="check-column"><?php if ( current_user_can( $post_type_object->cap->edit_post, $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th> 1302 1302 <?php 1303 1303 break; … … 1342 1342 $attributes = 'class="post-title column-title"' . $style; 1343 1343 ?> 1344 <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>1344 <td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->cap->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> 1345 1345 <?php 1346 1346 if ( 'excerpt' == $mode ) … … 1348 1348 1349 1349 $actions = array(); 1350 if ( current_user_can($post_type_object-> edit_cap, $post->ID) && 'trash' != $post->post_status ) {1350 if ( current_user_can($post_type_object->cap->edit_post, $post->ID) && 'trash' != $post->post_status ) { 1351 1351 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>'; 1352 1352 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick Edit') . '</a>'; 1353 1353 } 1354 if ( current_user_can($post_type_object-> delete_cap, $post->ID) ) {1354 if ( current_user_can($post_type_object->cap->delete_post, $post->ID) ) { 1355 1355 if ( 'trash' == $post->post_status ) 1356 1356 $actions['untrash'] = "<a title='" . esc_attr(__('Restore this post from the Trash')) . "' href='" . wp_nonce_url( admin_url( sprintf($post_type_object->_edit_link . '&action=untrash', $post->ID) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __('Restore') . "</a>"; … … 1361 1361 } 1362 1362 if ( in_array($post->post_status, array('pending', 'draft')) ) { 1363 if ( current_user_can($post_type_object-> edit_cap, $post->ID) )1363 if ( current_user_can($post_type_object->cap->edit_post, $post->ID) ) 1364 1364 $actions['view'] = '<a href="' . add_query_arg( 'preview', 'true', get_permalink($post->ID) ) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 1365 1365 } elseif ( 'trash' != $post->post_status ) { … … 1444 1444 case 'control_edit': 1445 1445 ?> 1446 <td><?php if ( current_user_can($post_type_object-> edit_cap, $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>1446 <td><?php if ( current_user_can($post_type_object->cap->edit_post, $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td> 1447 1447 <?php 1448 1448 break; … … 1450 1450 case 'control_delete': 1451 1451 ?> 1452 <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>1452 <td><?php if ( current_user_can($post_type_object->cap->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> 1453 1453 <?php 1454 1454 break; … … 1567 1567 $edit_link = get_edit_post_link( $page->ID ); 1568 1568 ?> 1569 <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) ? ' | ' . $post_type_object->labels->parent . ' ' . esc_html($parent_name) : ''; ?></strong>1569 <td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->cap->edit_post, $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) ? ' | ' . $post_type_object->labels->parent . ' ' . esc_html($parent_name) : ''; ?></strong> 1570 1570 <?php 1571 1571 $actions = array(); 1572 if ( current_user_can($post_type_object-> edit_cap, $page->ID) && $post->post_status != 'trash' ) {1572 if ( current_user_can($post_type_object->cap->edit_post, $page->ID) && $post->post_status != 'trash' ) { 1573 1573 $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>'; 1574 1574 $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; 1575 1575 } 1576 if ( current_user_can($post_type_object-> delete_cap, $page->ID) ) {1576 if ( current_user_can($post_type_object->cap->delete_post, $page->ID) ) { 1577 1577 if ( $post->post_status == 'trash' ) 1578 1578 $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-' . $post->post_type . '_' . $page->ID) . "'>" . __('Restore') . "</a>"; … … 1583 1583 } 1584 1584 if ( in_array($post->post_status, array('pending', 'draft')) ) { 1585 if ( current_user_can($post_type_object-> edit_cap, $page->ID) )1585 if ( current_user_can($post_type_object->cap->edit_post, $page->ID) ) 1586 1586 $actions['view'] = '<a href="' . add_query_arg( 'preview', 'true', get_permalink($page->ID) ) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 1587 1587 } elseif ( $post->post_status != 'trash' ) { … … 2011 2011 $the_comment_status = wp_get_comment_status($comment->comment_ID); 2012 2012 $post_type_object = get_post_type_object($post->post_type); 2013 $user_can = current_user_can($post_type_object-> edit_cap, $post->ID);2013 $user_can = current_user_can($post_type_object->cap->edit_post, $post->ID); 2014 2014 2015 2015 $comment_url = esc_url(get_comment_link($comment->comment_ID)); … … 3329 3329 switch ( $screen->id ) { 3330 3330 case $post_type_object->name: 3331 $default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->edit_item, $post_type_object-> edit_type_cap));3331 $default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->edit_item, $post_type_object->cap->edit_posts)); 3332 3332 break; 3333 3333 case "edit-{$post_type_object->name}": 3334 $default_action = array('post-new.php?post_type=' . $post_type_object->name => array($post_type_object->labels->new_item, $post_type_object-> edit_type_cap));3334 $default_action = array('post-new.php?post_type=' . $post_type_object->name => array($post_type_object->labels->new_item, $post_type_object->cap->edit_posts)); 3335 3335 break; 3336 3336 } -
trunk/wp-admin/includes/user.php
r14428 r14585 250 250 $post_type_obj = get_post_type_object($post_type); 251 251 252 if ( ! $user->has_cap($post_type_obj-> edit_others_cap) ) {253 if ( $user->has_cap($post_type_obj-> edit_type_cap) || ! $exclude_zeros )252 if ( ! $user->has_cap($post_type_obj->cap->edit_other_posts) ) { 253 if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros ) 254 254 return array($user->id); 255 255 else -
trunk/wp-admin/menu.php
r14581 r14585 130 130 $ptype_menu_position++; 131 131 132 $menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->labels->name ), $ptype_obj-> edit_type_cap, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-' . $ptype_class, 'menu-' . $ptype_class, $menu_icon );133 $submenu["edit.php?post_type=$ptype"][5] = array( $ptype_obj->labels->edit, $ptype_obj-> edit_type_cap, "edit.php?post_type=$ptype");134 $submenu["edit.php?post_type=$ptype"][10] = array( $ptype_obj->labels->add_new, $ptype_obj-> edit_type_cap, "post-new.php?post_type=$ptype" );132 $menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->labels->name ), $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-' . $ptype_class, 'menu-' . $ptype_class, $menu_icon ); 133 $submenu["edit.php?post_type=$ptype"][5] = array( $ptype_obj->labels->edit, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype"); 134 $submenu["edit.php?post_type=$ptype"][10] = array( $ptype_obj->labels->add_new, $ptype_obj->cap->edit_posts, "post-new.php?post_type=$ptype" ); 135 135 136 136 $i = 15; -
trunk/wp-admin/post-new.php
r14571 r14585 47 47 48 48 // Show post form. 49 if ( current_user_can($post_type_object-> edit_type_cap) ) {49 if ( current_user_can($post_type_object->cap->edit_posts) ) { 50 50 $post = get_default_post_to_edit( $post_type, true ); 51 51 $post_ID = $post->ID; -
trunk/wp-admin/post.php
r14571 r14585 153 153 wp_die( __('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?') ); 154 154 155 if ( !current_user_can($post_type_object-> edit_cap, $post_id) )155 if ( !current_user_can($post_type_object->cap->edit_post, $post_id) ) 156 156 wp_die( __('You are not allowed to edit this item.') ); 157 157 … … 218 218 $post = & get_post($post_id); 219 219 220 if ( !current_user_can($post_type_object-> delete_cap, $post_id) )220 if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) 221 221 wp_die( __('You are not allowed to move this item to the Trash.') ); 222 222 … … 231 231 check_admin_referer('untrash-' . $post_type . '_' . $post_id); 232 232 233 if ( !current_user_can($post_type_object-> delete_cap, $post_id) )233 if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) 234 234 wp_die( __('You are not allowed to move this item out of the Trash.') ); 235 235 … … 244 244 check_admin_referer('delete-' . $post_type . '_' . $post_id); 245 245 246 if ( !current_user_can($post_type_object-> delete_cap, $post_id) )246 if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) 247 247 wp_die( __('You are not allowed to delete this item.') ); 248 248 -
trunk/wp-includes/capabilities.php
r14404 r14585 824 824 $post_type = get_post_type_object( $post->post_type ); 825 825 if ( $post_type && 'post' != $post_type->capability_type ) { 826 $args = array_merge( array( $post_type-> delete_cap, $user_id ), $args );826 $args = array_merge( array( $post_type->cap->delete_post, $user_id ), $args ); 827 827 return call_user_func_array( 'map_meta_cap', $args ); 828 828 } … … 901 901 $post_type = get_post_type_object( $post->post_type ); 902 902 if ( $post_type && 'post' != $post_type->capability_type ) { 903 $args = array_merge( array( $post_type-> edit_cap, $user_id ), $args );903 $args = array_merge( array( $post_type->cap->edit_post, $user_id ), $args ); 904 904 return call_user_func_array( 'map_meta_cap', $args ); 905 905 } … … 960 960 $post_type = get_post_type_object( $post->post_type ); 961 961 if ( $post_type && 'post' != $post_type->capability_type ) { 962 $args = array_merge( array( $post_type-> read_cap, $user_id ), $args );962 $args = array_merge( array( $post_type->cap->read_post, $user_id ), $args ); 963 963 return call_user_func_array( 'map_meta_cap', $args ); 964 964 } -
trunk/wp-includes/link-template.php
r14490 r14585 794 794 return; 795 795 796 if ( !current_user_can( $post_type_object-> edit_cap, $post->ID ) )796 if ( !current_user_can( $post_type_object->cap->edit_post, $post->ID ) ) 797 797 return; 798 798 … … 847 847 return; 848 848 849 if ( !current_user_can( $post_type_object-> delete_cap, $post->ID ) )849 if ( !current_user_can( $post_type_object->cap->delete_post, $post->ID ) ) 850 850 return; 851 851 -
trunk/wp-includes/post.php
r14584 r14585 775 775 * - inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none. 776 776 * - capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post". 777 * - edit_cap - The capability that controls editing a particular object of this post type. Defaults to "edit_$capability_type" (edit_post). 778 * - edit_type_cap - The capability that controls editing objects of this post type as a class. Defaults to "edit_ . $capability_type . s" (edit_posts). 779 * - 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). 780 * - publish_others_cap - The capability that controls publishing objects of this post type. Defaults to "publish_ . $capability_type . s" (publish_posts). 781 * - read_cap - The capability that controls reading a particular object of this post type. Defaults to "read_$capability_type" (read_post). 782 * - delete_cap - The capability that controls deleting a particular object of this post type. Defaults to "delete_$capability_type" (delete_post). 777 * - capabilities - Array of capabilities for this post type. You can see accepted values in {@link get_post_type_capabilities()}. By default the capability_type is used to construct capabilities. 783 778 * - hierarchical - Whether the post type is hierarchical. Defaults to false. 784 779 * - supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none. … … 803 798 $defaults = array( 804 799 'labels' => array(), 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, 805 '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', ' hierarchical' => false,800 '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'capabilities' => array(), 'hierarchical' => false, 806 801 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 807 802 'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, … … 828 823 if ( empty($args->capability_type) ) 829 824 $args->capability_type = 'post'; 830 if ( empty($args->edit_cap) ) 831 $args->edit_cap = 'edit_' . $args->capability_type; 832 if ( empty($args->edit_type_cap) ) 833 $args->edit_type_cap = 'edit_' . $args->capability_type . 's'; 834 if ( empty($args->edit_others_cap) ) 835 $args->edit_others_cap = 'edit_others_' . $args->capability_type . 's'; 836 if ( empty($args->publish_cap) ) 837 $args->publish_cap = 'publish_' . $args->capability_type . 's'; 838 if ( empty($args->read_cap) ) 839 $args->read_cap = 'read_' . $args->capability_type; 840 if ( empty($args->read_private_cap) ) 841 $args->read_private_cap = 'read_private_' . $args->capability_type . 's'; 842 if ( empty($args->delete_cap) ) 843 $args->delete_cap = 'delete_' . $args->capability_type; 825 826 $args->cap = get_post_type_capabilities( $args ); 844 827 845 828 if ( ! empty($args->supports) ) { … … 891 874 892 875 return $args; 876 } 877 878 /** 879 * Builds an object with all post type capabilities out of a post type object 880 * 881 * Accepted keys of the capabilities array in the post type object: 882 * - edit_post - The meta capability that controls editing a particular object of this post type. Defaults to "edit_$capability_type" (edit_post). 883 * - edit_posts - The capability that controls editing objects of this post type as a class. Defaults to "edit_ . $capability_type . s" (edit_posts). 884 * - edit_others_posts - 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). 885 * - publish_posts - The capability that controls publishing objects of this post type. Defaults to "publish_ . $capability_type . s" (publish_posts). 886 * - read_post - The meta capability that controls reading a particular object of this post type. Defaults to "read_$capability_type" (read_post). 887 * - read_private_posts - The capability that controls reading private posts. Defaults to "read_ . $capability_type . s" (read_private_posts). 888 * - delete_post - The meta capability that controls deleting a particular object of this post type. Defaults to "delete_$capability_type" (delete_post). 889 * 890 * @since 3.0.0 891 * @param object $args 892 * @return object object with all the capabilities as member variables 893 */ 894 function get_post_type_capabilities( $args ) { 895 $defaults = array( 896 'edit_post' => 'edit_' . $args->capabilities['capability_type'], 897 'edit_posts' => 'edit_' . $args->capabilities['capability_type'] . 's', 898 'edit_others_posts' => 'edit_others_' . $args->capabilities['capability_type'] . 's', 899 'publish_posts' => 'publish_' . $args->capabilities['capability_type'] . 's', 900 'read_post' => 'edit_' . $args->capabilities['capability_type'], 901 'read_private_posts' => 'read_private_' . $args->capabilities['capability_type'] . 's', 902 'delete_post' => 'delete_' . $args->capabilities['capability_type'], 903 ); 904 $labels = array_merge( $defaults, $args->capabilities ); 905 return (object) $labels; 893 906 } 894 907 … … 1526 1539 if ( 'readable' == $perm && is_user_logged_in() ) { 1527 1540 $post_type_object = get_post_type_object($type); 1528 if ( !current_user_can( $post_type_object-> read_private_cap) ) {1541 if ( !current_user_can( $post_type_object->cap->read_private_posts ) ) { 1529 1542 $cache_key .= '_' . $perm . '_' . $user->ID; 1530 1543 $query .= " AND (post_status != 'private' OR ( post_author = '$user->ID' AND post_status = 'private' ))"; -
trunk/wp-includes/query.php
r14565 r14585 2193 2193 if ( !empty($post_type_object) ) { 2194 2194 $post_type_cap = $post_type_object->capability_type; 2195 $edit_cap = $post_type_object-> edit_cap;2196 $read_cap = $post_type_object-> read_cap;2197 $edit_others_cap = $post_type_object-> edit_others_cap;2198 $read_private_cap = $post_type_object-> read_private_cap;2195 $edit_cap = $post_type_object->cap->edit_post; 2196 $read_cap = $post_type_object->cap->read_post; 2197 $edit_others_cap = $post_type_object->cap->edit_other_posts; 2198 $read_private_cap = $post_type_object->cap->read_private_posts; 2199 2199 } else { 2200 2200 $edit_cap = 'edit_' . $post_type_cap;
Note: See TracChangeset
for help on using the changeset viewer.