<!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>[13786] trunk: Use correct cap checks and nonces for custom post_type's</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13786">13786</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2010-03-21 02:29:11 +0000 (Sun, 21 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use correct cap checks and nonces for custom post_type's</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesmetaboxesphp">trunk/wp-admin/includes/meta-boxes.php</a></li>
<li><a href="#trunkwpadminincludestemplatephp">trunk/wp-admin/includes/template.php</a></li>
<li><a href="#trunkwpincludescapabilitiesphp">trunk/wp-includes/capabilities.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesmetaboxesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/meta-boxes.php (13785 => 13786)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/meta-boxes.php        2010-03-21 01:49:00 UTC (rev 13785)
+++ trunk/wp-admin/includes/meta-boxes.php        2010-03-21 02:29:11 UTC (rev 13786)
</span><span class="lines">@@ -14,8 +14,7 @@
</span><span class="cx"> 
</span><span class="cx">         $post_type = $post-&gt;post_type;
</span><span class="cx">         $post_type_object = get_post_type_object($post_type);
</span><del>-        $type_cap = $post_type_object-&gt;capability_type;
-        $can_publish = current_user_can(&quot;publish_${type_cap}s&quot;);
</del><ins>+        $can_publish = current_user_can($post_type_object-&gt;publish_cap);
</ins><span class="cx"> ?&gt;
</span><span class="cx"> &lt;div class=&quot;submitbox&quot; id=&quot;submitpost&quot;&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -194,7 +193,7 @@
</span><span class="cx"> &lt;?php do_action('post_submitbox_start'); ?&gt;
</span><span class="cx"> &lt;div id=&quot;delete-action&quot;&gt;
</span><span class="cx"> &lt;?php
</span><del>-if ( current_user_can( &quot;delete_${type_cap}&quot;, $post-&gt;ID ) ) {
</del><ins>+if ( current_user_can( &quot;delete_post&quot;, $post-&gt;ID ) ) {
</ins><span class="cx">         if ( !EMPTY_TRASH_DAYS ) {
</span><span class="cx">                 $delete_url = wp_nonce_url( add_query_arg( array('action' =&gt; 'delete', 'post' =&gt; $post-&gt;ID) ), &quot;delete-${post_type}_{$post-&gt;ID}&quot; );
</span><span class="cx">                 $delete_text = __('Delete Permanently');
</span><span class="lines">@@ -407,7 +406,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /** 
</span><del>- * Displa comments for post table header
</del><ins>+ * Display comments for post table header
</ins><span class="cx">  * 
</span><span class="cx">  * @since 3.0
</span><span class="cx">  * 
</span></span></pre></div>
<a id="trunkwpadminincludestemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/template.php (13785 => 13786)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/template.php        2010-03-21 01:49:00 UTC (rev 13785)
+++ trunk/wp-admin/includes/template.php        2010-03-21 02:29:11 UTC (rev 13786)
</span><span class="lines">@@ -863,9 +863,10 @@
</span><span class="cx">         foreach ( $taxonomy_names as $taxonomy_name ) {
</span><span class="cx">                 $taxonomy = get_taxonomy( $taxonomy_name);
</span><span class="cx"> 
</span><del>-                if( !$taxonomy-&gt;show_ui ) continue;
</del><ins>+                if ( !$taxonomy-&gt;show_ui )
+                        continue;
</ins><span class="cx"> 
</span><del>-                if( $taxonomy-&gt;hierarchical )
</del><ins>+                if ( $taxonomy-&gt;hierarchical )
</ins><span class="cx">                         $hierarchical_taxonomies[] = $taxonomy;
</span><span class="cx">                 else
</span><span class="cx">                         $flat_taxonomies[] = $taxonomy;
</span><span class="lines">@@ -875,7 +876,6 @@
</span><span class="cx">         $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) );
</span><span class="cx">         $col_count = count($columns) - count($hidden);
</span><span class="cx">         $m = ( isset($mode) &amp;&amp; 'excerpt' == $mode ) ? 'excerpt' : 'list';
</span><del>-        // @todo use capability_type
</del><span class="cx">         $can_publish = current_user_can($post_type_object-&gt;publish_cap);
</span><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="lines">@@ -1561,11 +1561,11 @@
</span><span class="cx">                 }
</span><span class="cx">                 if ( current_user_can($post_type_object-&gt;delete_cap, $page-&gt;ID) ) {
</span><span class="cx">                         if ( $post-&gt;post_status == 'trash' )
</span><del>-                                $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;;
</del><ins>+                                $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-' . $post-&gt;post_type . '_' . $page-&gt;ID) . &quot;'&gt;&quot; . __('Restore') . &quot;&lt;/a&gt;&quot;;
</ins><span class="cx">                         elseif ( EMPTY_TRASH_DAYS )
</span><span class="cx">                                 $actions['trash'] = &quot;&lt;a class='submitdelete' title='&quot; . esc_attr(__('Move this page to the Trash')) . &quot;' href='&quot; . get_delete_post_link($page-&gt;ID) . &quot;'&gt;&quot; . __('Trash') . &quot;&lt;/a&gt;&quot;;
</span><span class="cx">                         if ( $post-&gt;post_status == 'trash' || !EMPTY_TRASH_DAYS )
</span><del>-                                $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;;
</del><ins>+                                $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-' . $post-&gt;post_type . '_' . $page-&gt;ID) . &quot;'&gt;&quot; . __('Delete Permanently') . &quot;&lt;/a&gt;&quot;;
</ins><span class="cx">                 }
</span><span class="cx">                 if ( in_array($post-&gt;post_status, array('pending', 'draft')) ) {
</span><span class="cx">                         if ( current_user_can($post_type_object-&gt;edit_cap, $page-&gt;ID) )
</span></span></pre></div>
<a id="trunkwpincludescapabilitiesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/capabilities.php (13785 => 13786)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/capabilities.php        2010-03-21 01:49:00 UTC (rev 13785)
+++ trunk/wp-includes/capabilities.php        2010-03-21 02:29:11 UTC (rev 13786)
</span><span class="lines">@@ -810,7 +810,7 @@
</span><span class="cx">                 $post = get_post( $args[0] );
</span><span class="cx">                 $post_type = get_post_type_object( $post-&gt;post_type );
</span><span class="cx">                 if ( $post_type &amp;&amp; 'post' != $post_type-&gt;capability_type ) {
</span><del>-                        $args = array_merge( array( 'delete_' . $post_type-&gt;capability_type, $user_id ), $args );
</del><ins>+                        $args = array_merge( array( $post_type-&gt;delete_cap, $user_id ), $args );
</ins><span class="cx">                         return call_user_func_array( 'map_meta_cap', $args );
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -887,7 +887,7 @@
</span><span class="cx">                 $post = get_post( $args[0] );
</span><span class="cx">                 $post_type = get_post_type_object( $post-&gt;post_type );
</span><span class="cx">                 if ( $post_type &amp;&amp; 'post' != $post_type-&gt;capability_type ) {
</span><del>-                        $args = array_merge( array( 'edit_' . $post_type-&gt;capability_type, $user_id ), $args );
</del><ins>+                        $args = array_merge( array( $post_type-&gt;edit_cap, $user_id ), $args );
</ins><span class="cx">                         return call_user_func_array( 'map_meta_cap', $args );
</span><span class="cx">                 }
</span><span class="cx">                 $post_author_data = get_userdata( $post-&gt;post_author );
</span><span class="lines">@@ -946,7 +946,7 @@
</span><span class="cx">                 $post = get_post( $args[0] );
</span><span class="cx">                 $post_type = get_post_type_object( $post-&gt;post_type );
</span><span class="cx">                 if ( $post_type &amp;&amp; 'post' != $post_type-&gt;capability_type ) {
</span><del>-                        $args = array_merge( array( 'read_' . $post_type-&gt;capability_type, $user_id ), $args );
</del><ins>+                        $args = array_merge( array( $post_type-&gt;read_cap, $user_id ), $args );
</ins><span class="cx">                         return call_user_func_array( 'map_meta_cap', $args );
</span><span class="cx">                 }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>