<!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-&gt;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-&gt;post_status || 'private' == $post-&gt;post_status) &amp;&amp; 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-&gt;post_status &amp;&amp; !current_user_can( 'publish_posts' ) ) )
</del><ins>+if ( !( 'pending' == $post-&gt;post_status &amp;&amp; !current_user_can( $post_type_object-&gt;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-&gt;id ); // TODO: ROLE SYSTEM
</span><span class="lines">@@ -192,7 +191,7 @@
</span><span class="cx"> &lt;div class=&quot;inside&quot;&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx"> $sample_permalink_html = get_sample_permalink_html($post-&gt;ID);
</span><del>-if ( !( 'pending' == $post-&gt;post_status &amp;&amp; !current_user_can( 'publish_' . $post_type_cap . 's' ) ) ) { ?&gt;
</del><ins>+if ( !( 'pending' == $post-&gt;post_status &amp;&amp; !current_user_can( $post_type_object-&gt;publish_cap ) ) ) { ?&gt;
</ins><span class="cx">         &lt;div id=&quot;edit-slug-box&quot;&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx">         if ( ! empty($post-&gt;ID) &amp;&amp; ! 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-&gt;capability_type;
</del><span class="cx"> 
</span><span class="cx"> if ( 'post' != $post_type ) {
</span><span class="cx">         $parent_file = &quot;edit.php?post_type=$post_type&quot;;
</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-&gt;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-&gt;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 = &amp; 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-&gt;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-&gt;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-&gt;edit_others_cap) ) {
</ins><span class="cx">         $user_posts_count = $wpdb-&gt;get_var( $wpdb-&gt;prepare(&quot;SELECT COUNT(1) FROM $wpdb-&gt;posts WHERE post_type = '%s' AND post_status != 'trash' AND post_author = %d&quot;, $post_type, $current_user-&gt;ID) );
</span><span class="cx">         $user_posts = true;
</span><span class="cx">         if ( $user_posts_count &amp;&amp; empty($_GET['post_status']) &amp;&amp; empty($_GET['all_posts']) &amp;&amp; empty($_GET['author']) )
</span><span class="lines">@@ -341,7 +340,7 @@
</span><span class="cx"> &lt;input type=&quot;submit&quot; id=&quot;post-query-submit&quot; value=&quot;&lt;?php esc_attr_e('Filter'); ?&gt;&quot; class=&quot;button-secondary&quot; /&gt;
</span><span class="cx"> &lt;?php }
</span><span class="cx"> 
</span><del>-if ( $is_trash &amp;&amp; current_user_can('edit_others_' . $post_type_cap .'s') ) { ?&gt;
</del><ins>+if ( $is_trash &amp;&amp; current_user_can($post_type_object-&gt;edit_others_cap) ) { ?&gt;
</ins><span class="cx"> &lt;input type=&quot;submit&quot; name=&quot;delete_all&quot; id=&quot;delete_all&quot; value=&quot;&lt;?php esc_attr_e('Empty Trash'); ?&gt;&quot; class=&quot;button-secondary apply&quot; /&gt;
</span><span class="cx"> &lt;?php } ?&gt;
</span><span class="cx"> &lt;/div&gt;
</span><span class="lines">@@ -388,7 +387,7 @@
</span><span class="cx"> &lt;?php } ?&gt;
</span><span class="cx"> &lt;/select&gt;
</span><span class="cx"> &lt;input type=&quot;submit&quot; value=&quot;&lt;?php esc_attr_e('Apply'); ?&gt;&quot; name=&quot;doaction2&quot; id=&quot;doaction2&quot; class=&quot;button-secondary action&quot; /&gt;
</span><del>-&lt;?php if ( $is_trash &amp;&amp; current_user_can('edit_others_' . $post_type_cap . 's') ) { ?&gt;
</del><ins>+&lt;?php if ( $is_trash &amp;&amp; current_user_can($post_type_object-&gt;edit_others_cap) ) { ?&gt;
</ins><span class="cx"> &lt;input type=&quot;submit&quot; name=&quot;delete_all2&quot; id=&quot;delete_all2&quot; value=&quot;&lt;?php esc_attr_e('Empty Trash'); ?&gt;&quot; class=&quot;button-secondary apply&quot; /&gt;
</span><span class="cx"> &lt;?php } ?&gt;
</span><span class="cx"> &lt;br class=&quot;clear&quot; /&gt;
</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) &amp;&amp; 'excerpt' == $mode ) ? 'excerpt' : 'list';
</span><span class="cx">         // @todo use capability_type
</span><del>-        $can_publish = current_user_can(&quot;publish_{$screen-&gt;post_type}s&quot;);
</del><ins>+        $can_publish = current_user_can($post_type_object-&gt;publish_cap);
</ins><span class="cx">         $core_columns = array( 'cb' =&gt; true, 'date' =&gt; true, 'title' =&gt; true, 'categories' =&gt; true, 'tags' =&gt; true, 'comments' =&gt; true, 'author' =&gt; true );
</span><span class="cx"> 
</span><span class="cx"> ?&gt;
</span><span class="lines">@@ -1335,7 +1335,7 @@
</span><span class="cx">                                 &lt;/select&gt;
</span><span class="cx">                         &lt;/label&gt;
</span><span class="cx"> 
</span><del>-&lt;?php if ( 'post' == $screen-&gt;post_type &amp;&amp; $can_publish &amp;&amp; current_user_can( 'edit_others_posts' ) ) : ?&gt;
</del><ins>+&lt;?php if ( 'post' == $screen-&gt;post_type &amp;&amp; $can_publish &amp;&amp; current_user_can( $post_type_object-&gt;edit_others_cap ) ) : ?&gt;
</ins><span class="cx"> 
</span><span class="cx"> &lt;?php        if ( $bulk ) : ?&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -1357,7 +1357,7 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;?php        endif; // $bulk ?&gt;
</span><span class="cx"> 
</span><del>-&lt;?php endif; // !$is_page &amp;&amp; $can_publish &amp;&amp; current_user_can( 'edit_others_posts' ) ?&gt;
</del><ins>+&lt;?php endif; // !$is_page &amp;&amp; $can_publish &amp;&amp; current_user_can( 'edit_others_cap' ) ?&gt;
</ins><span class="cx"> 
</span><span class="cx">                 &lt;/div&gt;
</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-&gt;post_type, $post-&gt;ID) )
</del><ins>+        $post_type_object = get_post_type_object($post-&gt;post_type);
+        if ( ! current_user_can($post_type_object-&gt;edit_cap, $post-&gt;ID) )
</ins><span class="cx">                 return;
</span><span class="cx"> 
</span><span class="cx">         $title = esc_attr($post-&gt;post_title);
</span><span class="lines">@@ -1426,17 +1426,23 @@
</span><span class="cx">         &lt;div class=&quot;ss&quot;&gt;' . mysql2date( 's', $post-&gt;post_date, false ) . '&lt;/div&gt;
</span><span class="cx">         &lt;div class=&quot;post_password&quot;&gt;' . esc_html( $post-&gt;post_password ) . '&lt;/div&gt;';
</span><span class="cx"> 
</span><ins>+        if ( $post_type_object-&gt;hierarchical )
+                echo '&lt;div class=&quot;post_parent&quot;&gt;' . $post-&gt;post_parent . '&lt;/div&gt;';
+
</ins><span class="cx">         if ( $post-&gt;post_type == 'page' )
</span><del>-                echo '
-        &lt;div class=&quot;post_parent&quot;&gt;' . $post-&gt;post_parent . '&lt;/div&gt;
-        &lt;div class=&quot;page_template&quot;&gt;' . esc_html( get_post_meta( $post-&gt;ID, '_wp_page_template', true ) ) . '&lt;/div&gt;
-        &lt;div class=&quot;menu_order&quot;&gt;' . $post-&gt;menu_order . '&lt;/div&gt;';
</del><ins>+                echo '&lt;div class=&quot;page_template&quot;&gt;' . esc_html( get_post_meta( $post-&gt;ID, '_wp_page_template', true ) ) . '&lt;/div&gt;';
</ins><span class="cx"> 
</span><ins>+        if ( $post_type_object-&gt;hierarchical )
+                echo '&lt;div class=&quot;menu_order&quot;&gt;' . $post-&gt;menu_order . '&lt;/div&gt;';
+
+        if ( is_object_in_taxonomy($post-&gt;post_type, 'post_tag') )
+                echo '&lt;div class=&quot;tags_input&quot;&gt;' . esc_html( str_replace( ',', ', ', get_tags_to_edit($post-&gt;ID) ) ) . '&lt;/div&gt;';
+
+        if ( is_object_in_taxonomy($post-&gt;post_type, 'post_tag') )
+                echo '&lt;div class=&quot;post_category&quot;&gt;' . implode( ',', wp_get_post_categories( $post-&gt;ID ) ) . '&lt;/div&gt;';
+
</ins><span class="cx">         if ( $post-&gt;post_type == 'post' )
</span><del>-                echo '
-        &lt;div class=&quot;tags_input&quot;&gt;' . esc_html( str_replace( ',', ', ', get_tags_to_edit($post-&gt;ID) ) ) . '&lt;/div&gt;
-        &lt;div class=&quot;post_category&quot;&gt;' . implode( ',', wp_get_post_categories( $post-&gt;ID ) ) . '&lt;/div&gt;
-        &lt;div class=&quot;sticky&quot;&gt;' . (is_sticky($post-&gt;ID) ? 'sticky' : '') . '&lt;/div&gt;';
</del><ins>+                echo '&lt;div class=&quot;sticky&quot;&gt;' . (is_sticky($post-&gt;ID) ? 'sticky' : '') . '&lt;/div&gt;';
</ins><span class="cx"> 
</span><span class="cx">         echo '&lt;/div&gt;';
</span><span class="cx"> }
</span><span class="lines">@@ -1495,6 +1501,7 @@
</span><span class="cx">         $post_owner = ( $current_user-&gt;ID == $post-&gt;post_author ? 'self' : 'other' );
</span><span class="cx">         $edit_link = get_edit_post_link( $post-&gt;ID );
</span><span class="cx">         $title = _draft_or_post_title();
</span><ins>+        $post_type_object = get_post_type_object($post-&gt;post_type);
</ins><span class="cx"> ?&gt;
</span><span class="cx">         &lt;tr id='post-&lt;?php echo $post-&gt;ID; ?&gt;' class='&lt;?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post-&gt;post_status ); ?&gt; iedit' valign=&quot;top&quot;&gt;
</span><span class="cx"> &lt;?php
</span><span class="lines">@@ -1513,7 +1520,7 @@
</span><span class="cx"> 
</span><span class="cx">                 case 'cb':
</span><span class="cx">                 ?&gt;
</span><del>-                &lt;th scope=&quot;row&quot; class=&quot;check-column&quot;&gt;&lt;?php if ( current_user_can( 'edit_post', $post-&gt;ID ) ) { ?&gt;&lt;input type=&quot;checkbox&quot; name=&quot;post[]&quot; value=&quot;&lt;?php the_ID(); ?&gt;&quot; /&gt;&lt;?php } ?&gt;&lt;/th&gt;
</del><ins>+                &lt;th scope=&quot;row&quot; class=&quot;check-column&quot;&gt;&lt;?php if ( current_user_can( $post_type_object-&gt;edit_cap, $post-&gt;ID ) ) { ?&gt;&lt;input type=&quot;checkbox&quot; name=&quot;post[]&quot; value=&quot;&lt;?php the_ID(); ?&gt;&quot; /&gt;&lt;?php } ?&gt;&lt;/th&gt;
</ins><span class="cx">                 &lt;?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=&quot;post-title column-title&quot;' . $style;
</span><span class="cx">                 ?&gt;
</span><del>-                &lt;td &lt;?php echo $attributes ?&gt;&gt;&lt;strong&gt;&lt;?php if ( current_user_can('edit_post', $post-&gt;ID) &amp;&amp; $post-&gt;post_status != 'trash' ) { ?&gt;&lt;a class=&quot;row-title&quot; href=&quot;&lt;?php echo $edit_link; ?&gt;&quot; title=&quot;&lt;?php echo esc_attr(sprintf(__('Edit &amp;#8220;%s&amp;#8221;'), $title)); ?&gt;&quot;&gt;&lt;?php echo $title ?&gt;&lt;/a&gt;&lt;?php } else { echo $title; }; _post_states($post); ?&gt;&lt;/strong&gt;
</del><ins>+                &lt;td &lt;?php echo $attributes ?&gt;&gt;&lt;strong&gt;&lt;?php if ( current_user_can($post_type_object-&gt;edit_cap, $post-&gt;ID) &amp;&amp; $post-&gt;post_status != 'trash' ) { ?&gt;&lt;a class=&quot;row-title&quot; href=&quot;&lt;?php echo $edit_link; ?&gt;&quot; title=&quot;&lt;?php echo esc_attr(sprintf(__('Edit &amp;#8220;%s&amp;#8221;'), $title)); ?&gt;&quot;&gt;&lt;?php echo $title ?&gt;&lt;/a&gt;&lt;?php } else { echo $title; }; _post_states($post); ?&gt;&lt;/strong&gt;
</ins><span class="cx">                 &lt;?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-&gt;ID) &amp;&amp; 'trash' != $post-&gt;post_status ) {
</del><ins>+                        if ( current_user_can($post_type_object-&gt;edit_cap, $post-&gt;ID) &amp;&amp; 'trash' != $post-&gt;post_status ) {
</ins><span class="cx">                                 $actions['edit'] = '&lt;a href=&quot;' . get_edit_post_link($post-&gt;ID, true) . '&quot; title=&quot;' . esc_attr(__('Edit this post')) . '&quot;&gt;' . __('Edit') . '&lt;/a&gt;';
</span><span class="cx">                                 $actions['inline hide-if-no-js'] = '&lt;a href=&quot;#&quot; class=&quot;editinline&quot; title=&quot;' . esc_attr(__('Edit this post inline')) . '&quot;&gt;' . __('Quick&amp;nbsp;Edit') . '&lt;/a&gt;';
</span><span class="cx">                         }
</span><del>-                        if ( current_user_can('delete_post', $post-&gt;ID) ) {
</del><ins>+                        if ( current_user_can($post_type_object-&gt;delete_cap, $post-&gt;ID) ) {
</ins><span class="cx">                                 if ( 'trash' == $post-&gt;post_status )
</span><span class="cx">                                         $actions['untrash'] = &quot;&lt;a title='&quot; . esc_attr(__('Restore this post from the Trash')) . &quot;' href='&quot; . wp_nonce_url(&quot;post.php?action=untrash&amp;amp;post=$post-&gt;ID&quot;, 'untrash-post_' . $post-&gt;ID) . &quot;'&gt;&quot; . __('Restore') . &quot;&lt;/a&gt;&quot;;
</span><span class="cx">                                 elseif ( EMPTY_TRASH_DAYS )
</span><span class="lines">@@ -1575,7 +1582,7 @@
</span><span class="cx">                                         $actions['delete'] = &quot;&lt;a class='submitdelete' title='&quot; . esc_attr(__('Delete this post permanently')) . &quot;' href='&quot; . wp_nonce_url(&quot;post.php?action=delete&amp;amp;post=$post-&gt;ID&quot;, 'delete-post_' . $post-&gt;ID) . &quot;'&gt;&quot; . __('Delete Permanently') . &quot;&lt;/a&gt;&quot;;
</span><span class="cx">                         }
</span><span class="cx">                         if ( in_array($post-&gt;post_status, array('pending', 'draft')) ) {
</span><del>-                                if ( current_user_can('edit_post', $post-&gt;ID) )
</del><ins>+                                if ( current_user_can($post_type_object-&gt;edit_cap, $post-&gt;ID) )
</ins><span class="cx">                                         $actions['view'] = '&lt;a href=&quot;' . get_permalink($post-&gt;ID) . '&quot; title=&quot;' . esc_attr(sprintf(__('Preview &amp;#8220;%s&amp;#8221;'), $title)) . '&quot; rel=&quot;permalink&quot;&gt;' . __('Preview') . '&lt;/a&gt;';
</span><span class="cx">                         } elseif ( 'trash' != $post-&gt;post_status ) {
</span><span class="cx">                                 $actions['view'] = '&lt;a href=&quot;' . get_permalink($post-&gt;ID) . '&quot; title=&quot;' . esc_attr(sprintf(__('View &amp;#8220;%s&amp;#8221;'), $title)) . '&quot; rel=&quot;permalink&quot;&gt;' . __('View') . '&lt;/a&gt;';
</span><span class="lines">@@ -1658,13 +1665,13 @@
</span><span class="cx"> 
</span><span class="cx">                 case 'control_edit':
</span><span class="cx">                 ?&gt;
</span><del>-                &lt;td&gt;&lt;?php if ( current_user_can('edit_post', $post-&gt;ID) ) { echo &quot;&lt;a href='$edit_link' class='edit'&gt;&quot; . __('Edit') . &quot;&lt;/a&gt;&quot;; } ?&gt;&lt;/td&gt;
</del><ins>+                &lt;td&gt;&lt;?php if ( current_user_can($post_type_object-&gt;edit_cap, $post-&gt;ID) ) { echo &quot;&lt;a href='$edit_link' class='edit'&gt;&quot; . __('Edit') . &quot;&lt;/a&gt;&quot;; } ?&gt;&lt;/td&gt;
</ins><span class="cx">                 &lt;?php
</span><span class="cx">                 break;
</span><span class="cx"> 
</span><span class="cx">                 case 'control_delete':
</span><span class="cx">                 ?&gt;
</span><del>-                &lt;td&gt;&lt;?php if ( current_user_can('delete_post', $post-&gt;ID) ) { echo &quot;&lt;a href='&quot; . wp_nonce_url(&quot;post.php?action=delete&amp;amp;post=$id&quot;, 'delete-post_' . $post-&gt;ID) . &quot;' class='delete'&gt;&quot; . __('Delete') . &quot;&lt;/a&gt;&quot;; } ?&gt;&lt;/td&gt;
</del><ins>+                &lt;td&gt;&lt;?php if ( current_user_can($post_type_object-&gt;delete_cap, $post-&gt;ID) ) { echo &quot;&lt;a href='&quot; . wp_nonce_url(&quot;post.php?action=delete&amp;amp;post=$id&quot;, 'delete-post_' . $post-&gt;ID) . &quot;' class='delete'&gt;&quot; . __('Delete') . &quot;&lt;/a&gt;&quot;; } ?&gt;&lt;/td&gt;
</ins><span class="cx">                 &lt;?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-&gt;post_type;
</span><ins>+        $post_type_object = get_post_type_object($post_type);
</ins><span class="cx"> ?&gt;
</span><span class="cx"> &lt;tr id=&quot;page-&lt;?php echo $id; ?&gt;&quot; class=&quot;&lt;?php echo $rowclass; ?&gt; iedit&quot;&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx"> 
</span><del>-foreach ($posts_columns as $column_name=&gt;$column_display_name) {
</del><ins>+foreach ( $posts_columns as $column_name =&gt; $column_display_name ) {
</ins><span class="cx">         $class = &quot;class=\&quot;$column_name column-$column_name\&quot;&quot;;
</span><span class="cx"> 
</span><span class="cx">         $style = '';
</span><span class="lines">@@ -1780,14 +1788,14 @@
</span><span class="cx">                 $attributes = 'class=&quot;post-title page-title column-title&quot;' . $style;
</span><span class="cx">                 $edit_link = get_edit_post_link( $page-&gt;ID );
</span><span class="cx">                 ?&gt;
</span><del>-                &lt;td &lt;?php echo $attributes ?&gt;&gt;&lt;strong&gt;&lt;?php if ( current_user_can('edit_page', $page-&gt;ID) &amp;&amp; $post-&gt;post_status != 'trash' ) { ?&gt;&lt;a class=&quot;row-title&quot; href=&quot;&lt;?php echo $edit_link; ?&gt;&quot; title=&quot;&lt;?php echo esc_attr(sprintf(__('Edit &amp;#8220;%s&amp;#8221;'), $title)); ?&gt;&quot;&gt;&lt;?php echo $pad; echo $title ?&gt;&lt;/a&gt;&lt;?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . __('Parent Page: ') . esc_html($parent_name) : ''; ?&gt;&lt;/strong&gt;
</del><ins>+                &lt;td &lt;?php echo $attributes ?&gt;&gt;&lt;strong&gt;&lt;?php if ( current_user_can($post_type_object-&gt;edit_cap, $page-&gt;ID) &amp;&amp; $post-&gt;post_status != 'trash' ) { ?&gt;&lt;a class=&quot;row-title&quot; href=&quot;&lt;?php echo $edit_link; ?&gt;&quot; title=&quot;&lt;?php echo esc_attr(sprintf(__('Edit &amp;#8220;%s&amp;#8221;'), $title)); ?&gt;&quot;&gt;&lt;?php echo $pad; echo $title ?&gt;&lt;/a&gt;&lt;?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . __('Parent Page: ') . esc_html($parent_name) : ''; ?&gt;&lt;/strong&gt;
</ins><span class="cx">                 &lt;?php
</span><span class="cx">                 $actions = array();
</span><del>-                if ( current_user_can('edit_page', $page-&gt;ID) &amp;&amp; $post-&gt;post_status != 'trash' ) {
</del><ins>+                if ( current_user_can($post_type_object-&gt;edit_cap, $page-&gt;ID) &amp;&amp; $post-&gt;post_status != 'trash' ) {
</ins><span class="cx">                         $actions['edit'] = '&lt;a href=&quot;' . $edit_link . '&quot; title=&quot;' . esc_attr(__('Edit this page')) . '&quot;&gt;' . __('Edit') . '&lt;/a&gt;';
</span><span class="cx">                         $actions['inline'] = '&lt;a href=&quot;#&quot; class=&quot;editinline&quot;&gt;' . __('Quick&amp;nbsp;Edit') . '&lt;/a&gt;';
</span><span class="cx">                 }
</span><del>-                if ( current_user_can('delete_page', $page-&gt;ID) ) {
</del><ins>+                if ( current_user_can($post_type_object-&gt;delete_cap, $page-&gt;ID) ) {
</ins><span class="cx">                         if ( $post-&gt;post_status == 'trash' )
</span><span class="cx">                                 $actions['untrash'] = &quot;&lt;a title='&quot; . esc_attr(__('Remove this page from the Trash')) . &quot;' href='&quot; . wp_nonce_url(&quot;post.php?post_type=$post_type&amp;amp;action=untrash&amp;amp;post=$page-&gt;ID&quot;, 'untrash-page_' . $page-&gt;ID) . &quot;'&gt;&quot; . __('Restore') . &quot;&lt;/a&gt;&quot;;
</span><span class="cx">                         elseif ( EMPTY_TRASH_DAYS )
</span><span class="lines">@@ -1796,7 +1804,7 @@
</span><span class="cx">                                 $actions['delete'] = &quot;&lt;a class='submitdelete' title='&quot; . esc_attr(__('Delete this page permanently')) . &quot;' href='&quot; . wp_nonce_url(&quot;post.php?post_type=$post_type&amp;amp;action=delete&amp;amp;post=$page-&gt;ID&quot;, 'delete-page_' . $page-&gt;ID) . &quot;'&gt;&quot; . __('Delete Permanently') . &quot;&lt;/a&gt;&quot;;
</span><span class="cx">                 }
</span><span class="cx">                 if ( in_array($post-&gt;post_status, array('pending', 'draft')) ) {
</span><del>-                        if ( current_user_can('edit_page', $page-&gt;ID) )
</del><ins>+                        if ( current_user_can($post_type_object-&gt;edit_cap, $page-&gt;ID) )
</ins><span class="cx">                                 $actions['view'] = '&lt;a href=&quot;' . get_permalink($page-&gt;ID) . '&quot; title=&quot;' . esc_attr(sprintf(__('Preview &amp;#8220;%s&amp;#8221;'), $title)) . '&quot; rel=&quot;permalink&quot;&gt;' . __('Preview') . '&lt;/a&gt;';
</span><span class="cx">                 } elseif ( $post-&gt;post_status != 'trash' ) {
</span><span class="cx">                         $actions['view'] = '&lt;a href=&quot;' . get_permalink($page-&gt;ID) . '&quot; title=&quot;' . esc_attr(sprintf(__('View &amp;#8220;%s&amp;#8221;'), $title)) . '&quot; rel=&quot;permalink&quot;&gt;' . __('View') . '&lt;/a&gt;';
</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-&gt;comment_post_ID);
</span><span class="cx">         $the_comment_status = wp_get_comment_status($comment-&gt;comment_ID);
</span><del>-        $user_can = current_user_can('edit_post', $post-&gt;ID);
</del><ins>+        $post_type_object = get_post_type_object($post-&gt;post_type);
+        $user_can = current_user_can($post_type_object-&gt;edit_cap, $post-&gt;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-&gt;capability_type . 's') ) {
</del><ins>+if ( current_user_can($post_type_object-&gt;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-&gt;post_type;
</span><span class="cx">                         $current_screen-&gt;post_type = $post-&gt;post_type;
</span><span class="cx">                         $current_screen-&gt;id = $current_screen-&gt;post_type;
</span><del>-                        $post_type_cap = $post_type_object-&gt;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-&gt;name;
</span><span class="cx">                 $current_screen-&gt;post_type = $post_type;
</span><span class="cx">                 $current_screen-&gt;id = $current_screen-&gt;post_type;
</span><del>-                $post_type_cap = $post_type_object-&gt;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 = &amp; 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-&gt;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-&gt;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-&gt;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 &quot;post&quot;.
</span><ins>+ * edit_cap - The capability that controls editing a particular object of this post type. Defaults to &quot;edit_$capability_type&quot; (edit_post).
+ * edit_type_cap - The capability that controls editing objects of this post type as a class. Defaults to &quot;edit_ . $capability_type . s&quot; (edit_posts).
+ * edit_others_cap - The capability that controls editing objects of this post type that are owned by other users. Defaults to &quot;edit_others_ . $capability_type . s&quot; (edit_others_posts).
+ * edit_others_cap - The capability that controls publishing objects of this post type. Defaults to &quot;publish_ . $capability_type . s&quot; (publish_posts).
+ * read_cap - The capability that controls reading a particular object of this post type. Defaults to &quot;read_$capability_type&quot; (read_post).
+ * delete_cap - The capability that controls deleting a particular object of this post type. Defaults to &quot;delete_$capability_type&quot; (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-&gt;label )
</span><span class="cx">                 $args-&gt;label = $post_type;
</span><span class="cx"> 
</span><del>-        if ( empty($args-&gt;capability_type) ) {
-                $args-&gt;edit_cap = '';
-                $args-&gt;read_cap = '';
-                $args-&gt;delete_cap = '';
-        } else {
</del><ins>+        if ( empty($args-&gt;capability_type) )
+                $args-&gt;capability_type = 'post';
+        if ( empty($args-&gt;edit_cap) )
</ins><span class="cx">                 $args-&gt;edit_cap = 'edit_' . $args-&gt;capability_type;
</span><ins>+        if ( empty($args-&gt;edit_type_cap) )
+                $args-&gt;edit_type_cap = 'edit_' . $args-&gt;capability_type . 's';
+        if ( empty($args-&gt;edit_others_cap) )
+                $args-&gt;edit_others_cap = 'edit_others_' . $args-&gt;capability_type . 's';
+        if ( empty($args-&gt;publish_cap) )
+                $args-&gt;publish_cap = 'publish_' . $args-&gt;capability_type . 's';
+        if ( empty($args-&gt;read_cap) )
</ins><span class="cx">                 $args-&gt;read_cap = 'read_' . $args-&gt;capability_type;
</span><ins>+        if ( empty($args-&gt;delete_cap) )
</ins><span class="cx">                 $args-&gt;delete_cap = 'delete_' . $args-&gt;capability_type;
</span><del>-        }
</del><span class="cx"> 
</span><span class="cx">         if ( !$args-&gt;_builtin &amp;&amp; $args-&gt;public )
</span><span class="cx">                 $args-&gt;_show = true;
</span></span></pre>
</div>
</div>

</body>
</html>