<!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>[13710] trunk: Allow enabling/disabling title and editor per post type.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13710">13710</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-03-15 21:16:41 +0000 (Mon, 15 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Allow enabling/disabling title and editor per post type. Introdoce remove_post_type_support().  Add enable/disable for author override. Props scribu. fixes <a href="http://trac.wordpress.org/ticket/12590">#12590</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmineditformadvancedphp">trunk/wp-admin/edit-form-advanced.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmineditformadvancedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-form-advanced.php (13709 => 13710)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-form-advanced.php        2010-03-15 18:10:34 UTC (rev 13709)
+++ trunk/wp-admin/edit-form-advanced.php        2010-03-15 21:16:41 UTC (rev 13710)
</span><span class="lines">@@ -106,10 +106,10 @@
</span><span class="cx"> if ( post_type_supports($post_type, 'page-attributes') )
</span><span class="cx">         add_meta_box('pageparentdiv', __('Attributes'), 'page_attributes_meta_box', $post_type, 'side', 'core');
</span><span class="cx"> 
</span><del>-if ( current_theme_supports( 'post-thumbnails', $post_type ) &amp;&amp; post_type_supports($post_type, 'post-thumbnails') )
</del><ins>+if ( current_theme_supports( 'post-thumbnails', $post_type ) &amp;&amp; post_type_supports($post_type, 'thumbnail') )
</ins><span class="cx">         add_meta_box('postimagediv', __('Post Thumbnail'), 'post_thumbnail_meta_box', $post_type, 'side', 'low');
</span><span class="cx"> 
</span><del>-if ( post_type_supports($post_type, 'excerpts') )
</del><ins>+if ( post_type_supports($post_type, 'excerpt') )
</ins><span class="cx">         add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $post_type, 'normal', 'core');
</span><span class="cx"> 
</span><span class="cx"> if ( post_type_supports($post_type, 'trackbacks') )
</span><span class="lines">@@ -128,11 +128,13 @@
</span><span class="cx"> if ( !( 'pending' == $post-&gt;post_status &amp;&amp; !current_user_can( $post_type_object-&gt;publish_cap ) ) )
</span><span class="cx">         add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core');
</span><span class="cx"> 
</span><del>-$authors = get_editable_user_ids( $current_user-&gt;id ); // TODO: ROLE SYSTEM
-if ( $post-&gt;post_author &amp;&amp; !in_array($post-&gt;post_author, $authors) )
-        $authors[] = $post-&gt;post_author;
-if ( $authors &amp;&amp; count( $authors ) &gt; 1 )
-        add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core');
</del><ins>+if ( post_type_supports($post_type, 'author') ) {
+        $authors = get_editable_user_ids( $current_user-&gt;id ); // TODO: ROLE SYSTEM
+        if ( $post-&gt;post_author &amp;&amp; !in_array($post-&gt;post_author, $authors) )
+                $authors[] = $post-&gt;post_author;
+        if ( $authors &amp;&amp; count( $authors ) &gt; 1 )
+                add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core');
+}
</ins><span class="cx"> 
</span><span class="cx"> if ( post_type_supports($post_type, 'revisions') &amp;&amp; 0 &lt; $post_ID &amp;&amp; wp_get_post_revisions( $post_ID ) )
</span><span class="cx">         add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core');
</span><span class="lines">@@ -184,6 +186,7 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;div id=&quot;post-body&quot;&gt;
</span><span class="cx"> &lt;div id=&quot;post-body-content&quot;&gt;
</span><ins>+&lt;?php if ( post_type_supports($post_type, 'title') ) { ?&gt;
</ins><span class="cx"> &lt;div id=&quot;titlediv&quot;&gt;
</span><span class="cx"> &lt;div id=&quot;titlewrap&quot;&gt;
</span><span class="cx">         &lt;label class=&quot;screen-reader-text&quot; for=&quot;title&quot;&gt;&lt;?php _e('Title') ?&gt;&lt;/label&gt;
</span><span class="lines">@@ -198,16 +201,19 @@
</span><span class="cx"> 
</span><span class="cx"> if ( !( 'pending' == $post-&gt;post_status &amp;&amp; !current_user_can( $post_type_object-&gt;publish_cap ) ) ) { ?&gt;
</span><span class="cx">         &lt;div id=&quot;edit-slug-box&quot;&gt;
</span><del>-&lt;?php
-        if ( ! empty($post-&gt;ID) &amp;&amp; ! empty($sample_permalink_html) &amp;&amp; 'auto-draft' != $post-&gt;post_status ) :
-                echo $sample_permalink_html;
-endif; ?&gt;
</del><ins>+        &lt;?php
+                if ( ! empty($post-&gt;ID) &amp;&amp; ! empty($sample_permalink_html) &amp;&amp; 'auto-draft' != $post-&gt;post_status )
+                        echo $sample_permalink_html;
+        ?&gt;
</ins><span class="cx">         &lt;/div&gt;
</span><span class="cx"> &lt;?php
</span><del>-} ?&gt;
</del><ins>+}
+?&gt;
</ins><span class="cx"> &lt;/div&gt;
</span><span class="cx"> &lt;/div&gt;
</span><ins>+&lt;?php } ?&gt;
</ins><span class="cx"> 
</span><ins>+&lt;?php if ( post_type_supports($post_type, 'editor') ) { ?&gt;
</ins><span class="cx"> &lt;div id=&quot;&lt;?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?&gt;&quot; class=&quot;postarea&quot;&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;?php the_editor($post-&gt;post_content); ?&gt;
</span><span class="lines">@@ -239,6 +245,7 @@
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;?php
</span><ins>+}
</ins><span class="cx"> 
</span><span class="cx"> do_meta_boxes($post_type, 'normal', $post);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (13709 => 13710)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2010-03-15 18:10:34 UTC (rev 13709)
+++ trunk/wp-includes/post.php        2010-03-15 21:16:41 UTC (rev 13710)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx">                                                                                 'hierarchical' =&gt; false,
</span><span class="cx">                                                                                 'rewrite' =&gt; false,
</span><span class="cx">                                                                                 'query_var' =&gt; false,
</span><del>-                                                                                'supports' =&gt; array('post-thumbnails', 'excerpts', 'trackbacks', 'custom-fields', 'comments', 'revisions')
</del><ins>+                                                                                'supports' =&gt; array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions')
</ins><span class="cx">                                                                         ) );
</span><span class="cx"> 
</span><span class="cx">         register_post_type( 'page', array(        'label' =&gt; __('Pages'),
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx">                                                                                 'hierarchical' =&gt; true,
</span><span class="cx">                                                                                 'rewrite' =&gt; false,
</span><span class="cx">                                                                                 'query_var' =&gt; false,
</span><del>-                                                                                'supports' =&gt; array('post-thumbnails', 'page-attributes', 'custom-fields', 'comments', 'revisions')
</del><ins>+                                                                                'supports' =&gt; array('title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions')
</ins><span class="cx">                                                                         ) );
</span><span class="cx"> 
</span><span class="cx">         register_post_type( 'attachment', array('label' =&gt; __('Media'),
</span><span class="lines">@@ -835,6 +835,9 @@
</span><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><ins>+        } else {
+                // Add default features
+                add_post_type_support($post_type, array('title', 'editor'));
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if ( false !== $args-&gt;query_var &amp;&amp; !empty($wp) ) {
</span><span class="lines">@@ -887,6 +890,23 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * Remove support for a feature from a post type.
+ *
+ * @since 3.0
+ * @param string $post_type The post type for which to remove the feature
+ * @param string $feature The feature being removed
+ */
+function remove_post_type_support( $post_type, $feature ) {
+        global $_wp_post_type_features;
+
+        if ( !isset($_wp_post_type_features[$post_type]) )
+                return;
+
+        if ( isset($_wp_post_type_features[$post_type][$feature]) )
+                unset($_wp_post_type_features[$post_type][$feature]);
+}
+
+/**
</ins><span class="cx">  * Checks a post type's support for a given feature
</span><span class="cx">  *
</span><span class="cx">  * @since 3.0
</span></span></pre>
</div>
</div>

</body>
</html>