mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
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: http://svn.automattic.com/wordpress/trunk@13710 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1aa48c2677
commit
81d6e1e8b3
@ -106,10 +106,10 @@ foreach ( get_object_taxonomies($post_type) as $tax_name ) {
|
||||
if ( post_type_supports($post_type, 'page-attributes') )
|
||||
add_meta_box('pageparentdiv', __('Attributes'), 'page_attributes_meta_box', $post_type, 'side', 'core');
|
||||
|
||||
if ( current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports($post_type, 'post-thumbnails') )
|
||||
if ( current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports($post_type, 'thumbnail') )
|
||||
add_meta_box('postimagediv', __('Post Thumbnail'), 'post_thumbnail_meta_box', $post_type, 'side', 'low');
|
||||
|
||||
if ( post_type_supports($post_type, 'excerpts') )
|
||||
if ( post_type_supports($post_type, 'excerpt') )
|
||||
add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $post_type, 'normal', 'core');
|
||||
|
||||
if ( post_type_supports($post_type, 'trackbacks') )
|
||||
@ -128,11 +128,13 @@ if ( ('publish' == $post->post_status || 'private' == $post->post_status) && pos
|
||||
if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->publish_cap ) ) )
|
||||
add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core');
|
||||
|
||||
$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');
|
||||
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');
|
||||
}
|
||||
|
||||
if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && wp_get_post_revisions( $post_ID ) )
|
||||
add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core');
|
||||
@ -184,6 +186,7 @@ $side_meta_boxes = do_meta_boxes($post_type, 'side', $post);
|
||||
|
||||
<div id="post-body">
|
||||
<div id="post-body-content">
|
||||
<?php if ( post_type_supports($post_type, 'title') ) { ?>
|
||||
<div id="titlediv">
|
||||
<div id="titlewrap">
|
||||
<label class="screen-reader-text" for="title"><?php _e('Title') ?></label>
|
||||
@ -198,16 +201,19 @@ if ( !empty($shortlink) )
|
||||
|
||||
if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->publish_cap ) ) ) { ?>
|
||||
<div id="edit-slug-box">
|
||||
<?php
|
||||
if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status ) :
|
||||
echo $sample_permalink_html;
|
||||
endif; ?>
|
||||
<?php
|
||||
if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status )
|
||||
echo $sample_permalink_html;
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
} ?>
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( post_type_supports($post_type, 'editor') ) { ?>
|
||||
<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
|
||||
|
||||
<?php the_editor($post->post_content); ?>
|
||||
@ -239,6 +245,7 @@ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
do_meta_boxes($post_type, 'normal', $post);
|
||||
|
||||
|
@ -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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user