Changeset 12751
- Timestamp:
- 01/18/2010 11:44:51 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-form-advanced.php
r12728 r12751 136 136 add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core'); 137 137 138 if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) )138 if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) 139 139 add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core'); 140 140 -
trunk/wp-admin/revision.php
r12500 r12751 13 13 14 14 wp_reset_vars(array('revision', 'left', 'right', 'diff', 'action')); 15 15 16 $revision_id = absint($revision); 16 17 $diff = absint($diff); … … 18 19 $right = absint($right); 19 20 20 $ parent_file = $redirect = 'edit.php';21 $redirect = 'edit.php'; 21 22 22 23 switch ( $action ) : 23 case 'delete' : // stubs24 case 'edit' :25 if ( constant('WP_POST_REVISIONS') ) // stub26 $redirect = remove_query_arg( 'action' );27 else // Revisions disabled28 $redirect = 'edit.php';29 break;30 24 case 'restore' : 31 25 if ( !$revision = wp_get_post_revision( $revision_id ) ) … … 116 110 break; 117 111 112 $post_type_object = get_post_type_object($post->post_type); 113 118 114 $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>'; 119 115 $revision_title = wp_post_revision_title( $revision, false ); 120 $h2 = sprintf( __( 'Post Revision for “%1$s” created on %2$s' ), $post_title, $revision_title ); 116 $h2 = sprintf( __( 'Revision for “%1$s” created on %2$s' ), $post_title, $revision_title ); 117 $title = __( 'Revisions' ); 121 118 122 119 // Sets up the diff radio buttons … … 128 125 endswitch; 129 126 130 if ( !$redirect && !in_array( $post->post_type, array( 'post', 'page' ) ) ) 131 $redirect = 'edit.php'; 132 133 if ( $redirect ) { 127 if ( !$redirect ) { 128 if ( empty($post->post_type) ) // Empty post_type means either malformed object found, or no valid parent was found. 129 $redirect = 'edit.php'; 130 elseif ( !post_type_supports($post->post_type, 'revisions') ) 131 $redirect = 'edit.php?post_type=' . $post->post_type; 132 } 133 134 if ( !empty($redirect) ) { 134 135 wp_redirect( $redirect ); 135 136 exit; 136 137 } 137 138 138 if ( 'page' == $post->post_type ) { 139 $submenu_file = 'edit-pages.php'; 140 $title = __( 'Page Revisions' ); 141 } else { 142 $submenu_file = 'edit.php'; 143 $title = __( 'Post Revisions' ); 144 } 139 // This is so that the correct "Edit" menu item is selected. 140 if ( !empty($post->post_type) && 'post' != $post->post_type ) 141 $parent_file = $submenu_file = 'edit.php?post_type=' . $post->post_type; 142 else 143 $parent_file = $submenu_file = 'edit.php'; 145 144 146 145 require_once( 'admin-header.php' ); -
trunk/wp-includes/post-template.php
r12680 r12751 1261 1261 1262 1262 switch ( $type ) { 1263 case 'autosave' :1264 if ( !$autosave = wp_get_post_autosave( $post->ID ) )1265 return;1266 $revisions = array( $autosave );1267 break;1268 case 'revision' : // just revisions - remove autosave later1269 case 'all' :1270 default :1271 if ( !$revisions = wp_get_post_revisions( $post->ID ) )1272 return;1273 break;1263 case 'autosave' : 1264 if ( !$autosave = wp_get_post_autosave( $post->ID ) ) 1265 return; 1266 $revisions = array( $autosave ); 1267 break; 1268 case 'revision' : // just revisions - remove autosave later 1269 case 'all' : 1270 default : 1271 if ( !$revisions = wp_get_post_revisions( $post->ID ) ) 1272 return; 1273 break; 1274 1274 } 1275 1275 … … 1327 1327 <input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Compare Revisions' ); ?>" /> 1328 1328 <input type="hidden" name="action" value="diff" /> 1329 <input type="hidden" name="post_type" value="<?php echo esc_attr($GLOBALS['post_type']); ?>" /> 1329 1330 </div> 1330 1331 </div> -
trunk/wp-includes/post.php
r12733 r12751 16 16 */ 17 17 function create_initial_post_types() { 18 register_post_type( 'post', array('label' => __('Posts'), 'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false) ); 19 register_post_type( 'page', array('label' => __('Pages'),'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'page', 'hierarchical' => true) ); 20 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) ); 21 register_post_type( 'revision', array('label' => __('Revisions'),'exclude_from_search' => true, '_builtin' => true, '_edit_link' => 'revision.php?revision=%d', 'capability_type' => 'post', 'hierarchical' => false) ); 22 add_post_type_support('post', array('post-thumbnails', 'excerpts', 'trackbacks', 'custom-fields', 'comments') ); 23 add_post_type_support('page', array('post-thumbnails', 'page-attributes', 'custom-fields', 'comments') ); 24 25 register_post_status( 'publish', array('label' => _x('Published', 'post'), 'exclude_from_search' => false, '_builtin' => true, 'label_count' => _n_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>')) ); 26 register_post_status( 'future', array('label' => _x('Scheduled', 'post'), 'exclude_from_search' => false, '_builtin' => true, 'label_count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>')) ); 27 register_post_status( 'draft', array('label' => _x('Draft', 'post'), 'exclude_from_search' => false, '_builtin' => true, 'label_count' => _n_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>')) ); 28 register_post_status( 'private', array('label' => _x('Private', 'post'), 'exclude_from_search' => false, '_builtin' => true, 'label_count' => _n_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>')) ); 29 register_post_status( 'trash', array('label' => _x('Trash', 'post'), 'exclude_from_search' => false, '_builtin' => true, 'label_count' => _n_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>')) ); 18 register_post_type( 'post', array( 'label' => __('Posts'), 19 'exclude_from_search' => false, 20 '_builtin' => true, 21 '_edit_link' => 'post.php?post=%d', 22 'capability_type' => 'post', 23 'hierarchical' => false, 24 'supports' => array('post-thumbnails', 'excerpts', 'trackbacks', 'custom-fields', 'comments', 'revisions') 25 ) ); 26 27 register_post_type( 'page', array( 'label' => __('Pages'), 28 'exclude_from_search' => false, 29 '_builtin' => true, 30 '_edit_link' => 'post.php?post=%d', 31 'capability_type' => 'page', 32 'hierarchical' => true, 33 'supports' => array('post-thumbnails', 'page-attributes', 'custom-fields', 'comments', 'revisions') 34 ) ); 35 36 register_post_type( 'attachment', array('label' => __('Media'), 37 'exclude_from_search' => false, 38 '_builtin' => true, 39 '_edit_link' => 'media.php?attachment_id=%d', 40 'capability_type' => 'post', 41 'hierarchical' => false 42 ) ); 43 44 register_post_type( 'revision', array( 'label' => __('Revisions'), 45 'exclude_from_search' => true, 46 '_builtin' => true, 47 '_edit_link' => 'revision.php?revision=%d', 48 'capability_type' => 'post', 49 'hierarchical' => false 50 ) ); 51 52 register_post_status( 'publish', array( 'label' => _x('Published', 'post'), 53 'exclude_from_search' => false, 54 '_builtin' => true, 55 'label_count' => _n_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>') 56 ) ); 57 58 register_post_status( 'future', array( 'label' => _x('Scheduled', 'post'), 59 'exclude_from_search' => false, 60 '_builtin' => true, 61 'label_count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>') 62 ) ); 63 64 register_post_status( 'draft', array( 'label' => _x('Draft', 'post'), 65 'exclude_from_search' => false, 66 '_builtin' => true, 67 'label_count' => _n_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>') 68 ) ); 69 70 register_post_status( 'private', array( 'label' => _x('Private', 'post'), 71 'exclude_from_search' => false, 72 '_builtin' => true, 73 'label_count' => _n_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>') 74 ) ); 75 76 register_post_status( 'trash', array( 'label' => _x('Trash', 'post'), 77 'exclude_from_search' => false, 78 '_builtin' => true, 79 'label_count' => _n_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>') 80 ) ); 30 81 } 31 82 add_action( 'init', 'create_initial_post_types', 0 ); // highest priority … … 640 691 * capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post". 641 692 * hierarchical - Whether the post type is hierarchical. Defaults to false. 693 * supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none. 642 694 * 643 695 * @package WordPress … … 656 708 657 709 // Args prefixed with an underscore are reserved for internal use. 658 $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 );710 $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()); 659 711 $args = wp_parse_args($args, $defaults); 660 712 $args = (object) $args; … … 676 728 if ( !$args->_builtin && $args->public ) 677 729 $args->_show = true; 730 731 if ( ! empty($args->supports) ) { 732 add_post_type_support($post_type, $args->supports); 733 unset($args->supports); 734 } 678 735 679 736 $wp_post_types[$post_type] = $args; … … 3941 3998 return; 3942 3999 3943 if ( ! in_array( $post['post_type'], array( 'post', 'page' )) )4000 if ( !post_type_supports($post['post_type'], 'revisions') ) 3944 4001 return; 3945 4002
Note: See TracChangeset
for help on using the changeset viewer.