<!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>[12993] trunk: Add a separate show_ui flag for post types.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12993">12993</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-02-06 17:27:30 +0000 (Sat, 06 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add a separate show_ui flag for post types. see <a href="http://trac.wordpress.org/ticket/9674">#9674</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmineditphp">trunk/wp-admin/edit.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="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmineditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit.php (12992 => 12993)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit.php        2010-02-06 17:09:34 UTC (rev 12992)
+++ trunk/wp-admin/edit.php        2010-02-06 17:27:30 UTC (rev 12993)
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx">         unset( $_redirect );
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-if ( isset($_GET['post_type']) &amp;&amp; ( in_array( $_GET['post_type'], get_post_types( array('_show' =&gt; true ) ) ) || in_array( $_GET['post_type'], get_post_types( array('_builtin' =&gt; true ) ) ) ) )
</del><ins>+if ( isset($_GET['post_type']) &amp;&amp; ( in_array( $_GET['post_type'], get_post_types( array('public' =&gt; true ) ) ) ) )
</ins><span class="cx">         $post_type = $_GET['post_type'];
</span><span class="cx"> else
</span><span class="cx">         $post_type = 'post';
</span></span></pre></div>
<a id="trunkwpadminmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/menu.php (12992 => 12993)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/menu.php        2010-02-06 17:09:34 UTC (rev 12992)
+++ trunk/wp-admin/menu.php        2010-02-06 17:27:30 UTC (rev 12993)
</span><span class="lines">@@ -81,10 +81,10 @@
</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><del>-foreach ( (array) get_post_types( array('_show' =&gt; true) ) as $ptype ) {
</del><ins>+foreach ( (array) get_post_types( array('show_ui' =&gt; true) ) as $ptype ) {
</ins><span class="cx">         $_wp_last_object_menu++;
</span><span class="cx">         $ptype_obj = get_post_type_object($ptype);
</span><del>-        $menu[$_wp_last_object_menu] = array(esc_attr($ptype_obj-&gt;label), 'edit_' . $ptype_obj-&gt;capability_type . 's', &quot;edit.php?post_type=$ptype&quot;, '', 'menu-top', 'menu-posts', 'div');
</del><ins>+        $menu[$_wp_last_object_menu] = array(esc_attr($ptype_obj-&gt;label), $ptype_obj-&gt;edit_type_cap, &quot;edit.php?post_type=$ptype&quot;, '', 'menu-top', 'menu-posts', 'div');
</ins><span class="cx">         $submenu[&quot;edit.php?post_type=$ptype&quot;][5]  = array( __('Edit'), 'edit_posts',  &quot;edit.php?post_type=$ptype&quot;);
</span><span class="cx">         /* translators: add new custom post type */
</span><span class="cx">         $submenu[&quot;edit.php?post_type=$ptype&quot;][10]  = array( _x('Add New', 'post'), 'edit_posts', &quot;post-new.php?post_type=$ptype&quot; );
</span></span></pre></div>
<a id="trunkwpadminpostnewphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/post-new.php (12992 => 12993)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/post-new.php        2010-02-06 17:09:34 UTC (rev 12992)
+++ trunk/wp-admin/post-new.php        2010-02-06 17:27:30 UTC (rev 12993)
</span><span class="lines">@@ -9,7 +9,7 @@
</span><span class="cx"> /** Load WordPress Administration Bootstrap */
</span><span class="cx"> require_once('admin.php');
</span><span class="cx"> 
</span><del>-if ( isset($_GET['post_type']) &amp;&amp; ( in_array( $_GET['post_type'], get_post_types( array('_show' =&gt; true ) ) ) || in_array( $_GET['post_type'], get_post_types( array('_builtin' =&gt; true ) ) ) ) )
</del><ins>+if ( isset($_GET['post_type']) &amp;&amp; ( in_array( $_GET['post_type'], get_post_types( array('public' =&gt; true ) ) ) ) )
</ins><span class="cx">         $post_type = $_GET['post_type'];
</span><span class="cx"> else
</span><span class="cx">         $post_type = 'post';
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (12992 => 12993)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2010-02-06 17:09:34 UTC (rev 12992)
+++ trunk/wp-includes/post.php        2010-02-06 17:27:30 UTC (rev 12993)
</span><span class="lines">@@ -16,8 +16,8 @@
</span><span class="cx">  */
</span><span class="cx"> function create_initial_post_types() {
</span><span class="cx">         register_post_type( 'post', array(        'label' =&gt; __('Posts'),
</span><del>-                                                                                'publicly_queryable' =&gt; true,
-                                                                                'exclude_from_search' =&gt; false,
</del><ins>+                                                                                'public' =&gt; true,
+                                                                                'show_ui' =&gt; false,
</ins><span class="cx">                                                                                 '_builtin' =&gt; true,
</span><span class="cx">                                                                                 '_edit_link' =&gt; 'post.php?post=%d',
</span><span class="cx">                                                                                 'capability_type' =&gt; 'post',
</span><span class="lines">@@ -28,8 +28,8 @@
</span><span class="cx">                                                                         ) );
</span><span class="cx"> 
</span><span class="cx">         register_post_type( 'page', array(        'label' =&gt; __('Pages'),
</span><del>-                                                                                'publicly_queryable' =&gt; true,
-                                                                                'exclude_from_search' =&gt; false,
</del><ins>+                                                                                'public' =&gt; true,
+                                                                                'show_ui' =&gt; false,
</ins><span class="cx">                                                                                 '_builtin' =&gt; true,
</span><span class="cx">                                                                                 '_edit_link' =&gt; 'post.php?post=%d',
</span><span class="cx">                                                                                 'capability_type' =&gt; 'page',
</span><span class="lines">@@ -40,7 +40,8 @@
</span><span class="cx">                                                                         ) );
</span><span class="cx"> 
</span><span class="cx">         register_post_type( 'attachment', array('label' =&gt; __('Media'),
</span><del>-                                                                                        'exclude_from_search' =&gt; false,
</del><ins>+                                                                                        'public' =&gt; true,
+                                                                                        'show_ui' =&gt; false,
</ins><span class="cx">                                                                                         '_builtin' =&gt; true,
</span><span class="cx">                                                                                         '_edit_link' =&gt; 'media.php?attachment_id=%d',
</span><span class="cx">                                                                                         'capability_type' =&gt; 'post',
</span><span class="lines">@@ -50,7 +51,7 @@
</span><span class="cx">                                                                                 ) );
</span><span class="cx"> 
</span><span class="cx">         register_post_type( 'revision', array(        'label' =&gt; __('Revisions'),
</span><del>-                                                                                        'exclude_from_search' =&gt; true,
</del><ins>+                                                                                        'public' =&gt; false,
</ins><span class="cx">                                                                                         '_builtin' =&gt; true,
</span><span class="cx">                                                                                         '_edit_link' =&gt; 'revision.php?revision=%d',
</span><span class="cx">                                                                                         'capability_type' =&gt; 'post',
</span><span class="lines">@@ -704,6 +705,7 @@
</span><span class="cx">  * public - Whether posts of this type should be shown in the admin UI. Defaults to false.
</span><span class="cx">  * exclude_from_search - Whether to exclude posts with this post type from search results. Defaults to true if the type is not public, false if the type is public.
</span><span class="cx">  * publicly_queryable - Whether post_type queries can be performed from the front page.  Defaults to whatever public is set as.
</span><ins>+ * show_ui - Whether to generate a default UI for managing this post type. Defaults to true if the type is public, false if the type is not public.
</ins><span class="cx">  * inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none.
</span><span class="cx">  * capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to &quot;post&quot;.
</span><span class="cx">  * edit_cap - The capability that controls editing a particular object of this post type. Defaults to &quot;edit_$capability_type&quot; (edit_post).
</span><span class="lines">@@ -732,7 +734,7 @@
</span><span class="cx">                 $wp_post_types = array();
</span><span class="cx"> 
</span><span class="cx">         // Args prefixed with an underscore are reserved for internal use.
</span><del>-        $defaults = array('label' =&gt; false, 'publicly_queryable' =&gt; null, 'exclude_from_search' =&gt; null, '_builtin' =&gt; false, '_edit_link' =&gt; 'post.php?post=%d', 'capability_type' =&gt; 'post', 'hierarchical' =&gt; false, 'public' =&gt; false, '_show' =&gt; false, 'rewrite' =&gt; true, 'query_var' =&gt; true, 'supports' =&gt; array(), 'register_meta_box_cb' =&gt; null, 'taxonomies' =&gt; array() );
</del><ins>+        $defaults = array('label' =&gt; false, 'publicly_queryable' =&gt; null, 'exclude_from_search' =&gt; null, '_builtin' =&gt; false, '_edit_link' =&gt; 'post.php?post=%d', 'capability_type' =&gt; 'post', 'hierarchical' =&gt; false, 'public' =&gt; false, 'rewrite' =&gt; true, 'query_var' =&gt; true, 'supports' =&gt; array(), 'register_meta_box_cb' =&gt; null, 'taxonomies' =&gt; array(), 'show_ui' =&gt; null );
</ins><span class="cx">         $args = wp_parse_args($args, $defaults);
</span><span class="cx">         $args = (object) $args;
</span><span class="cx"> 
</span><span class="lines">@@ -743,6 +745,10 @@
</span><span class="cx">         if ( null === $args-&gt;publicly_queryable )
</span><span class="cx">                 $args-&gt;publicly_queryable = $args-&gt;public;
</span><span class="cx"> 
</span><ins>+        // If not set, default to the setting for public.
+        if ( null === $args-&gt;show_ui )
+                $args-&gt;show_ui = $args-&gt;public;
+
</ins><span class="cx">         // If not set, default to true if not public, false if public.
</span><span class="cx">         if ( null === $args-&gt;exclude_from_search )
</span><span class="cx">                 $args-&gt;exclude_from_search = !$args-&gt;public;
</span><span class="lines">@@ -765,9 +771,6 @@
</span><span class="cx">         if ( empty($args-&gt;delete_cap) )
</span><span class="cx">                 $args-&gt;delete_cap = 'delete_' . $args-&gt;capability_type;
</span><span class="cx"> 
</span><del>-        if ( !$args-&gt;_builtin &amp;&amp; $args-&gt;public )
-                $args-&gt;_show = true;
-
</del><span class="cx">         if ( ! empty($args-&gt;supports) ) {
</span><span class="cx">                 add_post_type_support($post_type, $args-&gt;supports);
</span><span class="cx">                 unset($args-&gt;supports);
</span></span></pre>
</div>
</div>

</body>
</html>