<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[12927] trunk: Allow customizing capabilities for custom post types.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12927">12927</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-02-02 17:37:03 +0000 (Tue, 02 Feb 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Allow customizing capabilities for custom post types. Always check caps against those in the post type object instead of contructing them manually. see <a href="http://trac.wordpress.org/ticket/9674">#9674</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmineditformadvancedphp">trunk/wp-admin/edit-form-advanced.php</a></li>
<li><a href="#trunkwpadmineditphp">trunk/wp-admin/edit.php</a></li>
<li><a href="#trunkwpadminincludestemplatephp">trunk/wp-admin/includes/template.php</a></li>
<li><a href="#trunkwpadminpostnewphp">trunk/wp-admin/post-new.php</a></li>
<li><a href="#trunkwpadminpostphp">trunk/wp-admin/post.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmineditformadvancedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-form-advanced.php (12926 => 12927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-form-advanced.php        2010-02-02 16:32:19 UTC (rev 12926)
+++ trunk/wp-admin/edit-form-advanced.php        2010-02-02 17:37:03 UTC (rev 12927)
</span><span class="lines">@@ -85,7 +85,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $post_type_object = get_post_type_object($post_type);
</span><del>-$post_type_cap = $post_type_object->capability_type;
</del><span class="cx">
</span><span class="cx"> // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
</span><span class="cx"> require_once('includes/meta-boxes.php');
</span><span class="lines">@@ -128,7 +127,7 @@
</span><span class="cx"> if ( ('publish' == $post->post_status || 'private' == $post->post_status) && post_type_supports($post_type, 'comments') )
</span><span class="cx">         add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core');
</span><span class="cx">
</span><del>-if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) )
</del><ins>+if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->publish_cap ) ) )
</ins><span class="cx">         add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core');
</span><span class="cx">
</span><span class="cx"> $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
</span><span class="lines">@@ -192,7 +191,7 @@
</span><span class="cx"> <div class="inside">
</span><span class="cx"> <?php
</span><span class="cx"> $sample_permalink_html = get_sample_permalink_html($post->ID);
</span><del>-if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_' . $post_type_cap . 's' ) ) ) { ?>
</del><ins>+if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->publish_cap ) ) ) { ?>
</ins><span class="cx">         <div id="edit-slug-box">
</span><span class="cx"> <?php
</span><span class="cx">         if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :
</span></span></pre></div>
<a id="trunkwpadmineditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit.php (12926 => 12927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit.php        2010-02-02 16:32:19 UTC (rev 12926)
+++ trunk/wp-admin/edit.php        2010-02-02 17:37:03 UTC (rev 12927)
</span><span class="lines">@@ -27,7 +27,6 @@
</span><span class="cx"> $_GET['post_type'] = $post_type;
</span><span class="cx">
</span><span class="cx"> $post_type_object = get_post_type_object($post_type);
</span><del>-$post_type_cap = $post_type_object->capability_type;
</del><span class="cx">
</span><span class="cx"> if ( 'post' != $post_type ) {
</span><span class="cx">         $parent_file = "edit.php?post_type=$post_type";
</span><span class="lines">@@ -72,7 +71,7 @@
</span><span class="cx">                 case 'trash':
</span><span class="cx">                         $trashed = 0;
</span><span class="cx">                         foreach( (array) $post_ids as $post_id ) {
</span><del>-                                if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
</del><ins>+                                if ( !current_user_can($post_type_object->delete_cap, $post_id) )
</ins><span class="cx">                                         wp_die( __('You are not allowed to move this item to the trash.') );
</span><span class="cx">
</span><span class="cx">                                 if ( !wp_trash_post($post_id) )
</span><span class="lines">@@ -85,7 +84,7 @@
</span><span class="cx">                 case 'untrash':
</span><span class="cx">                         $untrashed = 0;
</span><span class="cx">                         foreach( (array) $post_ids as $post_id ) {
</span><del>-                                if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
</del><ins>+                                if ( !current_user_can($post_type_object->delete_cap, $post_id) )
</ins><span class="cx">                                         wp_die( __('You are not allowed to restore this item from the trash.') );
</span><span class="cx">
</span><span class="cx">                                 if ( !wp_untrash_post($post_id) )
</span><span class="lines">@@ -100,7 +99,7 @@
</span><span class="cx">                         foreach( (array) $post_ids as $post_id ) {
</span><span class="cx">                                 $post_del = & get_post($post_id);
</span><span class="cx">
</span><del>-                                if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
</del><ins>+                                if ( !current_user_can($post_type_object->delete_cap, $post_id) )
</ins><span class="cx">                                         wp_die( __('You are not allowed to delete this item.') );
</span><span class="cx">
</span><span class="cx">                                 if ( $post_del->post_type == 'attachment' ) {
</span><span class="lines">@@ -141,7 +140,7 @@
</span><span class="cx"> wp_enqueue_script('inline-edit-post');
</span><span class="cx">
</span><span class="cx"> $user_posts = false;
</span><del>-if ( !current_user_can('edit_others_' . $post_type_cap . 's') ) {
</del><ins>+if ( !current_user_can($post_type_object->edit_others_cap) ) {
</ins><span class="cx">         $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) );
</span><span class="cx">         $user_posts = true;
</span><span class="cx">         if ( $user_posts_count && empty($_GET['post_status']) && empty($_GET['all_posts']) && empty($_GET['author']) )
</span><span class="lines">@@ -341,7 +340,7 @@
</span><span class="cx"> <input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
</span><span class="cx"> <?php }
</span><span class="cx">
</span><del>-if ( $is_trash && current_user_can('edit_others_' . $post_type_cap .'s') ) { ?>
</del><ins>+if ( $is_trash && current_user_can($post_type_object->edit_others_cap) ) { ?>
</ins><span class="cx"> <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
</span><span class="cx"> <?php } ?>
</span><span class="cx"> </div>
</span><span class="lines">@@ -388,7 +387,7 @@
</span><span class="cx"> <?php } ?>
</span><span class="cx"> </select>
</span><span class="cx"> <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
</span><del>-<?php if ( $is_trash && current_user_can('edit_others_' . $post_type_cap . 's') ) { ?>
</del><ins>+<?php if ( $is_trash && current_user_can($post_type_object->edit_others_cap) ) { ?>
</ins><span class="cx"> <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
</span><span class="cx"> <?php } ?>
</span><span class="cx"> <br class="clear" />
</span></span></pre></div>
<a id="trunkwpadminincludestemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/template.php (12926 => 12927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/template.php        2010-02-02 16:32:19 UTC (rev 12926)
+++ trunk/wp-admin/includes/template.php        2010-02-02 17:37:03 UTC (rev 12927)
</span><span class="lines">@@ -1128,7 +1128,7 @@
</span><span class="cx">         $col_count = count($columns) - count($hidden);
</span><span class="cx">         $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
</span><span class="cx">         // @todo use capability_type
</span><del>-        $can_publish = current_user_can("publish_{$screen->post_type}s");
</del><ins>+        $can_publish = current_user_can($post_type_object->publish_cap);
</ins><span class="cx">         $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
</span><span class="cx">
</span><span class="cx"> ?>
</span><span class="lines">@@ -1335,7 +1335,7 @@
</span><span class="cx">                                 </select>
</span><span class="cx">                         </label>
</span><span class="cx">
</span><del>-<?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( 'edit_others_posts' ) ) : ?>
</del><ins>+<?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->edit_others_cap ) ) : ?>
</ins><span class="cx">
</span><span class="cx"> <?php        if ( $bulk ) : ?>
</span><span class="cx">
</span><span class="lines">@@ -1357,7 +1357,7 @@
</span><span class="cx">
</span><span class="cx"> <?php        endif; // $bulk ?>
</span><span class="cx">
</span><del>-<?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ?>
</del><ins>+<?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_cap' ) ?>
</ins><span class="cx">
</span><span class="cx">                 </div>
</span><span class="cx">
</span><span class="lines">@@ -1404,8 +1404,8 @@
</span><span class="cx"> * @param unknown_type $post
</span><span class="cx"> */
</span><span class="cx"> function get_inline_data($post) {
</span><del>-
-        if ( ! current_user_can('edit_' . $post->post_type, $post->ID) )
</del><ins>+        $post_type_object = get_post_type_object($post->post_type);
+        if ( ! current_user_can($post_type_object->edit_cap, $post->ID) )
</ins><span class="cx">                 return;
</span><span class="cx">
</span><span class="cx">         $title = esc_attr($post->post_title);
</span><span class="lines">@@ -1426,17 +1426,23 @@
</span><span class="cx">         <div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
</span><span class="cx">         <div class="post_password">' . esc_html( $post->post_password ) . '</div>';
</span><span class="cx">
</span><ins>+        if ( $post_type_object->hierarchical )
+                echo '<div class="post_parent">' . $post->post_parent . '</div>';
+
</ins><span class="cx">         if ( $post->post_type == 'page' )
</span><del>-                echo '
-        <div class="post_parent">' . $post->post_parent . '</div>
-        <div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>
-        <div class="menu_order">' . $post->menu_order . '</div>';
</del><ins>+                echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>';
</ins><span class="cx">
</span><ins>+        if ( $post_type_object->hierarchical )
+                echo '<div class="menu_order">' . $post->menu_order . '</div>';
+
+        if ( is_object_in_taxonomy($post->post_type, 'post_tag') )
+                echo '<div class="tags_input">' . esc_html( str_replace( ',', ', ', get_tags_to_edit($post->ID) ) ) . '</div>';
+
+        if ( is_object_in_taxonomy($post->post_type, 'post_tag') )
+                echo '<div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div>';
+
</ins><span class="cx">         if ( $post->post_type == 'post' )
</span><del>-                echo '
-        <div class="tags_input">' . esc_html( str_replace( ',', ', ', get_tags_to_edit($post->ID) ) ) . '</div>
-        <div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div>
-        <div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
</del><ins>+                echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
</ins><span class="cx">
</span><span class="cx">         echo '</div>';
</span><span class="cx"> }
</span><span class="lines">@@ -1495,6 +1501,7 @@
</span><span class="cx">         $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
</span><span class="cx">         $edit_link = get_edit_post_link( $post->ID );
</span><span class="cx">         $title = _draft_or_post_title();
</span><ins>+        $post_type_object = get_post_type_object($post->post_type);
</ins><span class="cx"> ?>
</span><span class="cx">         <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top">
</span><span class="cx"> <?php
</span><span class="lines">@@ -1513,7 +1520,7 @@
</span><span class="cx">
</span><span class="cx">                 case 'cb':
</span><span class="cx">                 ?>
</span><del>-                <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>
</del><ins>+                <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>
</ins><span class="cx">                 <?php
</span><span class="cx">                 break;
</span><span class="cx">
</span><span class="lines">@@ -1556,17 +1563,17 @@
</span><span class="cx">                 case 'title':
</span><span class="cx">                         $attributes = 'class="post-title column-title"' . $style;
</span><span class="cx">                 ?>
</span><del>-                <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 &#8220;%s&#8221;'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
</del><ins>+                <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 &#8220;%s&#8221;'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
</ins><span class="cx">                 <?php
</span><span class="cx">                         if ( 'excerpt' == $mode )
</span><span class="cx">                                 the_excerpt();
</span><span class="cx">
</span><span class="cx">                         $actions = array();
</span><del>-                        if ( current_user_can('edit_post', $post->ID) && 'trash' != $post->post_status ) {
</del><ins>+                        if ( current_user_can($post_type_object->edit_cap, $post->ID) && 'trash' != $post->post_status ) {
</ins><span class="cx">                                 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>';
</span><span class="cx">                                 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick&nbsp;Edit') . '</a>';
</span><span class="cx">                         }
</span><del>-                        if ( current_user_can('delete_post', $post->ID) ) {
</del><ins>+                        if ( current_user_can($post_type_object->delete_cap, $post->ID) ) {
</ins><span class="cx">                                 if ( 'trash' == $post->post_status )
</span><span class="cx">                                         $actions['untrash'] = "<a title='" . esc_attr(__('Restore this post from the Trash')) . "' href='" . wp_nonce_url("post.php?action=untrash&amp;post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
</span><span class="cx">                                 elseif ( EMPTY_TRASH_DAYS )
</span><span class="lines">@@ -1575,7 +1582,7 @@
</span><span class="cx">                                         $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
</span><span class="cx">                         }
</span><span class="cx">                         if ( in_array($post->post_status, array('pending', 'draft')) ) {
</span><del>-                                if ( current_user_can('edit_post', $post->ID) )
</del><ins>+                                if ( current_user_can($post_type_object->edit_cap, $post->ID) )
</ins><span class="cx">                                         $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
</span><span class="cx">                         } elseif ( 'trash' != $post->post_status ) {
</span><span class="cx">                                 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
</span><span class="lines">@@ -1658,13 +1665,13 @@
</span><span class="cx">
</span><span class="cx">                 case 'control_edit':
</span><span class="cx">                 ?>
</span><del>-                <td><?php if ( current_user_can('edit_post', $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
</del><ins>+                <td><?php if ( current_user_can($post_type_object->edit_cap, $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
</ins><span class="cx">                 <?php
</span><span class="cx">                 break;
</span><span class="cx">
</span><span class="cx">                 case 'control_delete':
</span><span class="cx">                 ?>
</span><del>-                <td><?php if ( current_user_can('delete_post', $post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
</del><ins>+                <td><?php if ( current_user_can($post_type_object->delete_cap, $post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
</ins><span class="cx">                 <?php
</span><span class="cx">                 break;
</span><span class="cx">
</span><span class="lines">@@ -1725,11 +1732,12 @@
</span><span class="cx">         $hidden = get_hidden_columns( $current_screen );
</span><span class="cx">         $title = _draft_or_post_title();
</span><span class="cx">         $post_type = $page->post_type;
</span><ins>+        $post_type_object = get_post_type_object($post_type);
</ins><span class="cx"> ?>
</span><span class="cx"> <tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit">
</span><span class="cx"> <?php
</span><span class="cx">
</span><del>-foreach ($posts_columns as $column_name=>$column_display_name) {
</del><ins>+foreach ( $posts_columns as $column_name => $column_display_name ) {
</ins><span class="cx">         $class = "class=\"$column_name column-$column_name\"";
</span><span class="cx">
</span><span class="cx">         $style = '';
</span><span class="lines">@@ -1780,14 +1788,14 @@
</span><span class="cx">                 $attributes = 'class="post-title page-title column-title"' . $style;
</span><span class="cx">                 $edit_link = get_edit_post_link( $page->ID );
</span><span class="cx">                 ?>
</span><del>-                <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 &#8220;%s&#8221;'), $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>
</del><ins>+                <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 &#8220;%s&#8221;'), $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>
</ins><span class="cx">                 <?php
</span><span class="cx">                 $actions = array();
</span><del>-                if ( current_user_can('edit_page', $page->ID) && $post->post_status != 'trash' ) {
</del><ins>+                if ( current_user_can($post_type_object->edit_cap, $page->ID) && $post->post_status != 'trash' ) {
</ins><span class="cx">                         $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>';
</span><span class="cx">                         $actions['inline'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>';
</span><span class="cx">                 }
</span><del>-                if ( current_user_can('delete_page', $page->ID) ) {
</del><ins>+                if ( current_user_can($post_type_object->delete_cap, $page->ID) ) {
</ins><span class="cx">                         if ( $post->post_status == 'trash' )
</span><span class="cx">                                 $actions['untrash'] = "<a title='" . esc_attr(__('Remove this page from the Trash')) . "' href='" . wp_nonce_url("post.php?post_type=$post_type&amp;action=untrash&amp;post=$page->ID", 'untrash-page_' . $page->ID) . "'>" . __('Restore') . "</a>";
</span><span class="cx">                         elseif ( EMPTY_TRASH_DAYS )
</span><span class="lines">@@ -1796,7 +1804,7 @@
</span><span class="cx">                                 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page permanently')) . "' href='" . wp_nonce_url("post.php?post_type=$post_type&amp;action=delete&amp;post=$page->ID", 'delete-page_' . $page->ID) . "'>" . __('Delete Permanently') . "</a>";
</span><span class="cx">                 }
</span><span class="cx">                 if ( in_array($post->post_status, array('pending', 'draft')) ) {
</span><del>-                        if ( current_user_can('edit_page', $page->ID) )
</del><ins>+                        if ( current_user_can($post_type_object->edit_cap, $page->ID) )
</ins><span class="cx">                                 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
</span><span class="cx">                 } elseif ( $post->post_status != 'trash' ) {
</span><span class="cx">                         $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
</span><span class="lines">@@ -2214,7 +2222,8 @@
</span><span class="cx">         $comment = get_comment( $comment_id );
</span><span class="cx">         $post = get_post($comment->comment_post_ID);
</span><span class="cx">         $the_comment_status = wp_get_comment_status($comment->comment_ID);
</span><del>-        $user_can = current_user_can('edit_post', $post->ID);
</del><ins>+        $post_type_object = get_post_type_object($post->post_type);
+        $user_can = current_user_can($post_type_object->edit_cap, $post->ID);
</ins><span class="cx">
</span><span class="cx">         $author_url = get_comment_author_url();
</span><span class="cx">         if ( 'http://' == $author_url )
</span></span></pre></div>
<a id="trunkwpadminpostnewphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/post-new.php (12926 => 12927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/post-new.php        2010-02-02 16:32:19 UTC (rev 12926)
+++ trunk/wp-admin/post-new.php        2010-02-02 17:37:03 UTC (rev 12927)
</span><span class="lines">@@ -49,7 +49,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Show post form.
</span><del>-if ( current_user_can('edit_' . $post_type_object->capability_type . 's') ) {
</del><ins>+if ( current_user_can($post_type_object->edit_type_cap) ) {
</ins><span class="cx">         $post = get_default_post_to_edit( $post_type );
</span><span class="cx">         include('edit-form-advanced.php');
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadminpostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/post.php (12926 => 12927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/post.php        2010-02-02 16:32:19 UTC (rev 12926)
+++ trunk/wp-admin/post.php        2010-02-02 17:37:03 UTC (rev 12927)
</span><span class="lines">@@ -25,7 +25,6 @@
</span><span class="cx"> $post_ID = $post_id;
</span><span class="cx"> $post = null;
</span><span class="cx"> $post_type_object = null;
</span><del>-$post_type_cap = null;
</del><span class="cx"> $post_type = null;
</span><span class="cx"> if ( $post_id ) {
</span><span class="cx">         $post = get_post($post_id);
</span><span class="lines">@@ -35,7 +34,6 @@
</span><span class="cx">                         $post_type = $post->post_type;
</span><span class="cx">                         $current_screen->post_type = $post->post_type;
</span><span class="cx">                         $current_screen->id = $current_screen->post_type;
</span><del>-                        $post_type_cap = $post_type_object->capability_type;
</del><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> } elseif ( isset($_POST['post_type']) ) {
</span><span class="lines">@@ -44,7 +42,6 @@
</span><span class="cx">                 $post_type = $post_type_object->name;
</span><span class="cx">                 $current_screen->post_type = $post_type;
</span><span class="cx">                 $current_screen->id = $current_screen->post_type;
</span><del>-                $post_type_cap = $post_type_object->capability_type;
</del><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -233,7 +230,7 @@
</span><span class="cx">
</span><span class="cx">         $post = & get_post($post_id);
</span><span class="cx">
</span><del>-        if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
</del><ins>+        if ( !current_user_can($post_type_object->delete_cap, $post_id) )
</ins><span class="cx">                 wp_die( __('You are not allowed to move this item to the trash.') );
</span><span class="cx">
</span><span class="cx">         if ( ! wp_trash_post($post_id) )
</span><span class="lines">@@ -246,7 +243,7 @@
</span><span class="cx"> case 'untrash':
</span><span class="cx">         check_admin_referer('untrash-' . $post_type . '_' . $post_id);
</span><span class="cx">
</span><del>-        if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
</del><ins>+        if ( !current_user_can($post_type_object->delete_cap, $post_id) )
</ins><span class="cx">                 wp_die( __('You are not allowed to move this item out of the trash.') );
</span><span class="cx">
</span><span class="cx">         if ( ! wp_untrash_post($post_id) )
</span><span class="lines">@@ -259,7 +256,7 @@
</span><span class="cx"> case 'delete':
</span><span class="cx">         check_admin_referer('delete-' . $post_type . '_' . $post_id);
</span><span class="cx">
</span><del>-        if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
</del><ins>+        if ( !current_user_can($post_type_object->delete_cap, $post_id) )
</ins><span class="cx">                 wp_die( __('You are not allowed to delete this item.') );
</span><span class="cx">
</span><span class="cx">         $force = !EMPTY_TRASH_DAYS;
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (12926 => 12927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2010-02-02 16:32:19 UTC (rev 12926)
+++ trunk/wp-includes/post.php        2010-02-02 17:37:03 UTC (rev 12927)
</span><span class="lines">@@ -700,6 +700,12 @@
</span><span class="cx"> * publicly_queryable - Whether post_type queries can be performed from the front page. Defaults to whatever public is set as.
</span><span class="cx"> * inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none.
</span><span class="cx"> * capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post".
</span><ins>+ * edit_cap - The capability that controls editing a particular object of this post type. Defaults to "edit_$capability_type" (edit_post).
+ * edit_type_cap - The capability that controls editing objects of this post type as a class. Defaults to "edit_ . $capability_type . s" (edit_posts).
+ * 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).
+ * edit_others_cap - The capability that controls publishing objects of this post type. Defaults to "publish_ . $capability_type . s" (publish_posts).
+ * read_cap - The capability that controls reading a particular object of this post type. Defaults to "read_$capability_type" (read_post).
+ * delete_cap - The capability that controls deleting a particular object of this post type. Defaults to "delete_$capability_type" (delete_post).
</ins><span class="cx"> * hierarchical - Whether the post type is hierarchical. Defaults to false.
</span><span class="cx"> * supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none.
</span><span class="cx"> *
</span><span class="lines">@@ -736,15 +742,20 @@
</span><span class="cx">         if ( false === $args->label )
</span><span class="cx">                 $args->label = $post_type;
</span><span class="cx">
</span><del>-        if ( empty($args->capability_type) ) {
-                $args->edit_cap = '';
-                $args->read_cap = '';
-                $args->delete_cap = '';
-        } else {
</del><ins>+        if ( empty($args->capability_type) )
+                $args->capability_type = 'post';
+        if ( empty($args->edit_cap) )
</ins><span class="cx">                 $args->edit_cap = 'edit_' . $args->capability_type;
</span><ins>+        if ( empty($args->edit_type_cap) )
+                $args->edit_type_cap = 'edit_' . $args->capability_type . 's';
+        if ( empty($args->edit_others_cap) )
+                $args->edit_others_cap = 'edit_others_' . $args->capability_type . 's';
+        if ( empty($args->publish_cap) )
+                $args->publish_cap = 'publish_' . $args->capability_type . 's';
+        if ( empty($args->read_cap) )
</ins><span class="cx">                 $args->read_cap = 'read_' . $args->capability_type;
</span><ins>+        if ( empty($args->delete_cap) )
</ins><span class="cx">                 $args->delete_cap = 'delete_' . $args->capability_type;
</span><del>-        }
</del><span class="cx">
</span><span class="cx">         if ( !$args->_builtin && $args->public )
</span><span class="cx">                 $args->_show = true;
</span></span></pre>
</div>
</div>
</body>
</html>