<!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 ) && post_type_supports($post_type, 'post-thumbnails') )
</del><ins>+if ( current_theme_supports( 'post-thumbnails', $post_type ) && 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->post_status && !current_user_can( $post_type_object->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->id ); // TODO: ROLE SYSTEM
-if ( $post->post_author && !in_array($post->post_author, $authors) )
-        $authors[] = $post->post_author;
-if ( $authors && count( $authors ) > 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->id ); // TODO: ROLE SYSTEM
+        if ( $post->post_author && !in_array($post->post_author, $authors) )
+                $authors[] = $post->post_author;
+        if ( $authors && count( $authors ) > 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') && 0 < $post_ID && 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"> <div id="post-body">
</span><span class="cx"> <div id="post-body-content">
</span><ins>+<?php if ( post_type_supports($post_type, 'title') ) { ?>
</ins><span class="cx"> <div id="titlediv">
</span><span class="cx"> <div id="titlewrap">
</span><span class="cx">         <label class="screen-reader-text" for="title"><?php _e('Title') ?></label>
</span><span class="lines">@@ -198,16 +201,19 @@
</span><span class="cx">
</span><span class="cx"> if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->publish_cap ) ) ) { ?>
</span><span class="cx">         <div id="edit-slug-box">
</span><del>-<?php
-        if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status ) :
-                echo $sample_permalink_html;
-endif; ?>
</del><ins>+        <?php
+                if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status )
+                        echo $sample_permalink_html;
+        ?>
</ins><span class="cx">         </div>
</span><span class="cx"> <?php
</span><del>-} ?>
</del><ins>+}
+?>
</ins><span class="cx"> </div>
</span><span class="cx"> </div>
</span><ins>+<?php } ?>
</ins><span class="cx">
</span><ins>+<?php if ( post_type_supports($post_type, 'editor') ) { ?>
</ins><span class="cx"> <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
</span><span class="cx">
</span><span class="cx"> <?php the_editor($post->post_content); ?>
</span><span class="lines">@@ -239,6 +245,7 @@
</span><span class="cx"> </div>
</span><span class="cx">
</span><span class="cx"> <?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' => false,
</span><span class="cx">                                                                                 'rewrite' => false,
</span><span class="cx">                                                                                 'query_var' => false,
</span><del>-                                                                                'supports' => array('post-thumbnails', 'excerpts', 'trackbacks', 'custom-fields', 'comments', 'revisions')
</del><ins>+                                                                                'supports' => 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' => __('Pages'),
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx">                                                                                 'hierarchical' => true,
</span><span class="cx">                                                                                 'rewrite' => false,
</span><span class="cx">                                                                                 'query_var' => false,
</span><del>-                                                                                'supports' => array('post-thumbnails', 'page-attributes', 'custom-fields', 'comments', 'revisions')
</del><ins>+                                                                                'supports' => 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' => __('Media'),
</span><span class="lines">@@ -835,6 +835,9 @@
</span><span class="cx">         if ( ! empty($args->supports) ) {
</span><span class="cx">                 add_post_type_support($post_type, $args->supports);
</span><span class="cx">                 unset($args->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->query_var && !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>