Make WordPress Core

Changeset 13710


Ignore:
Timestamp:
03/15/2010 09:16:41 PM (15 years ago)
Author:
ryan
Message:

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

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r13635 r13710  
    107107    add_meta_box('pageparentdiv', __('Attributes'), 'page_attributes_meta_box', $post_type, 'side', 'core');
    108108
    109 if ( current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports($post_type, 'post-thumbnails') )
     109if ( current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports($post_type, 'thumbnail') )
    110110    add_meta_box('postimagediv', __('Post Thumbnail'), 'post_thumbnail_meta_box', $post_type, 'side', 'low');
    111111
    112 if ( post_type_supports($post_type, 'excerpts') )
     112if ( post_type_supports($post_type, 'excerpt') )
    113113    add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $post_type, 'normal', 'core');
    114114
     
    129129    add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core');
    130130
    131 $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
    132 if ( $post->post_author && !in_array($post->post_author, $authors) )
    133     $authors[] = $post->post_author;
    134 if ( $authors && count( $authors ) > 1 )
    135     add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core');
     131if ( post_type_supports($post_type, 'author') ) {
     132    $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
     133    if ( $post->post_author && !in_array($post->post_author, $authors) )
     134        $authors[] = $post->post_author;
     135    if ( $authors && count( $authors ) > 1 )
     136        add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core');
     137}
    136138
    137139if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && wp_get_post_revisions( $post_ID ) )
     
    185187<div id="post-body">
    186188<div id="post-body-content">
     189<?php if ( post_type_supports($post_type, 'title') ) { ?>
    187190<div id="titlediv">
    188191<div id="titlewrap">
     
    199202if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->publish_cap ) ) ) { ?>
    200203    <div id="edit-slug-box">
    201 <?php
    202     if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status ) :
    203         echo $sample_permalink_html;
    204 endif; ?>
     204    <?php
     205        if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status )
     206            echo $sample_permalink_html;
     207    ?>
    205208    </div>
    206209<?php
    207 } ?>
    208 </div>
    209 </div>
    210 
     210}
     211?>
     212</div>
     213</div>
     214<?php } ?>
     215
     216<?php if ( post_type_supports($post_type, 'editor') ) { ?>
    211217<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
    212218
     
    240246
    241247<?php
     248}
    242249
    243250do_meta_boxes($post_type, 'normal', $post);
  • trunk/wp-includes/post.php

    r13695 r13710  
    2626                                        'rewrite' => false,
    2727                                        'query_var' => false,
    28                                         'supports' => array('post-thumbnails', 'excerpts', 'trackbacks', 'custom-fields', 'comments', 'revisions')
     28                                        'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions')
    2929                                    ) );
    3030
     
    3939                                        'rewrite' => false,
    4040                                        'query_var' => false,
    41                                         'supports' => array('post-thumbnails', 'page-attributes', 'custom-fields', 'comments', 'revisions')
     41                                        'supports' => array('title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions')
    4242                                    ) );
    4343
     
    836836        add_post_type_support($post_type, $args->supports);
    837837        unset($args->supports);
     838    } else {
     839        // Add default features
     840        add_post_type_support($post_type, array('title', 'editor'));
    838841    }
    839842
     
    885888            $_wp_post_type_features[$post_type][$feature] = array_slice( func_get_args(), 2 );
    886889    }
     890}
     891
     892/**
     893 * Remove support for a feature from a post type.
     894 *
     895 * @since 3.0
     896 * @param string $post_type The post type for which to remove the feature
     897 * @param string $feature The feature being removed
     898 */
     899function remove_post_type_support( $post_type, $feature ) {
     900    global $_wp_post_type_features;
     901
     902    if ( !isset($_wp_post_type_features[$post_type]) )
     903        return;
     904
     905    if ( isset($_wp_post_type_features[$post_type][$feature]) )
     906        unset($_wp_post_type_features[$post_type][$feature]);
    887907}
    888908
Note: See TracChangeset for help on using the changeset viewer.