mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00: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: https://develop.svn.wordpress.org/trunk@13710 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
+22
-2
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user