diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php
index 2af0bb0074..b2ac3c8104 100644
--- a/wp-admin/edit-form-advanced.php
+++ b/wp-admin/edit-form-advanced.php
@@ -135,7 +135,7 @@ if ( $post->post_author && !in_array($post->post_author, $authors) )
if ( $authors && count( $authors ) > 1 )
add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core');
-if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) )
+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');
do_action('do_meta_boxes', $post_type, 'normal', $post);
diff --git a/wp-admin/revision.php b/wp-admin/revision.php
index 8c712a531f..9bf9c5dd8f 100644
--- a/wp-admin/revision.php
+++ b/wp-admin/revision.php
@@ -12,21 +12,15 @@ require_once('admin.php');
wp_enqueue_script('list-revisions');
wp_reset_vars(array('revision', 'left', 'right', 'diff', 'action'));
+
$revision_id = absint($revision);
$diff = absint($diff);
$left = absint($left);
$right = absint($right);
-$parent_file = $redirect = 'edit.php';
+$redirect = 'edit.php';
switch ( $action ) :
-case 'delete' : // stubs
-case 'edit' :
- if ( constant('WP_POST_REVISIONS') ) // stub
- $redirect = remove_query_arg( 'action' );
- else // Revisions disabled
- $redirect = 'edit.php';
- break;
case 'restore' :
if ( !$revision = wp_get_post_revision( $revision_id ) )
break;
@@ -115,9 +109,12 @@ default :
if ( !constant('WP_POST_REVISIONS') && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
break;
+ $post_type_object = get_post_type_object($post->post_type);
+
$post_title = '' . get_the_title() . '';
$revision_title = wp_post_revision_title( $revision, false );
- $h2 = sprintf( __( 'Post Revision for “%1$s” created on %2$s' ), $post_title, $revision_title );
+ $h2 = sprintf( __( 'Revision for “%1$s” created on %2$s' ), $post_title, $revision_title );
+ $title = __( 'Revisions' );
// Sets up the diff radio buttons
$left = $revision->ID;
@@ -127,21 +124,23 @@ default :
break;
endswitch;
-if ( !$redirect && !in_array( $post->post_type, array( 'post', 'page' ) ) )
- $redirect = 'edit.php';
+if ( !$redirect ) {
+ if ( empty($post->post_type) ) // Empty post_type means either malformed object found, or no valid parent was found.
+ $redirect = 'edit.php';
+ elseif ( !post_type_supports($post->post_type, 'revisions') )
+ $redirect = 'edit.php?post_type=' . $post->post_type;
+}
-if ( $redirect ) {
+if ( !empty($redirect) ) {
wp_redirect( $redirect );
exit;
}
-if ( 'page' == $post->post_type ) {
- $submenu_file = 'edit-pages.php';
- $title = __( 'Page Revisions' );
-} else {
- $submenu_file = 'edit.php';
- $title = __( 'Post Revisions' );
-}
+// This is so that the correct "Edit" menu item is selected.
+if ( !empty($post->post_type) && 'post' != $post->post_type )
+ $parent_file = $submenu_file = 'edit.php?post_type=' . $post->post_type;
+else
+ $parent_file = $submenu_file = 'edit.php';
require_once( 'admin-header.php' );
diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php
index 43ae7e4a04..9c85482034 100644
--- a/wp-includes/post-template.php
+++ b/wp-includes/post-template.php
@@ -1260,17 +1260,17 @@ function wp_list_post_revisions( $post_id = 0, $args = null ) {
extract( wp_parse_args( $args, $defaults ), EXTR_SKIP );
switch ( $type ) {
- case 'autosave' :
- if ( !$autosave = wp_get_post_autosave( $post->ID ) )
- return;
- $revisions = array( $autosave );
- break;
- case 'revision' : // just revisions - remove autosave later
- case 'all' :
- default :
- if ( !$revisions = wp_get_post_revisions( $post->ID ) )
- return;
- break;
+ case 'autosave' :
+ if ( !$autosave = wp_get_post_autosave( $post->ID ) )
+ return;
+ $revisions = array( $autosave );
+ break;
+ case 'revision' : // just revisions - remove autosave later
+ case 'all' :
+ default :
+ if ( !$revisions = wp_get_post_revisions( $post->ID ) )
+ return;
+ break;
}
/* translators: post revision: 1: when, 2: author name */
@@ -1326,6 +1326,7 @@ function wp_list_post_revisions( $post_id = 0, $args = null ) {
+
diff --git a/wp-includes/post.php b/wp-includes/post.php
index 2842f9520a..d178796069 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -15,18 +15,69 @@
* Creates the initial post types when 'init' action is fired.
*/
function create_initial_post_types() {
- register_post_type( 'post', array('label' => __('Posts'), 'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false) );
- register_post_type( 'page', array('label' => __('Pages'),'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'page', 'hierarchical' => true) );
- register_post_type( 'attachment', array('label' => __('Media'), 'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'media.php?attachment_id=%d', 'capability_type' => 'post', 'hierarchical' => false) );
- register_post_type( 'revision', array('label' => __('Revisions'),'exclude_from_search' => true, '_builtin' => true, '_edit_link' => 'revision.php?revision=%d', 'capability_type' => 'post', 'hierarchical' => false) );
- add_post_type_support('post', array('post-thumbnails', 'excerpts', 'trackbacks', 'custom-fields', 'comments') );
- add_post_type_support('page', array('post-thumbnails', 'page-attributes', 'custom-fields', 'comments') );
+ register_post_type( 'post', array( 'label' => __('Posts'),
+ 'exclude_from_search' => false,
+ '_builtin' => true,
+ '_edit_link' => 'post.php?post=%d',
+ 'capability_type' => 'post',
+ 'hierarchical' => false,
+ 'supports' => array('post-thumbnails', 'excerpts', 'trackbacks', 'custom-fields', 'comments', 'revisions')
+ ) );
- register_post_status( 'publish', array('label' => _x('Published', 'post'), 'exclude_from_search' => false, '_builtin' => true, 'label_count' => _n_noop('Published (%s)', 'Published (%s)')) );
- register_post_status( 'future', array('label' => _x('Scheduled', 'post'), 'exclude_from_search' => false, '_builtin' => true, 'label_count' => _n_noop('Scheduled (%s)', 'Scheduled (%s)')) );
- register_post_status( 'draft', array('label' => _x('Draft', 'post'), 'exclude_from_search' => false, '_builtin' => true, 'label_count' => _n_noop('Draft (%s)', 'Drafts (%s)')) );
- register_post_status( 'private', array('label' => _x('Private', 'post'), 'exclude_from_search' => false, '_builtin' => true, 'label_count' => _n_noop('Private (%s)', 'Private (%s)')) );
- register_post_status( 'trash', array('label' => _x('Trash', 'post'), 'exclude_from_search' => false, '_builtin' => true, 'label_count' => _n_noop('Trash (%s)', 'Trash (%s)')) );
+ register_post_type( 'page', array( 'label' => __('Pages'),
+ 'exclude_from_search' => false,
+ '_builtin' => true,
+ '_edit_link' => 'post.php?post=%d',
+ 'capability_type' => 'page',
+ 'hierarchical' => true,
+ 'supports' => array('post-thumbnails', 'page-attributes', 'custom-fields', 'comments', 'revisions')
+ ) );
+
+ register_post_type( 'attachment', array('label' => __('Media'),
+ 'exclude_from_search' => false,
+ '_builtin' => true,
+ '_edit_link' => 'media.php?attachment_id=%d',
+ 'capability_type' => 'post',
+ 'hierarchical' => false
+ ) );
+
+ register_post_type( 'revision', array( 'label' => __('Revisions'),
+ 'exclude_from_search' => true,
+ '_builtin' => true,
+ '_edit_link' => 'revision.php?revision=%d',
+ 'capability_type' => 'post',
+ 'hierarchical' => false
+ ) );
+
+ register_post_status( 'publish', array( 'label' => _x('Published', 'post'),
+ 'exclude_from_search' => false,
+ '_builtin' => true,
+ 'label_count' => _n_noop('Published (%s)', 'Published (%s)')
+ ) );
+
+ register_post_status( 'future', array( 'label' => _x('Scheduled', 'post'),
+ 'exclude_from_search' => false,
+ '_builtin' => true,
+ 'label_count' => _n_noop('Scheduled (%s)', 'Scheduled (%s)')
+ ) );
+
+ register_post_status( 'draft', array( 'label' => _x('Draft', 'post'),
+ 'exclude_from_search' => false,
+ '_builtin' => true,
+ 'label_count' => _n_noop('Draft (%s)', 'Drafts (%s)')
+ ) );
+
+ register_post_status( 'private', array( 'label' => _x('Private', 'post'),
+ 'exclude_from_search' => false,
+ '_builtin' => true,
+ 'label_count' => _n_noop('Private (%s)', 'Private (%s)')
+ ) );
+
+ register_post_status( 'trash', array( 'label' => _x('Trash', 'post'),
+ 'exclude_from_search' => false,
+ '_builtin' => true,
+ 'label_count' => _n_noop('Trash (%s)', 'Trash (%s)')
+ ) );
}
add_action( 'init', 'create_initial_post_types', 0 ); // highest priority
@@ -639,6 +690,7 @@ function get_post_types( $args = array(), $output = 'names' ) {
* inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none.
* capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post".
* hierarchical - Whether the post type is hierarchical. Defaults to false.
+ * supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none.
*
* @package WordPress
* @subpackage Post
@@ -655,7 +707,7 @@ function register_post_type($post_type, $args = array()) {
$wp_post_types = array();
// Args prefixed with an underscore are reserved for internal use.
- $defaults = array('label' => false, 'exclude_from_search' => true, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, '_show' => false);
+ $defaults = array('label' => false, 'exclude_from_search' => true, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, '_show' => false, 'supports' => array());
$args = wp_parse_args($args, $defaults);
$args = (object) $args;
@@ -676,6 +728,11 @@ function register_post_type($post_type, $args = array()) {
if ( !$args->_builtin && $args->public )
$args->_show = true;
+ if ( ! empty($args->supports) ) {
+ add_post_type_support($post_type, $args->supports);
+ unset($args->supports);
+ }
+
$wp_post_types[$post_type] = $args;
return $args;
@@ -3940,7 +3997,7 @@ function wp_save_post_revision( $post_id ) {
if ( !$post = get_post( $post_id, ARRAY_A ) )
return;
- if ( !in_array( $post['post_type'], array( 'post', 'page' ) ) )
+ if ( !post_type_supports($post['post_type'], 'revisions') )
return;
$return = _wp_put_post_revision( $post );