<!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->post_type;
</span><span class="cx">         $post_type_object = get_post_type_object($post_type);
</span><del>-        $type_cap = $post_type_object->capability_type;
-        $can_publish = current_user_can("publish_${type_cap}s");
</del><ins>+        $can_publish = current_user_can($post_type_object->publish_cap);
</ins><span class="cx"> ?>
</span><span class="cx"> <div class="submitbox" id="submitpost">
</span><span class="cx">
</span><span class="lines">@@ -194,7 +193,7 @@
</span><span class="cx"> <?php do_action('post_submitbox_start'); ?>
</span><span class="cx"> <div id="delete-action">
</span><span class="cx"> <?php
</span><del>-if ( current_user_can( "delete_${type_cap}", $post->ID ) ) {
</del><ins>+if ( current_user_can( "delete_post", $post->ID ) ) {
</ins><span class="cx">         if ( !EMPTY_TRASH_DAYS ) {
</span><span class="cx">                 $delete_url = wp_nonce_url( add_query_arg( array('action' => 'delete', 'post' => $post->ID) ), "delete-${post_type}_{$post->ID}" );
</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->show_ui ) continue;
</del><ins>+                if ( !$taxonomy->show_ui )
+                        continue;
</ins><span class="cx">
</span><del>-                if( $taxonomy->hierarchical )
</del><ins>+                if ( $taxonomy->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) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
</span><del>-        // @todo use capability_type
</del><span class="cx">         $can_publish = current_user_can($post_type_object->publish_cap);
</span><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="lines">@@ -1561,11 +1561,11 @@
</span><span class="cx">                 }
</span><span class="cx">                 if ( current_user_can($post_type_object->delete_cap, $page->ID) ) {
</span><span class="cx">                         if ( $post->post_status == 'trash' )
</span><del>-                                $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>";
</del><ins>+                                $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-' . $post->post_type . '_' . $page->ID) . "'>" . __('Restore') . "</a>";
</ins><span class="cx">                         elseif ( EMPTY_TRASH_DAYS )
</span><span class="cx">                                 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this page to the Trash')) . "' href='" . get_delete_post_link($page->ID) . "'>" . __('Trash') . "</a>";
</span><span class="cx">                         if ( $post->post_status == 'trash' || !EMPTY_TRASH_DAYS )
</span><del>-                                $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>";
</del><ins>+                                $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-' . $post->post_type . '_' . $page->ID) . "'>" . __('Delete Permanently') . "</a>";
</ins><span class="cx">                 }
</span><span class="cx">                 if ( in_array($post->post_status, array('pending', 'draft')) ) {
</span><span class="cx">                         if ( current_user_can($post_type_object->edit_cap, $page->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->post_type );
</span><span class="cx">                 if ( $post_type && 'post' != $post_type->capability_type ) {
</span><del>-                        $args = array_merge( array( 'delete_' . $post_type->capability_type, $user_id ), $args );
</del><ins>+                        $args = array_merge( array( $post_type->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->post_type );
</span><span class="cx">                 if ( $post_type && 'post' != $post_type->capability_type ) {
</span><del>-                        $args = array_merge( array( 'edit_' . $post_type->capability_type, $user_id ), $args );
</del><ins>+                        $args = array_merge( array( $post_type->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->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->post_type );
</span><span class="cx">                 if ( $post_type && 'post' != $post_type->capability_type ) {
</span><del>-                        $args = array_merge( array( 'read_' . $post_type->capability_type, $user_id ), $args );
</del><ins>+                        $args = array_merge( array( $post_type->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>