Allow enabling/disabling title and editor per post type. Introdoce remove_post_type_support(). Add enable/disable for author override. Props scribu. fixes #12590

git-svn-id: https://develop.svn.wordpress.org/trunk@13710 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2010-03-15 21:16:41 +00:00
parent feb6eacff1
commit b8fb00fc92
2 changed files with 41 additions and 14 deletions
+22 -2
View File
@@ -25,7 +25,7 @@ function create_initial_post_types() {
'hierarchical' => false,
'rewrite' => false,
'query_var' => false,
'supports' => array('post-thumbnails', 'excerpts', 'trackbacks', 'custom-fields', 'comments', 'revisions')
'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions')
) );
register_post_type( 'page', array( 'label' => __('Pages'),
@@ -38,7 +38,7 @@ function create_initial_post_types() {
'hierarchical' => true,
'rewrite' => false,
'query_var' => false,
'supports' => array('post-thumbnails', 'page-attributes', 'custom-fields', 'comments', 'revisions')
'supports' => array('title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions')
) );
register_post_type( 'attachment', array('label' => __('Media'),
@@ -835,6 +835,9 @@ function register_post_type($post_type, $args = array()) {
if ( ! empty($args->supports) ) {
add_post_type_support($post_type, $args->supports);
unset($args->supports);
} else {
// Add default features
add_post_type_support($post_type, array('title', 'editor'));
}
if ( false !== $args->query_var && !empty($wp) ) {
@@ -886,6 +889,23 @@ function add_post_type_support( $post_type, $feature ) {
}
}
/**
* 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]);
}
/**
* Checks a post type's support for a given feature
*