Ticket #11703: 11703.2.diff
| File 11703.2.diff, 9.1 KB (added by , 16 years ago) |
|---|
-
wp-admin/edit-form-advanced.php
135 135 if ( $authors && count( $authors ) > 1 ) 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 141 141 do_action('do_meta_boxes', $post_type, 'normal', $post); -
wp-admin/revision.php
11 11 12 12 wp_enqueue_script('list-revisions'); 13 13 14 wp_reset_vars(array('revision', 'left', 'right', 'diff', 'action')); 14 wp_reset_vars(array('revision', 'left', 'right', 'diff', 'action', 'post_type')); 15 16 if ( empty($post_type) ) 17 $post_type = 'post'; 18 19 if ( 'post' != $post_type ) 20 $parent_file = $submenu_file = $redirect = "edit.php?post_type=$post_type"; 21 else 22 $parent_file = $submenu_file = $redirect = 'edit.php'; 23 15 24 $revision_id = absint($revision); 16 25 $diff = absint($diff); 17 26 $left = absint($left); 18 27 $right = absint($right); 19 28 20 $parent_file = $redirect = 'edit.php';21 22 29 switch ( $action ) : 23 30 case 'delete' : // stubs 24 31 case 'edit' : … … 115 122 if ( !constant('WP_POST_REVISIONS') && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave 116 123 break; 117 124 125 $post_type_object = get_post_type_object($post->post_type); 126 118 127 $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>'; 119 128 $revision_title = wp_post_revision_title( $revision, false ); 120 $h2 = sprintf( __( 'Post Revision for “%1$s” created on %2$s' ), $post_title, $revision_title ); 129 $h2 = sprintf( __( '%s Revision for “%1$s” created on %2$s' ), $post_type_object->label, $post_title, $revision_title ); // @TODO singular? for post_type 130 $title = sprintf(__( '%s Revisions' ), $post_type_object->label ); // @TODO singular? for post_type 121 131 122 132 // Sets up the diff radio buttons 123 133 $left = $revision->ID; … … 127 137 break; 128 138 endswitch; 129 139 130 if ( !$redirect && ! in_array( $post->post_type, array( 'post', 'page' )) )131 $redirect = 'edit.php';140 if ( !$redirect && !post_type_supports($post_type, 'revisions') ) 141 $redirect = "edit.php?post_type=$post_type"; 132 142 133 143 if ( $redirect ) { 134 144 wp_redirect( $redirect ); 135 145 exit; 136 146 } 137 147 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 }145 146 148 require_once( 'admin-header.php' ); 147 149 148 150 ?> -
wp-includes/link-template.php
689 689 if ( !current_user_can( $post_type_object->edit_cap, $post->ID ) ) 690 690 return; 691 691 692 return apply_filters( 'get_edit_post_link', admin_url( sprintf($post_type_object->_edit_link . $action, $post->ID) ), $post->ID, $context ); 692 if ( 'revision' == $post->post_type && $revision_parent = get_post($post->post_parent) ) { 693 $url = admin_url( sprintf($post_type_object->_edit_link . $action, $revision_parent->post_type, $post->ID) ); 694 } else { 695 $url = admin_url( sprintf($post_type_object->_edit_link . $action, $post->ID) ); 696 } 697 698 return apply_filters( 'get_edit_post_link', $url, $post->ID, $context ); 693 699 } 694 700 695 701 /** -
wp-includes/post-template.php
1260 1260 extract( wp_parse_args( $args, $defaults ), EXTR_SKIP ); 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 1276 1276 /* translators: post revision: 1: when, 2: author name */ … … 1326 1326 <div class="alignleft"> 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> 1331 1332 -
wp-includes/post.php
15 15 * Creates the initial post types when 'init' action is fired. 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') ); 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, 'supports' => array('post-thumbnails', 'excerpts', 'trackbacks', 'custom-fields', 'comments', 'revisions') ) ); 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, 'supports' => array('post-thumbnails', 'page-attributes', 'custom-fields', 'comments', 'revisions')) ); 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?post_type=%s&revision=%d', 'capability_type' => 'post', 'hierarchical' => false) ); 24 22 25 23 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 24 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>')) ); … … 655 653 $wp_post_types = array(); 656 654 657 655 // 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 );656 $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, 'support' => array()); 659 657 $args = wp_parse_args($args, $defaults); 660 658 $args = (object) $args; 661 659 … … 676 674 if ( !$args->_builtin && $args->public ) 677 675 $args->_show = true; 678 676 677 if ( ! empty($args->supports) ) { 678 add_post_type_support($post_type, $args->supports); 679 unset($args->supports); 680 } 681 679 682 $wp_post_types[$post_type] = $args; 680 683 681 684 return $args; … … 3940 3943 if ( !$post = get_post( $post_id, ARRAY_A ) ) 3941 3944 return; 3942 3945 3943 if ( ! in_array( $post['post_type'], array( 'post', 'page' )) )3946 if ( !post_type_supports($post['post_type'], 'revisions') ) 3944 3947 return; 3945 3948 3946 3949 $return = _wp_put_post_revision( $post );