<!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>[12597] trunk: More custom post type support.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12597">12597</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-01-04 16:58:43 +0000 (Mon, 04 Jan 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>More custom post type support. Props scribu. see <a href="http://trac.wordpress.org/ticket/9674">#9674</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminadminajaxphp">trunk/wp-admin/admin-ajax.php</a></li>
<li><a href="#trunkwpadminadminheaderphp">trunk/wp-admin/admin-header.php</a></li>
<li><a href="#trunkwpadmineditformadvancedphp">trunk/wp-admin/edit-form-advanced.php</a></li>
<li><a href="#trunkwpadminedittagsphp">trunk/wp-admin/edit-tags.php</a></li>
<li><a href="#trunkwpadmineditphp">trunk/wp-admin/edit.php</a></li>
<li><a href="#trunkwpadminincludesmetaboxesphp">trunk/wp-admin/includes/meta-boxes.php</a></li>
<li><a href="#trunkwpadminincludespluginphp">trunk/wp-admin/includes/plugin.php</a></li>
<li><a href="#trunkwpadminincludespostphp">trunk/wp-admin/includes/post.php</a></li>
<li><a href="#trunkwpadminincludestemplatephp">trunk/wp-admin/includes/template.php</a></li>
<li><a href="#trunkwpadminjspostdevjs">trunk/wp-admin/js/post.dev.js</a></li>
<li><a href="#trunkwpadminjspostjs">trunk/wp-admin/js/post.js</a></li>
<li><a href="#trunkwpadminmenuheaderphp">trunk/wp-admin/menu-header.php</a></li>
<li><a href="#trunkwpadminmenuphp">trunk/wp-admin/menu.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="#trunkwpincludescapabilitiesphp">trunk/wp-includes/capabilities.php</a></li>
<li><a href="#trunkwpincludeslinktemplatephp">trunk/wp-includes/link-template.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
<li><a href="#trunkwpincludesqueryphp">trunk/wp-includes/query.php</a></li>
<li><a href="#trunkwpincludestaxonomyphp">trunk/wp-includes/taxonomy.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminadminajaxphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/admin-ajax.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/admin-ajax.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-admin/admin-ajax.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -1135,7 +1135,7 @@
</span><span class="cx">         if ( 'page' == $_POST['post_type'] ) {
</span><span class="cx">                 $post[] = get_post($_POST['post_ID']);
</span><span class="cx">                 page_rows($post);
</span><del>-        } elseif ( 'post' == $_POST['post_type'] ) {
</del><ins>+        } elseif ( 'post' == $_POST['post_type'] || in_array($_POST['post_type'], get_post_types( array('_show' => true) ) ) ) {
</ins><span class="cx">                 $mode = $_POST['post_view'];
</span><span class="cx">                 $post[] = get_post($_POST['post_ID']);
</span><span class="cx">                 post_rows($post);
</span></span></pre></div>
<a id="trunkwpadminadminheaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/admin-header.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/admin-header.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-admin/admin-header.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -35,13 +35,20 @@
</span><span class="cx"> else if ( isset($pagenow) )
</span><span class="cx">         $hook_suffix = $pagenow;
</span><span class="cx">
</span><ins>+if ( isset($submenu_file) && (false !== $pos = strpos($submenu_file, 'post_type=')) )
+        $typenow = substr($submenu_file, $pos + 10);
+elseif ( isset($parent_file) && (false !== $pos = strpos($parent_file, 'post_type=')) )
+        $typenow = substr($parent_file, $pos + 10);
+else
+        $typenow = '';
+
</ins><span class="cx"> $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
</span><span class="cx"> ?>
</span><span class="cx"> <script type="text/javascript">
</span><span class="cx"> //<![CDATA[
</span><span class="cx"> addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
</span><span class="cx"> var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'};
</span><del>-var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = '<?php echo substr($pagenow, 0, -4); ?>', adminpage = '<?php echo $admin_body_class; ?>', thousandsSeparator = '<?php echo $wp_locale->number_format['thousands_sep']; ?>', decimalPoint = '<?php echo $wp_locale->number_format['decimal_point']; ?>';
</del><ins>+var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = '<?php echo substr($pagenow, 0, -4); ?>', typenow = '<?php echo $typenow; ?>', adminpage = '<?php echo $admin_body_class; ?>', thousandsSeparator = '<?php echo $wp_locale->number_format['thousands_sep']; ?>', decimalPoint = '<?php echo $wp_locale->number_format['decimal_point']; ?>';
</ins><span class="cx"> //]]>
</span><span class="cx"> </script>
</span><span class="cx"> <?php
</span></span></pre></div>
<a id="trunkwpadmineditformadvancedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-form-advanced.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-form-advanced.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-admin/edit-form-advanced.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -85,45 +85,46 @@
</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="cx">
</span><del>-add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', 'post', 'side', 'core');
</del><ins>+add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $post_type, 'side', 'core');
</ins><span class="cx">
</span><span class="cx"> // all tag-style post taxonomies
</span><del>-foreach ( get_object_taxonomies('post') as $tax_name ) {
</del><ins>+foreach ( get_object_taxonomies($post_type) as $tax_name ) {
</ins><span class="cx">         if ( !is_taxonomy_hierarchical($tax_name) ) {
</span><span class="cx">                 $taxonomy = get_taxonomy($tax_name);
</span><span class="cx">                 $label = isset($taxonomy->label) ? esc_attr($taxonomy->label) : $tax_name;
</span><span class="cx">
</span><del>-                add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', 'post', 'side', 'core');
</del><ins>+                add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', $post_type, 'side', 'core');
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core');
-if ( current_theme_supports( 'post-thumbnails', 'post' ) )
-        add_meta_box('postimagediv', __('Post Thumbnail'), 'post_thumbnail_meta_box', 'post', 'side', 'low');
-add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core');
-add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', 'post', 'normal', 'core');
-add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'post', 'normal', 'core');
</del><ins>+if ( is_object_in_taxonomy($post_type, 'category') )
+        add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', $post_type, 'side', 'core');
+if ( current_theme_supports( 'post-thumbnails', $post_type ) )
+        add_meta_box('postimagediv', __('Post Thumbnail'), 'post_thumbnail_meta_box', $post_type, 'side', 'low');
+add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $post_type, 'normal', 'core');
+add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', $post_type, 'normal', 'core');
+add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', $post_type, 'normal', 'core');
</ins><span class="cx"> do_action('dbx_post_advanced');
</span><del>-add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'post', 'normal', 'core');
</del><ins>+add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', $post_type, 'normal', 'core');
</ins><span class="cx">
</span><span class="cx"> if ( 'publish' == $post->post_status || 'private' == $post->post_status )
</span><del>-        add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', 'post', 'normal', 'core');
</del><ins>+        add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core');
</ins><span class="cx">
</span><span class="cx"> if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) )
</span><del>-        add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'normal', 'core');
</del><ins>+        add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core');
</ins><span class="cx">
</span><span class="cx"> $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
</span><span class="cx"> if ( $post->post_author && !in_array($post->post_author, $authors) )
</span><span class="cx">         $authors[] = $post->post_author;
</span><span class="cx"> if ( $authors && count( $authors ) > 1 )
</span><del>-        add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'normal', 'core');
</del><ins>+        add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', $post_type, 'normal', 'core');
</ins><span class="cx">
</span><span class="cx"> if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) )
</span><del>-        add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'normal', 'core');
</del><ins>+        add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core');
</ins><span class="cx">
</span><del>-do_action('do_meta_boxes', 'post', 'normal', $post);
-do_action('do_meta_boxes', 'post', 'advanced', $post);
-do_action('do_meta_boxes', 'post', 'side', $post);
</del><ins>+do_action('do_meta_boxes', $post_type, 'normal', $post);
+do_action('do_meta_boxes', $post_type, 'advanced', $post);
+do_action('do_meta_boxes', $post_type, 'side', $post);
</ins><span class="cx">
</span><span class="cx"> require_once('admin-header.php');
</span><span class="cx">
</span><span class="lines">@@ -152,7 +153,7 @@
</span><span class="cx"> <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr($form_action) ?>" />
</span><span class="cx"> <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr($form_action) ?>" />
</span><span class="cx"> <input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
</span><del>-<input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post->post_type) ?>" />
</del><ins>+<input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post_type) ?>" />
</ins><span class="cx"> <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr($post->post_status) ?>" />
</span><span class="cx"> <input name="referredby" type="hidden" id="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" />
</span><span class="cx"> <?php
</span><span class="lines">@@ -166,7 +167,7 @@
</span><span class="cx">
</span><span class="cx"> <?php do_action('submitpost_box'); ?>
</span><span class="cx">
</span><del>-<?php $side_meta_boxes = do_meta_boxes('post', 'side', $post); ?>
</del><ins>+<?php $side_meta_boxes = do_meta_boxes($post_type, 'side', $post); ?>
</ins><span class="cx"> </div>
</span><span class="cx">
</span><span class="cx"> <div id="post-body">
</span><span class="lines">@@ -223,11 +224,11 @@
</span><span class="cx">
</span><span class="cx"> <?php
</span><span class="cx">
</span><del>-do_meta_boxes('post', 'normal', $post);
</del><ins>+do_meta_boxes($post_type, 'normal', $post);
</ins><span class="cx">
</span><span class="cx"> do_action('edit_form_advanced');
</span><span class="cx">
</span><del>-do_meta_boxes('post', 'advanced', $post);
</del><ins>+do_meta_boxes($post_type, 'advanced', $post);
</ins><span class="cx">
</span><span class="cx"> do_action('dbx_post_sidebar'); ?>
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminedittagsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-tags.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-tags.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-admin/edit-tags.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -19,9 +19,19 @@
</span><span class="cx"> if ( !is_taxonomy($taxonomy) )
</span><span class="cx">         wp_die(__('Invalid taxonomy'));
</span><span class="cx">
</span><del>-$parent_file = 'edit.php';
-$submenu_file = "edit-tags.php?taxonomy=$taxonomy";
</del><ins>+if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) )
+        $post_type = $_GET['post_type'];
+else
+        $post_type = 'post';
</ins><span class="cx">
</span><ins>+if ( 'post' != $post_type ) {
+        $parent_file = "edit.php?post_type=$post_type";
+        $submenu_file = "edit-tags.php?taxonomy=$taxonomy&post_type=$post_type";
+} else {
+        $parent_file = 'edit.php';
+        $submenu_file = "edit-tags.php?taxonomy=$taxonomy";        
+}
+
</ins><span class="cx"> if ( isset( $_GET['action'] ) && isset($_GET['delete_tags']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) )
</span><span class="cx">         $action = 'bulk-delete';
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadmineditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-admin/edit.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -20,17 +20,34 @@
</span><span class="cx">         unset( $_redirect );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) )
+        $post_type = $_GET['post_type'];
+else
+        $post_type = 'post';
+
+$post_type_object = get_post_type_object($post_type);
+
+if ( 'post' != $post_type ) {
+        $parent_file = "edit.php?post_type=$post_type";
+        $submenu_file = "edit.php?post_type=$post_type";
+        $post_new_file = "post-new.php?post_type=$post_type";
+} else {
+        $parent_file = 'edit.php';
+        $submenu_file = 'edit.php';
+        $post_new_file = 'post-new.php';
+}
+
</ins><span class="cx"> // Handle bulk actions
</span><span class="cx"> if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) {
</span><span class="cx">         check_admin_referer('bulk-posts');
</span><span class="cx">         $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
</span><span class="cx">
</span><span class="cx">         if ( strpos($sendback, 'post.php') !== false )
</span><del>-                $sendback = admin_url('post-new.php');
</del><ins>+                $sendback = admin_url($post_new_file);
</ins><span class="cx">
</span><span class="cx">         if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
</span><span class="cx">                 $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']);
</span><del>-                $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='post' AND post_status = %s", $post_status ) );
</del><ins>+                $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) );
</ins><span class="cx">                 $doaction = 'delete';
</span><span class="cx">         } elseif ( ( $_GET['action'] != -1 || $_GET['action2'] != -1 ) && ( isset($_GET['post']) || isset($_GET['ids']) ) ) {
</span><span class="cx">                 $post_ids = isset($_GET['post']) ? array_map( 'intval', (array) $_GET['post'] ) : explode(',', $_GET['ids']);
</span><span class="lines">@@ -107,14 +124,13 @@
</span><span class="cx">          exit;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-if ( empty($title) )
-        $title = __('Edit Posts');
-$parent_file = 'edit.php';
</del><ins>+$title = sprintf(__('Edit %s'), $post_type_object->label);
+
</ins><span class="cx"> wp_enqueue_script('inline-edit-post');
</span><span class="cx">
</span><span class="cx"> $user_posts = false;
</span><span class="cx"> if ( !current_user_can('edit_others_posts') ) {
</span><del>-        $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = 'post' AND post_status != 'trash' AND post_author = %d", $current_user->ID) );
</del><ins>+        $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) );
</ins><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="cx">                 $_GET['author'] = $current_user->ID;
</span><span class="lines">@@ -134,7 +150,7 @@
</span><span class="cx">
</span><span class="cx"> <div class="wrap">
</span><span class="cx"> <?php screen_icon(); ?>
</span><del>-<h2><?php echo esc_html( $title ); ?> <a href="post-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'post'); ?></a> <?php
</del><ins>+<h2><?php echo esc_html( $title ); ?> <a href="<?php echo $post_new_file ?>" class="button add-new-h2"><?php echo esc_html_x('Add New', 'post'); ?></a> <?php
</ins><span class="cx"> if ( isset($_GET['s']) && $_GET['s'] )
</span><span class="cx">         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( get_search_query() ) ); ?>
</span><span class="cx"> </h2>
</span><span class="lines">@@ -188,7 +204,7 @@
</span><span class="cx"> <?php
</span><span class="cx"> if ( empty($locked_post_status) ) :
</span><span class="cx"> $status_links = array();
</span><del>-$num_posts = wp_count_posts( 'post', 'readable' );
</del><ins>+$num_posts = wp_count_posts( $post_type, 'readable' );
</ins><span class="cx"> $class = '';
</span><span class="cx"> $allposts = '';
</span><span class="cx">
</span><span class="lines">@@ -215,7 +231,7 @@
</span><span class="cx">         if ( isset($_GET['post_status']) && $status == $_GET['post_status'] )
</span><span class="cx">                 $class = ' class="current"';
</span><span class="cx">
</span><del>-        $status_links[] = "<li><a href='edit.php?post_status=$status'$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>';
</del><ins>+        $status_links[] = "<li><a href='edit.php?post_status=$status&amp;post_type=$post_type'$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>';
</ins><span class="cx"> }
</span><span class="cx"> echo implode( " |</li>\n", $status_links ) . '</li>';
</span><span class="cx"> unset( $status_links );
</span><span class="lines">@@ -230,6 +246,7 @@
</span><span class="cx"> </p>
</span><span class="cx">
</span><span class="cx"> <input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_GET['post_status']) ? esc_attr($_GET['post_status']) : 'all'; ?>" />
</span><ins>+<input type="hidden" name="post_type" class="post_type_page" value="<?php echo $post_type; ?>" />
</ins><span class="cx"> <input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" />
</span><span class="cx">
</span><span class="cx"> <?php if ( have_posts() ) { ?>
</span><span class="lines">@@ -267,7 +284,7 @@
</span><span class="cx">
</span><span class="cx"> <?php // view filters
</span><span class="cx"> if ( !is_singular() ) {
</span><del>-$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC";
</del><ins>+$arc_query = $wpdb->prepare("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = %s ORDER BY post_date DESC", $post_type);
</ins><span class="cx">
</span><span class="cx"> $arc_result = $wpdb->get_results( $arc_query );
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminincludesmetaboxesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/meta-boxes.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/meta-boxes.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-admin/includes/meta-boxes.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -13,7 +13,9 @@
</span><span class="cx">         global $action;
</span><span class="cx">
</span><span class="cx">         $post_type = $post->post_type;
</span><del>-        $can_publish = current_user_can("publish_${post_type}s");
</del><ins>+ $post_type_object = get_post_type_object($post_type);
+        $type_cap = $post_type_object->capability_type;
+        $can_publish = current_user_can("publish_${type_cap}s");
</ins><span class="cx"> ?>
</span><span class="cx"> <div class="submitbox" id="submitpost">
</span><span class="cx">
</span><span class="lines">@@ -184,7 +186,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_${post_type}", $post->ID ) ) {
</del><ins>+if ( current_user_can( "delete_${type_cap}", $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></pre></div>
<a id="trunkwpadminincludespluginphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/plugin.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/plugin.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-admin/includes/plugin.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -745,14 +745,15 @@
</span><span class="cx">                         $parent = $_wp_real_parent_file[$parent];
</span><span class="cx">                 return $parent;
</span><span class="cx">         }
</span><del>-/*
</del><ins>+
+        /*
</ins><span class="cx">         if ( !empty ( $parent_file ) ) {
</span><span class="cx">                 if ( isset( $_wp_real_parent_file[$parent_file] ) )
</span><span class="cx">                         $parent_file = $_wp_real_parent_file[$parent_file];
</span><span class="cx">
</span><span class="cx">                 return $parent_file;
</span><span class="cx">         }
</span><del>-*/
</del><ins>+        */
</ins><span class="cx">
</span><span class="cx">         if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) {
</span><span class="cx">                 foreach ( (array)$menu as $parent_menu ) {
</span><span class="lines">@@ -782,7 +783,7 @@
</span><span class="cx">                 foreach ( $submenu[$parent] as $submenu_array ) {
</span><span class="cx">                         if ( isset( $_wp_real_parent_file[$parent] ) )
</span><span class="cx">                                 $parent = $_wp_real_parent_file[$parent];
</span><del>-                        if ( $submenu_array[2] == $pagenow ) {
</del><ins>+                        if ( $submenu_array[2] == $pagenow && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) {
</ins><span class="cx">                                 $parent_file = $parent;
</span><span class="cx">                                 return $parent;
</span><span class="cx">                         } else
</span></span></pre></div>
<a id="trunkwpadminincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/post.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/post.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-admin/includes/post.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -846,12 +846,17 @@
</span><span class="cx">                 $orderby = 'date';
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        $post_type_q = 'post_type=post';
+        if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types( array('_show' => true) ) ) )
+                $post_type_q = 'post_type=' . $q['post_type'];
+
+
</ins><span class="cx">         $posts_per_page = (int) get_user_option( 'edit_per_page', 0, false );
</span><span class="cx">         if ( empty( $posts_per_page ) || $posts_per_page < 1 )
</span><span class="cx">                 $posts_per_page = 15;
</span><span class="cx">         $posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page );
</span><span class="cx">
</span><del>-        wp("post_type=post&$post_status_q&posts_per_page=$posts_per_page&order=$order&orderby=$orderby");
</del><ins>+        wp("$post_type_q&$post_status_q&posts_per_page=$posts_per_page&order=$order&orderby=$orderby");
</ins><span class="cx">
</span><span class="cx">         return array($post_stati, $avail_post_stati);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadminincludestemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/template.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/template.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-admin/includes/template.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -3482,7 +3482,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function screen_meta($screen) {
</span><del>-        global $wp_meta_boxes, $_wp_contextual_help;
</del><ins>+        global $wp_meta_boxes, $_wp_contextual_help, $typenow;
</ins><span class="cx">
</span><span class="cx">         $screen = str_replace('.php', '', $screen);
</span><span class="cx">         $screen = str_replace('-new', '', $screen);
</span><span class="lines">@@ -3492,6 +3492,12 @@
</span><span class="cx">         $column_screens = get_column_headers($screen);
</span><span class="cx">         $meta_screens = array('index' => 'dashboard');
</span><span class="cx">
</span><ins>+        // Give post_type pages their own screen
+        if ( 'post' == $screen ) {
+                if ( !empty($typenow) )
+                        $screen = $typenow;
+        }
+
</ins><span class="cx">         if ( isset($meta_screens[$screen]) )
</span><span class="cx">                 $screen = $meta_screens[$screen];
</span><span class="cx">         $show_screen = false;
</span><span class="lines">@@ -3675,6 +3681,11 @@
</span><span class="cx">         global $screen_layout_columns;
</span><span class="cx">
</span><span class="cx">         $columns = array('dashboard' => 4, 'post' => 2, 'page' => 2, 'link' => 2);
</span><ins>+
+        // Add custom post types
+        foreach ( get_post_types( array('_show' => true) ) as $post_type )
+                $columns[$post_type] = 2;
+
</ins><span class="cx">         $columns = apply_filters('screen_layout_columns', $columns, $screen);
</span><span class="cx">
</span><span class="cx">         if ( !isset($columns[$screen]) ) {
</span><span class="lines">@@ -3754,8 +3765,12 @@
</span><span class="cx">         global $parent_file, $hook_suffix;
</span><span class="cx">
</span><span class="cx">         if ( empty($name) ) {
</span><del>-                if ( isset($parent_file) && !empty($parent_file) )
-                        $name = substr($parent_file, 0, -4);
</del><ins>+                if ( isset($parent_file) && !empty($parent_file) ) {
+                        $name = $parent_file;
+                        if ( false !== $pos = strpos($name, '?post_type=') )
+                                $name = substr($name, 0, $pos);
+                        $name = substr($name, 0, -4);
+                }
</ins><span class="cx">                 else
</span><span class="cx">                         $name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix);
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkwpadminjspostdevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/post.dev.js (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/post.dev.js        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-admin/js/post.dev.js        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -231,10 +231,14 @@
</span><span class="cx">         var catAddAfter, stamp, visibility, sticky = '', post = 'post' == pagenow || 'post-new' == pagenow, page = 'page' == pagenow || 'page-new' == pagenow;
</span><span class="cx">
</span><span class="cx">         // postboxes
</span><del>-        if ( post )
-                postboxes.add_postbox_toggles('post');
-        else if ( page )
</del><ins>+        if ( post ) {
+                type = 'post';
+                if ( typenow )
+                        type = typenow;
+                postboxes.add_postbox_toggles(type);
+        } else if ( page ) {
</ins><span class="cx">                 postboxes.add_postbox_toggles('page');
</span><ins>+        }
</ins><span class="cx">
</span><span class="cx">         // multi-taxonomies
</span><span class="cx">         if ( $('#tagsdiv-post_tag').length ) {
</span></span></pre></div>
<a id="trunkwpadminjspostjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/post.js (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/post.js        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-admin/js/post.js        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -1 +1 @@
</span><del>-var tagBox,commentsBox,editPermalink,makeSlugeditClickable,WPSetThumbnailHTML,WPSetThumbnailID,WPRemoveThumbnail;function array_unique_noempty(b){var c=[];jQuery.each(b,function(a,d){d=jQuery.trim(d);if(d&&jQuery.inArray(d,c)==-1){c.push(d)}});return c}(function(a){tagBox={clean:function(b){return b.replace(/\s*,\s*/g,",").replace(/,+/g,",").replace(/[,\s]+$/,"").replace(/^[,\s]+/,"")},parseTags:function(e){var h=e.id,b=h.split("-check-num-")[1],d=a(e).closest(".tagsdiv"),g=d.find(".the-tags"),c=g.val().split(","),f=[];delete c[b];a.each(c,function(i,j){j=a.trim(j);if(j){f.push(j)}});g.val(this.clean(f.join(",")));this.quickClicks(d);return false},quickClicks:function(c){var e=a(".the-tags",c),d=a(".tagchecklist",c),b;if(!e.length){return}b=e.val().split(",");d.empty();a.each(b,function(h,i){var f,g,j=a(c).attr("id");i=a.trim(i);if(!i.match(/^\s+$/)&&""!=i){g=j+"-check-num-"+h;f='<span><a id="'+g+'" class="ntdelbutton">X</a>&nbsp;'+i+"</span> ";d.append(f);a("#"+g).click(function(){tagBox.parseTags(this)})}})},flushTags:function(e,b,g){b=b||false;var i,c=a(".the-tags",e),h=a("input.newtag",e),d;i=b?a(b).text():h.val();tagsval=c.val();d=tagsval?tagsval+","+i:i;d=this.clean(d);d=array_unique_noempty(d.split(",")).join(",");c.val(d);this.quickClicks(e);if(!b){h.val("")}if("undefined"==typeof(g)){h.focus()}return false},get:function(c){var b=c.substr(c.indexOf("-")+1);a.post(ajaxurl,{action:"get-tagcloud",tax:b},function(e,d){if(0==e||"success"!=d){e=wpAjax.broken}e=a('<p id="tagcloud-'+b+'" class="the-tagcloud">'+e+"</p>");a("a",e).click(function(){tagBox.flushTags(a(this).closest(".inside").children(".tagsdiv"),this);return false});a("#"+c).after(e)})},init:function(){var b=this,c=a("div.ajaxtag");a(".tagsdiv").each(function(){tagBox.quickClicks(this)});a("input.tagadd",c).click(function(){b.flushTags(a(this).closest(".tagsdiv"))});a("div.taghint",c).click(function(){a(this).css("visibility","hidden").siblings(".newtag").focus()});a("input.newtag",c).blur(function(){if(this.value==""){a(this).siblings(".taghint").css("visibility","")}}).focus(function(){a(this).siblings(".taghint").css("visibility","hidden")}).keyup(function(d){if(13==d.which){tagBox.flushTags(a(this).closest(".tagsdiv"));return false}}).keypress(function(d){if(13==d.which){d.preventDefault();return false}}).each(function(){var d=a(this).closest("div.tagsdiv").attr("id");a(this).suggest(ajaxurl+"?action=ajax-tag-search&tax="+d,{delay:500,minchars:2,multiple:true,multipleSep:", "})});a("#post").submit(function(){a("div.tagsdiv").each(function(){tagBox.flushTags(this,false,1)})});a("a.tagcloud-link").click(function(){tagBox.get(a(this).attr("id"));a(this).unbind().click(function(){a(this).siblings(".the-tagcloud").toggle();return false});return false})}};commentsBox={st:0,get:function(d,c){var b=this.st,e;if(!c){c=20}this.st+=c;this.total=d;a("#commentsdiv img.waiting").show();e={action:"get-comments",mode:"single",_ajax_nonce:a("#add_comment_nonce").val(),post_ID:a("#post_ID").val(),start:b,num:c};a.post(ajaxurl,e,function(f){f=wpAjax.parseAjaxResponse(f);a("#commentsdiv .widefat").show();a("#commentsdiv img.waiting").hide();if("object"==typeof f&&f.responses[0]){a("#the-comment-list").append(f.responses[0].data);theList=theExtraList=null;a("a[className*=':']").unbind();setCommentsList();if(commentsBox.st>commentsBox.total){a("#show-comments").hide()}else{a("#show-comments").html(postL10n.showcomm)}return}else{if(1==f){a("#show-comments").parent().html(postL10n.endcomm);return}}a("#the-comment-list").append('<tr><td colspan="2">'+wpAjax.broken+"</td></tr>")});return false}};WPSetThumbnailHTML=function(b){a(".inside","#postimagediv").html(b)};WPSetThumbnailID=function(c){var b=a("input[value=_thumbnail_id]","#list-table");if(b.size()>0){a("#meta\\["+b.attr("id").match(/[0-9]+/)+"\\]\\[value\\]").text(c)}};WPRemoveThumbnail=function(){a.post(ajaxurl,{action:"set-post-thumbnail",post_id:a("#post_ID").val(),thumbnail_id:-1,cookie:encodeURIComponent(document.cookie)},function(b){if(b=="0"){alert(setPostThumbnailL10n.error)}else{WPSetThumbnailHTML(b)}})}})(jQuery);jQuery(document).ready(function(f){var d,a,b,h="",i="post"==pagenow||"post-new"==pagenow,g="page"==pagenow||"page-new"==pagenow;if(i){postboxes.add_postbox_toggles("post")}else{if(g){postboxes.add_postbox_toggles("page")}}if(f("#tagsdiv-post_tag").length){tagBox.init()}else{f("#side-sortables, #normal-sortables, #advanced-sortables").children("div.postbox").each(function(){if(this.id.indexOf("tagsdiv-")===0){tagBox.init();return false}})}if(f("#categorydiv").length){f("a","#category-tabs").click(function(){var j=f(this).attr("href");f(this).parent().addClass("tabs").siblings("li").removeClass("tabs");f("#category-tabs").siblings(".tabs-panel").hide();f(j).show();if("#categories-all"==j){deleteUserSetting("cats")}else{setUserSetting("cats","pop")}return false});if(getUserSetting("cats")){f('a[href="#categories-pop"]',"#category-tabs").click()}f("#newcat").one("focus",function(){f(this).val("").removeClass("form-input-tip")});f("#category-add-sumbit").click(function(){f("#newcat").focus()});catAddBefore=function(j){if(!f("#newcat").val()){return false}j.data+="&"+f(":checked","#categorychecklist").serialize();return j};d=function(m,l){var k,j=f("#newcat_parent");if("undefined"!=l.parsed.responses[0]&&(k=l.parsed.responses[0].supplemental.newcat_parent)){j.before(k);j.remove()}};f("#categorychecklist").wpList({alt:"",response:"category-ajax-response",addBefore:catAddBefore,addAfter:d});f("#category-add-toggle").click(function(){f("#category-adder").toggleClass("wp-hidden-children");f('a[href="#categories-all"]',"#category-tabs").click();return false});f("#categorychecklist").children("li.popular-category").add(f("#categorychecklist-pop").children()).find(":checkbox").live("click",function(){var j=f(this),l=j.is(":checked"),k=j.val();f("#in-category-"+k+", #in-popular-category-"+k).attr("checked",l)})}if(f("#postcustom").length){f("#the-list").wpList({addAfter:function(j,k){f("table#list-table").show();if(typeof(autosave_update_post_ID)!="undefined"){autosave_update_post_ID(k.parsed.responses[0].supplemental.postid)}},addBefore:function(j){j.data+="&post_id="+f("#post_ID").val();return j}})}if(f("#submitdiv").length){a=f("#timestamp").html();b=f("#post-visibility-display").html();function e(){var j=f("#post-visibility-select");if(f("input:radio:checked",j).val()!="public"){f("#sticky").attr("checked",false);f("#sticky-span").hide()}else{f("#sticky-span").show()}if(f("input:radio:checked",j).val()!="password"){f("#password-span").hide()}else{f("#password-span").show()}}function c(){var q,r,k,t,s=f("#post_status"),l=f("option[value=publish]",s),j=f("#aa").val(),o=f("#mm").val(),p=f("#jj").val(),n=f("#hh").val(),m=f("#mn").val();q=new Date(j,o-1,p,n,m);r=new Date(f("#hidden_aa").val(),f("#hidden_mm").val()-1,f("#hidden_jj").val(),f("#hidden_hh").val(),f("#hidden_mn").val());k=new Date(f("#cur_aa").val(),f("#cur_mm").val()-1,f("#cur_jj").val(),f("#cur_hh").val(),f("#cur_mn").val());if(q.getFullYear()!=j||(1+q.getMonth())!=o||q.getDate()!=p||q.getMinutes()!=m){f(".timestamp-wrap","#timestampdiv").addClass("form-invalid");return false}else{f(".timestamp-wrap","#timestampdiv").removeClass("form-invalid")}if(q>k&&f("#original_post_status").val()!="future"){t=postL10n.publishOnFuture;f("#publish").val(postL10n.schedule)}else{if(q<=k&&f("#original_post_status").val()!="publish"){t=postL10n.publishOn;f("#publish").val(postL10n.publish)}else{t=postL10n.publishOnPast;if(g){f("#publish").val(postL10n.updatePage)}else{f("#publish").val(postL10n.updatePost)}}}if(r.toUTCString()==q.toUTCString()){f("#timestamp").html(a)}else{f("#timestamp").html(t+" <b>"+f("option[value="+f("#mm").val()+"]","#mm").text()+" "+p+", "+j+" @ "+n+":"+m+"</b> ")}if(f("input:radio:checked","#post-visibility-select").val()=="private"){if(g){f("#publish").val(postL10n.updatePage)}else{f("#publish").val(postL10n.updatePost)}if(l.length==0){s.append('<option value="publish">'+postL10n.privatelyPublished+"</option>")}else{l.html(postL10n.privatelyPublished)}f("option[value=publish]",s).attr("selected",true);f(".edit-post-status","#misc-publishing-actions").hide()}else{if(f("#original_post_status").val()=="future"||f("#original_post_status").val()=="draft"){if(l.length){l.remove();s.val(f("#hidden_post_status").val())}}else{l.html(postL10n.published)}if(s.is(":hidden")){f(".edit-post-status","#misc-publishing-actions").show()}}f("#post-status-display").html(f("option:selected",s).text());if(f("option:selected",s).val()=="private"||f("option:selected",s).val()=="publish"){f("#save-post").hide()}else{f("#save-post").show();if(f("option:selected",s).val()=="pending"){f("#save-post").show().val(postL10n.savePending)}else{f("#save-post").show().val(postL10n.saveDraft)}}return true}f(".edit-visibility","#visibility").click(function(){if(f("#post-visibility-select").is(":hidden")){e();f("#post-visibility-select").slideDown("normal");f(this).hide()}return false});f(".cancel-post-visibility","#post-visibility-select").click(function(){f("#post-visibility-select").slideUp("normal");f("#visibility-radio-"+f("#hidden-post-visibility").val()).attr("checked",true);f("#post_password").val(f("#hidden_post_password").val());f("#sticky").attr("checked",f("#hidden-post-sticky").attr("checked"));f("#post-visibility-display").html(b);f(".edit-visibility","#visibility").show();c();return false});f(".save-post-visibility","#post-visibility-select").click(function(){var j=f("#post-visibility-select");j.slideUp("normal");f(".edit-visibility","#visibility").show();c();if(f("input:radio:checked",j).val()!="public"){f("#sticky").attr("checked",false)}if(true==f("#sticky").attr("checked")){h="Sticky"}else{h=""}f("#post-visibility-display").html(postL10n[f("input:radio:checked",j).val()+h]);return false});f("input:radio","#post-visibility-select").change(function(){e()});f("#timestampdiv").siblings("a.edit-timestamp").click(function(){if(f("#timestampdiv").is(":hidden")){f("#timestampdiv").slideDown("normal");f(this).hide()}return false});f(".cancel-timestamp","#timestampdiv").click(function(){f("#timestampdiv").slideUp("normal");f("#mm").val(f("#hidden_mm").val());f("#jj").val(f("#hidden_jj").val());f("#aa").val(f("#hidden_aa").val());f("#hh").val(f("#hidden_hh").val());f("#mn").val(f("#hidden_mn").val());f("#timestampdiv").siblings("a.edit-timestamp").show();c();return false});f(".save-timestamp","#timestampdiv").click(function(){if(c()){f("#timestampdiv").slideUp("normal");f("#timestampdiv").siblings("a.edit-timestamp").show()}return false});f("#post-status-select").siblings("a.edit-post-status").click(function(){if(f("#post-status-select").is(":hidden")){f("#post-status-select").slideDown("normal");f(this).hide()}return false});f(".save-post-status","#post-status-select").click(function(){f("#post-status-select").slideUp("normal");f("#post-status-select").siblings("a.edit-post-status").show();c();return false});f(".cancel-post-status","#post-status-select").click(function(){f("#post-status-select").slideUp("normal");f("#post_status").val(f("#hidden_post_status").val());f("#post-status-select").siblings("a.edit-post-status").show();c();return false})}if(f("#edit-slug-box").length){editPermalink=function(j){var k,n=0,m=f("#editable-post-name"),o=m.html(),r=f("#post_name"),s=r.html(),p=f("#edit-slug-buttons"),q=p.html(),l=f("#editable-post-name-full").html();f("#view-post-btn").hide();p.html('<a href="#" class="save button">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+"</a>");p.children(".save").click(function(){var t=m.children("input").val();f.post(ajaxurl,{action:"sample-permalink",post_id:j,new_slug:t,new_title:f("#title").val(),samplepermalinknonce:f("#samplepermalinknonce").val()},function(u){f("#edit-slug-box").html(u);p.html(q);r.attr("value",t);makeSlugeditClickable();f("#view-post-btn").show()});return false});f(".cancel","#edit-slug-buttons").click(function(){f("#view-post-btn").show();m.html(o);p.html(q);r.attr("value",s);return false});for(k=0;k<l.length;++k){if("%"==l.charAt(k)){n++}}slug_value=(n>l.length/4)?"":l;m.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children("input").keypress(function(u){var t=u.keyCode||0;if(13==t){p.children(".save").click();return false}if(27==t){p.children(".cancel").click();return false}r.attr("value",this.value)}).focus()};makeSlugeditClickable=function(){f("#editable-post-name").click(function(){f("#edit-slug-buttons").children(".edit-slug").click()})};makeSlugeditClickable()}});
</del><span class="cx">\ No newline at end of file
</span><ins>+var tagBox,commentsBox,editPermalink,makeSlugeditClickable,WPSetThumbnailHTML,WPSetThumbnailID,WPRemoveThumbnail;function array_unique_noempty(b){var c=[];jQuery.each(b,function(a,d){d=jQuery.trim(d);if(d&&jQuery.inArray(d,c)==-1){c.push(d)}});return c}(function(a){tagBox={clean:function(b){return b.replace(/\s*,\s*/g,",").replace(/,+/g,",").replace(/[,\s]+$/,"").replace(/^[,\s]+/,"")},parseTags:function(e){var h=e.id,b=h.split("-check-num-")[1],d=a(e).closest(".tagsdiv"),g=d.find(".the-tags"),c=g.val().split(","),f=[];delete c[b];a.each(c,function(i,j){j=a.trim(j);if(j){f.push(j)}});g.val(this.clean(f.join(",")));this.quickClicks(d);return false},quickClicks:function(c){var e=a(".the-tags",c),d=a(".tagchecklist",c),b;if(!e.length){return}b=e.val().split(",");d.empty();a.each(b,function(h,i){var f,g,j=a(c).attr("id");i=a.trim(i);if(!i.match(/^\s+$/)&&""!=i){g=j+"-check-num-"+h;f='<span><a id="'+g+'" class="ntdelbutton">X</a>&nbsp;'+i+"</span> ";d.append(f);a("#"+g).click(function(){tagBox.parseTags(this)})}})},flushTags:function(e,b,g){b=b||false;var i,c=a(".the-tags",e),h=a("input.newtag",e),d;i=b?a(b).text():h.val();tagsval=c.val();d=tagsval?tagsval+","+i:i;d=this.clean(d);d=array_unique_noempty(d.split(",")).join(",");c.val(d);this.quickClicks(e);if(!b){h.val("")}if("undefined"==typeof(g)){h.focus()}return false},get:function(c){var b=c.substr(c.indexOf("-")+1);a.post(ajaxurl,{action:"get-tagcloud",tax:b},function(e,d){if(0==e||"success"!=d){e=wpAjax.broken}e=a('<p id="tagcloud-'+b+'" class="the-tagcloud">'+e+"</p>");a("a",e).click(function(){tagBox.flushTags(a(this).closest(".inside").children(".tagsdiv"),this);return false});a("#"+c).after(e)})},init:function(){var b=this,c=a("div.ajaxtag");a(".tagsdiv").each(function(){tagBox.quickClicks(this)});a("input.tagadd",c).click(function(){b.flushTags(a(this).closest(".tagsdiv"))});a("div.taghint",c).click(function(){a(this).css("visibility","hidden").siblings(".newtag").focus()});a("input.newtag",c).blur(function(){if(this.value==""){a(this).siblings(".taghint").css("visibility","")}}).focus(function(){a(this).siblings(".taghint").css("visibility","hidden")}).keyup(function(d){if(13==d.which){tagBox.flushTags(a(this).closest(".tagsdiv"));return false}}).keypress(function(d){if(13==d.which){d.preventDefault();return false}}).each(function(){var d=a(this).closest("div.tagsdiv").attr("id");a(this).suggest(ajaxurl+"?action=ajax-tag-search&tax="+d,{delay:500,minchars:2,multiple:true,multipleSep:", "})});a("#post").submit(function(){a("div.tagsdiv").each(function(){tagBox.flushTags(this,false,1)})});a("a.tagcloud-link").click(function(){tagBox.get(a(this).attr("id"));a(this).unbind().click(function(){a(this).siblings(".the-tagcloud").toggle();return false});return false})}};commentsBox={st:0,get:function(d,c){var b=this.st,e;if(!c){c=20}this.st+=c;this.total=d;a("#commentsdiv img.waiting").show();e={action:"get-comments",mode:"single",_ajax_nonce:a("#add_comment_nonce").val(),post_ID:a("#post_ID").val(),start:b,num:c};a.post(ajaxurl,e,function(f){f=wpAjax.parseAjaxResponse(f);a("#commentsdiv .widefat").show();a("#commentsdiv img.waiting").hide();if("object"==typeof f&&f.responses[0]){a("#the-comment-list").append(f.responses[0].data);theList=theExtraList=null;a("a[className*=':']").unbind();setCommentsList();if(commentsBox.st>commentsBox.total){a("#show-comments").hide()}else{a("#show-comments").html(postL10n.showcomm)}return}else{if(1==f){a("#show-comments").parent().html(postL10n.endcomm);return}}a("#the-comment-list").append('<tr><td colspan="2">'+wpAjax.broken+"</td></tr>")});return false}};WPSetThumbnailHTML=function(b){a(".inside","#postimagediv").html(b)};WPSetThumbnailID=function(c){var b=a("input[value=_thumbnail_id]","#list-table");if(b.size()>0){a("#meta\\["+b.attr("id").match(/[0-9]+/)+"\\]\\[value\\]").text(c)}};WPRemoveThumbnail=function(){a.post(ajaxurl,{action:"set-post-thumbnail",post_id:a("#post_ID").val(),thumbnail_id:-1,cookie:encodeURIComponent(document.cookie)},function(b){if(b=="0"){alert(setPostThumbnailL10n.error)}else{WPSetThumbnailHTML(b)}})}})(jQuery);jQuery(document).ready(function(f){var d,a,b,h="",i="post"==pagenow||"post-new"==pagenow,g="page"==pagenow||"page-new"==pagenow;if(i){type="post";if(typenow){type=typenow}postboxes.add_postbox_toggles(type)}else{if(g){postboxes.add_postbox_toggles("page")}}if(f("#tagsdiv-post_tag").length){tagBox.init()}else{f("#side-sortables, #normal-sortables, #advanced-sortables").children("div.postbox").each(function(){if(this.id.indexOf("tagsdiv-")===0){tagBox.init();return false}})}if(f("#categorydiv").length){f("a","#category-tabs").click(function(){var j=f(this).attr("href");f(this).parent().addClass("tabs").siblings("li").removeClass("tabs");f("#category-tabs").siblings(".tabs-panel").hide();f(j).show();if("#categories-all"==j){deleteUserSetting("cats")}else{setUserSetting("cats","pop")}return false});if(getUserSetting("cats")){f('a[href="#categories-pop"]',"#category-tabs").click()}f("#newcat").one("focus",function(){f(this).val("").removeClass("form-input-tip")});f("#category-add-sumbit").click(function(){f("#newcat").focus()});catAddBefore=function(j){if(!f("#newcat").val()){return false}j.data+="&"+f(":checked","#categorychecklist").serialize();return j};d=function(m,l){var k,j=f("#newcat_parent");if("undefined"!=l.parsed.responses[0]&&(k=l.parsed.responses[0].supplemental.newcat_parent)){j.before(k);j.remove()}};f("#categorychecklist").wpList({alt:"",response:"category-ajax-response",addBefore:catAddBefore,addAfter:d});f("#category-add-toggle").click(function(){f("#category-adder").toggleClass("wp-hidden-children");f('a[href="#categories-all"]',"#category-tabs").click();return false});f("#categorychecklist").children("li.popular-category").add(f("#categorychecklist-pop").children()).find(":checkbox").live("click",function(){var j=f(this),l=j.is(":checked"),k=j.val();f("#in-category-"+k+", #in-popular-category-"+k).attr("checked",l)})}if(f("#postcustom").length){f("#the-list").wpList({addAfter:function(j,k){f("table#list-table").show();if(typeof(autosave_update_post_ID)!="undefined"){autosave_update_post_ID(k.parsed.responses[0].supplemental.postid)}},addBefore:function(j){j.data+="&post_id="+f("#post_ID").val();return j}})}if(f("#submitdiv").length){a=f("#timestamp").html();b=f("#post-visibility-display").html();function e(){var j=f("#post-visibility-select");if(f("input:radio:checked",j).val()!="public"){f("#sticky").attr("checked",false);f("#sticky-span").hide()}else{f("#sticky-span").show()}if(f("input:radio:checked",j).val()!="password"){f("#password-span").hide()}else{f("#password-span").show()}}function c(){var q,r,k,t,s=f("#post_status"),l=f("option[value=publish]",s),j=f("#aa").val(),o=f("#mm").val(),p=f("#jj").val(),n=f("#hh").val(),m=f("#mn").val();q=new Date(j,o-1,p,n,m);r=new Date(f("#hidden_aa").val(),f("#hidden_mm").val()-1,f("#hidden_jj").val(),f("#hidden_hh").val(),f("#hidden_mn").val());k=new Date(f("#cur_aa").val(),f("#cur_mm").val()-1,f("#cur_jj").val(),f("#cur_hh").val(),f("#cur_mn").val());if(q.getFullYear()!=j||(1+q.getMonth())!=o||q.getDate()!=p||q.getMinutes()!=m){f(".timestamp-wrap","#timestampdiv").addClass("form-invalid");return false}else{f(".timestamp-wrap","#timestampdiv").removeClass("form-invalid")}if(q>k&&f("#original_post_status").val()!="future"){t=postL10n.publishOnFuture;f("#publish").val(postL10n.schedule)}else{if(q<=k&&f("#original_post_status").val()!="publish"){t=postL10n.publishOn;f("#publish").val(postL10n.publish)}else{t=postL10n.publishOnPast;if(g){f("#publish").val(postL10n.updatePage)}else{f("#publish").val(postL10n.updatePost)}}}if(r.toUTCString()==q.toUTCString()){f("#timestamp").html(a)}else{f("#timestamp").html(t+" <b>"+f("option[value="+f("#mm").val()+"]","#mm").text()+" "+p+", "+j+" @ "+n+":"+m+"</b> ")}if(f("input:radio:checked","#post-visibility-select").val()=="private"){if(g){f("#publish").val(postL10n.updatePage)}else{f("#publish").val(postL10n.updatePost)}if(l.length==0){s.append('<option value="publish">'+postL10n.privatelyPublished+"</option>")}else{l.html(postL10n.privatelyPublished)}f("option[value=publish]",s).attr("selected",true);f(".edit-post-status","#misc-publishing-actions").hide()}else{if(f("#original_post_status").val()=="future"||f("#original_post_status").val()=="draft"){if(l.length){l.remove();s.val(f("#hidden_post_status").val())}}else{l.html(postL10n.published)}if(s.is(":hidden")){f(".edit-post-status","#misc-publishing-actions").show()}}f("#post-status-display").html(f("option:selected",s).text());if(f("option:selected",s).val()=="private"||f("option:selected",s).val()=="publish"){f("#save-post").hide()}else{f("#save-post").show();if(f("option:selected",s).val()=="pending"){f("#save-post").show().val(postL10n.savePending)}else{f("#save-post").show().val(postL10n.saveDraft)}}return true}f(".edit-visibility","#visibility").click(function(){if(f("#post-visibility-select").is(":hidden")){e();f("#post-visibility-select").slideDown("normal");f(this).hide()}return false});f(".cancel-post-visibility","#post-visibility-select").click(function(){f("#post-visibility-select").slideUp("normal");f("#visibility-radio-"+f("#hidden-post-visibility").val()).attr("checked",true);f("#post_password").val(f("#hidden_post_password").val());f("#sticky").attr("checked",f("#hidden-post-sticky").attr("checked"));f("#post-visibility-display").html(b);f(".edit-visibility","#visibility").show();c();return false});f(".save-post-visibility","#post-visibility-select").click(function(){var j=f("#post-visibility-select");j.slideUp("normal");f(".edit-visibility","#visibility").show();c();if(f("input:radio:checked",j).val()!="public"){f("#sticky").attr("checked",false)}if(true==f("#sticky").attr("checked")){h="Sticky"}else{h=""}f("#post-visibility-display").html(postL10n[f("input:radio:checked",j).val()+h]);return false});f("input:radio","#post-visibility-select").change(function(){e()});f("#timestampdiv").siblings("a.edit-timestamp").click(function(){if(f("#timestampdiv").is(":hidden")){f("#timestampdiv").slideDown("normal");f(this).hide()}return false});f(".cancel-timestamp","#timestampdiv").click(function(){f("#timestampdiv").slideUp("normal");f("#mm").val(f("#hidden_mm").val());f("#jj").val(f("#hidden_jj").val());f("#aa").val(f("#hidden_aa").val());f("#hh").val(f("#hidden_hh").val());f("#mn").val(f("#hidden_mn").val());f("#timestampdiv").siblings("a.edit-timestamp").show();c();return false});f(".save-timestamp","#timestampdiv").click(function(){if(c()){f("#timestampdiv").slideUp("normal");f("#timestampdiv").siblings("a.edit-timestamp").show()}return false});f("#post-status-select").siblings("a.edit-post-status").click(function(){if(f("#post-status-select").is(":hidden")){f("#post-status-select").slideDown("normal");f(this).hide()}return false});f(".save-post-status","#post-status-select").click(function(){f("#post-status-select").slideUp("normal");f("#post-status-select").siblings("a.edit-post-status").show();c();return false});f(".cancel-post-status","#post-status-select").click(function(){f("#post-status-select").slideUp("normal");f("#post_status").val(f("#hidden_post_status").val());f("#post-status-select").siblings("a.edit-post-status").show();c();return false})}if(f("#edit-slug-box").length){editPermalink=function(j){var k,n=0,m=f("#editable-post-name"),o=m.html(),r=f("#post_name"),s=r.html(),p=f("#edit-slug-buttons"),q=p.html(),l=f("#editable-post-name-full").html();f("#view-post-btn").hide();p.html('<a href="#" class="save button">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+"</a>");p.children(".save").click(function(){var t=m.children("input").val();f.post(ajaxurl,{action:"sample-permalink",post_id:j,new_slug:t,new_title:f("#title").val(),samplepermalinknonce:f("#samplepermalinknonce").val()},function(u){f("#edit-slug-box").html(u);p.html(q);r.attr("value",t);makeSlugeditClickable();f("#view-post-btn").show()});return false});f(".cancel","#edit-slug-buttons").click(function(){f("#view-post-btn").show();m.html(o);p.html(q);r.attr("value",s);return false});for(k=0;k<l.length;++k){if("%"==l.charAt(k)){n++}}slug_value=(n>l.length/4)?"":l;m.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children("input").keypress(function(u){var t=u.keyCode||0;if(13==t){p.children(".save").click();return false}if(27==t){p.children(".cancel").click();return false}r.attr("value",this.value)}).focus()};makeSlugeditClickable=function(){f("#editable-post-name").click(function(){f("#edit-slug-buttons").children(".edit-slug").click()})};makeSlugeditClickable()}});
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadminmenuheaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/menu-header.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/menu-header.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-admin/menu-header.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx">                 if ( !empty($submenu[$item[2]]) )
</span><span class="cx">                         $class[] = 'wp-has-submenu';
</span><span class="cx">
</span><del>-                if ( ( $parent_file && $item[2] == $parent_file ) || strcmp($self, $item[2]) == 0 ) {
</del><ins>+                if ( ( $parent_file && $item[2] == $parent_file ) || ( false === strpos($parent_file, '?') && strcmp($self, $item[2]) == 0 ) ) {
</ins><span class="cx">                         if ( !empty($submenu[$item[2]]) )
</span><span class="cx">                                 $class[] = 'wp-has-current-submenu wp-menu-open';
</span><span class="cx">                         else
</span></span></pre></div>
<a id="trunkwpadminmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/menu.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/menu.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-admin/menu.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -65,6 +65,25 @@
</span><span class="cx">
</span><span class="cx"> $_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group
</span><span class="cx">
</span><ins>+foreach ( (array) get_post_types( array('_show' => true) ) as $ptype ) {
+        $_wp_last_object_menu++;
+        $ptype_obj = get_post_type_object($ptype);
+        $menu[$_wp_last_object_menu] = array(esc_attr($ptype_obj->label), 'edit_' . $ptype_obj->capability_type . 's', "edit.php?post_type=$ptype", '', 'menu-top', 'menu-posts', 'div');
+        $submenu["edit.php?post_type=$ptype"][5] = array( __('Edit'), 'edit_posts', "edit.php?post_type=$ptype");
+        /* translators: add new custom post type */
+        $submenu["edit.php?post_type=$ptype"][10] = array( _x('Add New', 'post'), 'edit_posts', "post-new.php?post_type=$ptype" );
+
+        $i = 15;
+        foreach ( $wp_taxonomies as $tax ) {
+                if ( $tax->hierarchical || ! in_array($ptype, (array) $tax->object_type, true) )
+                        continue;
+
+                $submenu["edit.php?post_type=$ptype"][$i] = array( esc_attr($tax->label), 'manage_categories', "edit-tags.php?taxonomy=$tax->name&amp;post_type=$ptype" );
+                ++$i;
+        }
+}
+unset($ptype, $ptype_obj);
+
</ins><span class="cx"> $menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' );
</span><span class="cx">
</span><span class="cx"> $menu[60] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-top', 'menu-appearance', 'div' );
</span></span></pre></div>
<a id="trunkwpadminpostnewphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/post-new.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/post-new.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-admin/post-new.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -8,8 +8,24 @@
</span><span class="cx">
</span><span class="cx"> /** Load WordPress Administration Bootstrap */
</span><span class="cx"> require_once('admin.php');
</span><del>-$title = __('Add New Post');
-$parent_file = 'edit.php';
</del><ins>+
+if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) )
+        $post_type = $_GET['post_type'];
+else
+        $post_type = 'post';
+
+if ( 'post' != $post_type ) {
+        $parent_file = "edit.php?post_type=$post_type";
+        $submenu_file = "post-new.php?post_type=$post_type";
+} else {
+        $parent_file = 'edit.php';
+        $submenu_file = 'post-new.php';
+}
+
+$post_type_object = get_post_type_object($post_type);
+
+$title = sprintf(__('Add New %s'), $post_type_object->label);
+
</ins><span class="cx"> $editing = true;
</span><span class="cx"> wp_enqueue_script('autosave');
</span><span class="cx"> wp_enqueue_script('post');
</span><span class="lines">@@ -34,6 +50,7 @@
</span><span class="cx">
</span><span class="cx"> // Show post form.
</span><span class="cx"> $post = get_default_post_to_edit();
</span><ins>+$post->post_type = $post_type;
</ins><span class="cx"> include('edit-form-advanced.php');
</span><span class="cx">
</span><span class="cx"> include('admin-footer.php');
</span></span></pre></div>
<a id="trunkwpadminpostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/post.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/post.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-admin/post.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -126,6 +126,7 @@
</span><span class="cx">         }
</span><span class="cx">         $post_ID = $p = (int) $_GET['post'];
</span><span class="cx">         $post = get_post($post_ID);
</span><ins>+        $post_type_object = get_post_type_object($post->post_type);
</ins><span class="cx">
</span><span class="cx">         if ( empty($post->ID) )
</span><span class="cx">                 wp_die( __('You attempted to edit a post that doesn&#8217;t exist. Perhaps it was deleted?') );
</span><span class="lines">@@ -136,11 +137,20 @@
</span><span class="cx">         if ( 'trash' == $post->post_status )
</span><span class="cx">                 wp_die( __('You can&#8217;t edit this post because it is in the Trash. Please restore it and try again.') );
</span><span class="cx">
</span><del>-        if ( 'post' != $post->post_type ) {
</del><ins>+        if ( null == $post_type_object )
+                wp_die( __('Unknown post type.') );
+
+        if ( 'post' != $post->post_type && $post_type_object->_builtin ) {
</ins><span class="cx">                 wp_redirect( get_edit_post_link( $post->ID, 'url' ) );
</span><span class="cx">                 exit();
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        $post_type = $post->post_type;
+        if ( 'post' != $post_type ) {
+                $parent_file = "edit.php?post_type=$post_type";
+                $submenu_file = "edit.php?post_type=$post_type";
+        }
+
</ins><span class="cx">         wp_enqueue_script('post');
</span><span class="cx">         if ( user_can_richedit() )
</span><span class="cx">                 wp_enqueue_script('editor');
</span><span class="lines">@@ -157,7 +167,7 @@
</span><span class="cx">                 wp_enqueue_script('autosave');
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        $title = __('Edit Post');
</del><ins>+        $title = sprintf(__('Edit %s'), $post_type_object->label);
</ins><span class="cx">         $post = get_post_to_edit($post_ID);
</span><span class="cx">
</span><span class="cx">         include('edit-form-advanced.php');
</span></span></pre></div>
<a id="trunkwpincludescapabilitiesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/capabilities.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/capabilities.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-includes/capabilities.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -779,8 +779,9 @@
</span><span class="cx">                 $author_data = get_userdata( $user_id );
</span><span class="cx">                 //echo "post ID: {$args[0]}<br />";
</span><span class="cx">                 $post = get_post( $args[0] );
</span><del>-                if ( 'page' == $post->post_type ) {
-                        $args = array_merge( array( 'delete_page', $user_id ), $args );
</del><ins>+                $post_type = get_post_type_object( $post->post_type );
+                if ( $post_type && 'post' != $post_type->capability_type ) {
+                        $args = array_merge( array( 'delete_' . $post_type->capability_type, $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">@@ -855,8 +856,9 @@
</span><span class="cx">                 $author_data = get_userdata( $user_id );
</span><span class="cx">                 //echo "post ID: {$args[0]}<br />";
</span><span class="cx">                 $post = get_post( $args[0] );
</span><del>-                if ( 'page' == $post->post_type ) {
-                        $args = array_merge( array( 'edit_page', $user_id ), $args );
</del><ins>+                $post_type = get_post_type_object( $post->post_type );
+                if ( $post_type && 'post' != $post_type->capability_type ) {
+                        $args = array_merge( array( 'edit_' . $post_type->capability_type, $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">@@ -913,8 +915,9 @@
</span><span class="cx">                 break;
</span><span class="cx">         case 'read_post':
</span><span class="cx">                 $post = get_post( $args[0] );
</span><del>-                if ( 'page' == $post->post_type ) {
-                        $args = array_merge( array( 'read_page', $user_id ), $args );
</del><ins>+                $post_type = get_post_type_object( $post->post_type );
+                if ( $post_type && 'post' != $post_type->capability_type ) {
+                        $args = array_merge( array( 'read_' . $post_type->capability_type, $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>
<a id="trunkwpincludeslinktemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/link-template.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/link-template.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-includes/link-template.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -678,39 +678,18 @@
</span><span class="cx">                 return;
</span><span class="cx">
</span><span class="cx">         if ( 'display' == $context )
</span><del>-                $action = 'action=edit&amp;';
</del><ins>+                $action = '&amp;action=edit';
</ins><span class="cx">         else
</span><del>-                $action = 'action=edit&';
</del><ins>+                $action = '&action=edit';
</ins><span class="cx">
</span><del>-        switch ( $post->post_type ) :
-        case 'page' :
-                if ( !current_user_can( 'edit_page', $post->ID ) )
-                        return;
-                $file = 'page';
-                $var = 'post';
-                break;
-        case 'attachment' :
-                if ( !current_user_can( 'edit_post', $post->ID ) )
-                        return;
-                $file = 'media';
-                $var = 'attachment_id';
-                break;
-        case 'revision' :
-                if ( !current_user_can( 'edit_post', $post->ID ) )
-                        return;
-                $file = 'revision';
-                $var = 'revision';
-                $action = '';
-                break;
-        default :
-                if ( !current_user_can( 'edit_post', $post->ID ) )
-                        return apply_filters( 'get_edit_post_link', '', $post->ID, $context );
-                $file = 'post';
-                $var = 'post';
-                break;
-        endswitch;
</del><ins>+        $post_type_object = get_post_type_object( $post->post_type );
+        if ( !$post_type_object )
+                return;
</ins><span class="cx">
</span><del>-        return apply_filters( 'get_edit_post_link', admin_url("$file.php?{$action}$var=$post->ID"), $post->ID, $context );
</del><ins>+        if ( !current_user_can( $post_type_object->edit_cap, $post->ID ) )
+                return;
+
+        return apply_filters( 'get_edit_post_link', admin_url( sprintf($post_type_object->_edit_link . $action, $post->ID) ), $post->ID, $context );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-includes/post.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -15,10 +15,10 @@
</span><span class="cx"> * Creates the initial post types when 'init' action is fired.
</span><span class="cx"> */
</span><span class="cx"> function create_initial_post_types() {
</span><del>-        register_post_type( 'post', array('exclude_from_search' => false) );
-        register_post_type( 'page', array('exclude_from_search' => false) );
-        register_post_type( 'attachment', array('exclude_from_search' => false) );
-        register_post_type( 'revision', array('exclude_from_search' => true) );
</del><ins>+        register_post_type( 'post', array('label' => __('Posts'), 'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false) );
+        register_post_type( 'page', array('label' => __('Pages'),'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'page.php?post=%d', 'capability_type' => 'page', 'hierarchical' => true) );
+        register_post_type( 'attachment', array('label' => __('Media'), 'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'media.php?attachment_id=%d', 'capability_type' => 'post', 'hierarchical' => false) );
+        register_post_type( 'revision', array('label' => __('Revisions'),'exclude_from_search' => true, '_builtin' => true, '_edit_link' => 'revision.php?revision=%d', 'capability_type' => 'post', 'hierarchical' => false) );
</ins><span class="cx"> }
</span><span class="cx"> add_action( 'init', 'create_initial_post_types', 0 ); // highest priority
</span><span class="cx">
</span><span class="lines">@@ -442,6 +442,28 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Retrieve a post type object by name
+ *
+ * @package WordPress
+ * @subpackage Post
+ * @since 3.0
+ * @uses $wp_post_types
+ * @see register_post_type
+ * @see get_post_types
+ *
+ * @param string $post_type The name of a registered post type
+ * @return object A post type object
+ */
+function get_post_type_object( $post_type ) {
+        global $wp_post_types;
+
+        if ( empty($wp_post_types[$post_type]) )
+                return null;
+
+        return $wp_post_types[$post_type];
+}
+
+/**
</ins><span class="cx"> * Get a list of all registered post type objects.
</span><span class="cx"> *
</span><span class="cx"> * @package WordPress
</span><span class="lines">@@ -491,7 +513,12 @@
</span><span class="cx"> *
</span><span class="cx"> * Optional $args contents:
</span><span class="cx"> *
</span><ins>+ * label - A descriptive name for the post type marked for translation. Defaults to $post_type.
+ * public - Whether posts of this type should be shown in the admin UI. Defaults to true.
</ins><span class="cx"> * exclude_from_search - Whether to exclude posts with this post type from search results. Defaults to true.
</span><ins>+ * inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none.
+ * capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post".
+ * hierarchical - Whether the post type is hierarchical. Defaults to false.
</ins><span class="cx"> *
</span><span class="cx"> * @package WordPress
</span><span class="cx"> * @subpackage Post
</span><span class="lines">@@ -507,12 +534,31 @@
</span><span class="cx">         if (!is_array($wp_post_types))
</span><span class="cx">                 $wp_post_types = array();
</span><span class="cx">
</span><del>-        $defaults = array('exclude_from_search' => true);
</del><ins>+        // Args prefixed with an underscore are reserved for internal use.
+        $defaults = array('label' => false, 'exclude_from_search' => true, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, '_show' => false);
</ins><span class="cx">         $args = wp_parse_args($args, $defaults);
</span><ins>+        $args = (object) $args;
</ins><span class="cx">
</span><span class="cx">         $post_type = sanitize_user($post_type, true);
</span><del>-        $args['name'] = $post_type;
-        $wp_post_types[$post_type] = (object) $args;
</del><ins>+        $args->name = $post_type;
+
+        if ( false === $args->label )
+                $args->label = $post_type;
+
+        if ( empty($args->capability_type) ) {
+                $args->edit_cap = '';
+                $args->read_cap = '';
+        } else {
+                $args->edit_cap = 'edit_' . $args->capability_type;
+                $args->read_cap = 'read_' . $args->capability_type;
+        }
+
+        if ( !$args->_builtin && $args->public )
+                $args->_show = true;
+
+        $wp_post_types[$post_type] = $args;
+
+        return $args;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -1018,7 +1064,8 @@
</span><span class="cx">
</span><span class="cx">         $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";
</span><span class="cx">         if ( 'readable' == $perm && is_user_logged_in() ) {
</span><del>-                if ( !current_user_can("read_private_{$type}s") ) {
</del><ins>+                $post_type_object = get_post_type_object($type);
+                if ( !current_user_can("read_private_{$post_type_object->capability_type}s") ) {
</ins><span class="cx">                         $cache_key .= '_' . $perm . '_' . $user->ID;
</span><span class="cx">                         $query .= " AND (post_status != 'private' OR ( post_author = '$user->ID' AND post_status = 'private' ))";
</span><span class="cx">                 }
</span></span></pre></div>
<a id="trunkwpincludesqueryphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/query.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/query.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-includes/query.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -2062,8 +2062,13 @@
</span><span class="cx">
</span><span class="cx">                 if ( is_array($post_type) )
</span><span class="cx">                         $post_type_cap = 'multiple_post_type';
</span><del>-                else
-                        $post_type_cap = $post_type;
</del><ins>+                else {
+                        $post_type_object = get_post_type_object ( $post_type );
+                        if ( !empty($post_type_object) )
+                                $post_type_cap = $post_type_object->capability_type;
+                        else
+                                $post_type_cap = $post_type;
+                }
</ins><span class="cx">
</span><span class="cx">                 $exclude_post_types = '';
</span><span class="cx">                 foreach ( get_post_types( array('exclude_from_search' => true) ) as $_wp_post_type )
</span></span></pre></div>
<a id="trunkwpincludestaxonomyphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/taxonomy.php (12596 => 12597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/taxonomy.php        2010-01-02 17:16:26 UTC (rev 12596)
+++ trunk/wp-includes/taxonomy.php        2010-01-04 16:58:43 UTC (rev 12597)
</span><span class="lines">@@ -180,20 +180,46 @@
</span><span class="cx">                 $wp->add_query_var($args['query_var']);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ( false !== $args['rewrite'] && !empty($wp_rewrite) ) {
</del><ins>+        if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') ) {
</ins><span class="cx">                 if ( !is_array($args['rewrite']) )
</span><span class="cx">                         $args['rewrite'] = array();
</span><span class="cx">                 if ( !isset($args['rewrite']['slug']) )
</span><span class="cx">                         $args['rewrite']['slug'] = sanitize_title_with_dashes($taxonomy);
</span><span class="cx">                 $wp_rewrite->add_rewrite_tag("%$taxonomy%", '([^/]+)', $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=$term");
</span><del>-                $wp_rewrite->add_permastruct($taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%");
</del><ins>+                $wp_rewrite->add_permastruct($taxonomy, "/{$args['rewrite']['slug']}/%$taxonomy%");
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         $args['name'] = $taxonomy;
</span><del>-        $args['object_type'] = $object_type;
</del><ins>+        $args['object_type'] = (array) $object_type;
</ins><span class="cx">         $wp_taxonomies[$taxonomy] = (object) $args;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Add an already registered taxonomy to an object type.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 3.0
+ * @uses $wp_taxonomies Modifies taxonomy object
+ *
+ * @param string $taxonomy Name of taxonomy object
+ * @param array|string $object_type Name of the object type
+ * @return bool True if successful, false if not
+ */
+function register_taxonomy_for_object_type( $taxonomy, $object_type) {
+        global $wp_taxonomies;
+
+        if ( !isset($wp_taxonomies[$taxonomy]) )
+                return false;
+
+        if ( ! get_post_type_object($object_type) )
+                return false;
+
+        $wp_taxonomies[$taxonomy]->object_type[] = $object_type;
+
+        return true;
+}
+
</ins><span class="cx"> //
</span><span class="cx"> // Term API
</span><span class="cx"> //
</span><span class="lines">@@ -2378,4 +2404,26 @@
</span><span class="cx">         return false;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Determine if the given object type is associated with the given taxonomy.
+ *
+ * @since 3.0
+ * @uses get_object_taxonomies()
+ *
+ * @param string $object_type Object type string
+ * @param string $taxonomy. Single taxonomy name
+ * @return bool True if object is associated with the taxonomy, otherwise false.
+ */
+function is_object_in_taxonomy($object_type, $taxonomy) {
+        $taxonomies = get_object_taxonomies($object_type);
+
+        if ( empty($taxonomies) )
+                return false;
+
+        if ( in_array($taxonomy, $taxonomies) )
+                return true;
+
+        return false;
+}
+
</ins><span class="cx"> ?>
</span></span></pre>
</div>
</div>
</body>
</html>