Ticket #23314: 23314.5.diff
File 23314.5.diff, 17.3 KB (added by , 9 years ago) |
---|
-
wp-admin/css/common.css
872 872 line-height: 23px; 873 873 } 874 874 875 #publishing-action .spinner { 875 #major-publishing-actions .spinner, 876 #minor-publishing-actions .spinner { 876 877 float: left; 878 margin: 4px 1px; 877 879 } 878 880 879 881 #misc-publishing-actions { -
wp-admin/edit-form-advanced.php
55 55 remove_post_type_support( $post_type, 'editor' ); 56 56 } 57 57 58 $is_advanced_revision = false; 59 if ( 'revision' == $post->post_type ) { 60 $parent = get_post( $post->post_parent ); 61 if ( isset( $parent->post_type ) && post_type_supports( $parent->post_type, 'advanced-revisions' ) ) { 62 $is_advanced_revision = true; 63 } 64 } 65 58 66 $thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ); 59 67 if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) { 60 68 if ( wp_attachment_is( 'audio', $post ) ) { … … 123 131 8 => __( 'Post submitted.' ) . $preview_link_html, 124 132 9 => sprintf( __( 'Post scheduled for: <strong>%1$s</strong>' ), $scheduled_date ) . $scheduled_link_html, 125 133 10 => __( 'Post draft updated.' ) . $preview_link_html, 134 11 => __( 'A new version of this post has been created, but not published.' ), 135 12 => __( 'Your changes have been saved, but not published.' ), 136 13 => sprintf( __( 'Your changes have been saved and published. <a href="%s">View post</a>' ), esc_url( get_permalink( $post_ID ) ) ), 137 14 => __( 'Your changes have been discarded.' ), 126 138 ); 127 139 128 140 /** This filter is documented in wp-admin/includes/meta-boxes.php */ … … 140 152 8 => sprintf( __('Page submitted. <a target="_blank" href="%s">Preview page</a>'), esc_url( $page_preview_url ) ), 141 153 9 => sprintf( __('Page scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview page</a>'), date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_date ) ), esc_url( $permalink ) ), 142 154 10 => sprintf( __('Page draft updated. <a target="_blank" href="%s">Preview page</a>'), esc_url( $page_preview_url ) ), 155 11 => __( 'A new version of this page has been created, but not published.' ), 156 12 => __( 'Your changes have been saved, but not published.' ), 157 13 => sprintf( __( 'Your changes have been saved and published. <a href="%s">View page</a>' ), esc_url( get_permalink( $post_ID ) ) ), 158 14 => __( 'Your changes have been discarded.' ), 143 159 ); 144 160 $messages['attachment'] = array_fill( 1, 10, __( 'Media attachment updated.' ) ); // Hack, for now. 145 161 … … 246 262 if ( $thumbnail_support && current_user_can( 'upload_files' ) ) 247 263 add_meta_box('postimagediv', esc_html( $post_type_object->labels->featured_image ), 'post_thumbnail_meta_box', null, 'side', 'low'); 248 264 249 if ( post_type_supports($post_type, 'excerpt') )265 if ( post_type_supports($post_type, 'excerpt') || ( $is_advanced_revision && post_type_supports( $parent->post_type, 'excerpt' ) ) ) 250 266 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', null, 'normal', 'core'); 251 267 252 268 if ( post_type_supports($post_type, 'trackbacks') ) … … 271 287 if ( ( 'publish' == get_post_status( $post ) || 'private' == get_post_status( $post ) ) && post_type_supports($post_type, 'comments') ) 272 288 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core'); 273 289 274 if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) )290 if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) && ! $is_advanced_revision ) 275 291 add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core'); 276 292 277 if ( post_type_supports($post_type, 'author') ) {293 if ( post_type_supports($post_type, 'author') && ! $is_advanced_revision ) { 278 294 if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) 279 295 add_meta_box('authordiv', __('Author'), 'post_author_meta_box', null, 'normal', 'core'); 280 296 } … … 503 519 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> 504 520 <div id="post-body-content"> 505 521 506 <?php if ( post_type_supports( $post_type, 'title') ) { ?>522 <?php if ( post_type_supports( $post_type, 'title' ) || ( $is_advanced_revision && post_type_supports( $parent->post_type, 'title' ) ) ) { ?> 507 523 <div id="titlediv"> 508 524 <div id="titlewrap"> 509 525 <?php … … 568 584 */ 569 585 do_action( 'edit_form_after_title', $post ); 570 586 571 if ( post_type_supports( $post_type, 'editor') ) {587 if ( post_type_supports( $post_type, 'editor' ) || ( $is_advanced_revision && post_type_supports( $parent->post_type, 'editor' ) ) ) { 572 588 ?> 573 589 <div id="postdivrich" class="postarea<?php if ( $_wp_editor_expand ) { echo ' wp-editor-expand'; } ?>"> 574 590 -
wp-admin/includes/meta-boxes.php
17 17 $post_type = $post->post_type; 18 18 $post_type_object = get_post_type_object($post_type); 19 19 $can_publish = current_user_can($post_type_object->cap->publish_posts); 20 21 $is_advanced_revision = false; 22 if ( 'revision' == $post->post_type && $post->post_parent ) { 23 $parent = get_post( $post->post_parent ); 24 $is_advanced_revision = post_type_supports( $parent->post_type, 'advanced-revisions' ); 25 } 20 26 ?> 21 27 <div class="submitbox" id="submitpost"> 22 28 … … 29 35 30 36 <div id="minor-publishing-actions"> 31 37 <div id="save-action"> 32 <?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> 38 <?php if ( $is_advanced_revision ) { ?> 39 <input type="submit" name="save" id="save-post" value="<?php esc_attr_e( 'Save Changes' ); ?>" class="button" /> 40 <?php } elseif ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> 33 41 <input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" class="button" /> 34 42 <span class="spinner"></span> 35 43 <?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?> 36 44 <input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" class="button" /> 45 <?php } elseif ( 'publish' == $post->post_status && post_type_supports( $post->post_type, 'advanced-revisions' ) ) { ?> 46 <input type="submit" name="save-version" id="save-post" value="<?php esc_attr_e( 'Save a Version' ); ?>" class="button" /> 37 47 <span class="spinner"></span> 38 48 <?php } ?> 39 49 </div> 40 <?php if ( is_post_type_viewable( $post_type_object )) : ?>50 <?php if ( $post_type_object->public || $is_advanced_revision ) : ?> 41 51 <div id="preview-action"> 42 52 <?php 43 53 if ( 'publish' == $post->post_status ) { … … 56 66 * @param WP_Post $post Post object. 57 67 */ 58 68 $preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post ) ); 59 $preview_button = __( 'Preview' );69 $preview_button = ( $is_advanced_revision ) ? __( 'Preview Changes' ) : __( 'Preview' ); 60 70 } 61 71 ?> 62 72 <a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview-<?php echo (int) $post->ID; ?>" id="post-preview"><?php echo $preview_button; ?></a> … … 67 77 </div><!-- #minor-publishing-actions --> 68 78 69 79 <div id="misc-publishing-actions"> 80 <?php if ( $is_advanced_revision ) : ?> 81 <?php else: ?> 70 82 71 83 <div class="misc-pub-section misc-pub-post-status"><label for="post_status"><?php _e('Status:') ?></label> 72 84 <span id="post-status-display"> … … 222 234 */ 223 235 do_action( 'post_submitbox_misc_actions' ); 224 236 ?> 225 </div> 237 <?php endif; // $is_advanced_revision ?> 238 </div><!-- #misc-publishing-actions --> 226 239 <div class="clear"></div> 227 240 </div> 228 241 … … 242 255 $delete_text = __('Delete Permanently'); 243 256 else 244 257 $delete_text = __('Move to Trash'); 258 259 $delete_link = get_delete_post_link( $post->ID ); 260 if ( $is_advanced_revision ) { 261 $delete_text = __( 'Discard Changes' ); 262 $delete_link = add_query_arg( 'post', $post->ID, get_delete_post_link( $post->post_parent, '', true ) ); 263 $delete_link = wp_nonce_url( $delete_link, "delete-post_{$post->ID}" ); 264 } 245 265 ?> 246 <a class="submitdelete deletion" href="<?php echo get_delete_post_link($post->ID); ?>"><?php echo $delete_text; ?></a><?php266 <a class="submitdelete deletion" href="<?php echo esc_url( $delete_link ); ?>"><?php echo esc_html( $delete_text ); ?></a><?php 247 267 } ?> 248 268 </div> 249 269 … … 256 276 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" /> 257 277 <?php submit_button( __( 'Schedule' ), 'primary button-large', 'publish', false ); ?> 258 278 <?php else : ?> 279 <?php $publish_label = ( $is_advanced_revision ) ? __( 'Publish Changes' ) : __( 'Publish' ); ?> 280 <?php if ( $is_advanced_revision ) : ?> 281 <input name="publish_revision" type="hidden" value="1" /> 282 <?php endif; ?> 259 283 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" /> 260 <?php submit_button( __( 'Publish' ), 'primary button-large', 'publish', false); ?>284 <?php submit_button( $publish_label, 'primary button-large', 'publish', false, array( 'accesskey' => 'p' ) ); ?> 261 285 <?php endif; 262 286 else : ?> 263 287 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" /> -
wp-admin/includes/post.php
200 200 } 201 201 } 202 202 203 $is_advanced_revision = false; 204 if ( 'revision' == $post->post_type ) { 205 $parent = get_post( $post->post_parent ); 206 if ( isset( $parent->post_type ) && post_type_supports( $parent->post_type, 'advanced-revisions' ) ) { 207 $is_advanced_revision = true; 208 } 209 } 210 203 211 $ptype = get_post_type_object($post_data['post_type']); 204 212 if ( !current_user_can( 'edit_post', $post_ID ) ) { 205 213 if ( 'page' == $post_data['post_type'] ) … … 366 374 367 375 update_post_meta( $post_ID, '_edit_last', get_current_user_id() ); 368 376 369 $success = wp_update_post( $post_data ); 377 if ( ! empty( $_POST['save-version'] ) && post_type_supports( $post->post_type, 'advanced-revisions' ) ) { 378 unset( $post_data['post_ID'], $post_data['ID'] ); 379 $post_data['post_type'] = 'revision'; 380 $post_data['post_parent'] = $post_ID; 381 $post_data['post_status'] = 'draft'; 382 } 383 384 if ( ! empty( $_POST['publish'] ) && $is_advanced_revision ) { 385 if ( ! current_user_can( 'edit_post', $parent->ID ) ) 386 wp_die( __( 'You are not allowed to edit this post.' ) ); 387 388 unset( $post_data['post_parent'] ); 389 $post_data['post_type'] = $parent->post_type; 390 $post_data['post_status'] = $parent->post_status; 391 $post_data['ID'] = $parent->ID; 392 $post_data['post_ID'] = $parent->ID; 393 394 // Discard the revision 395 wp_delete_post( $post->ID, true ); 396 } 397 398 $post_ID = ( ! empty( $post_data['ID'] ) ) ? wp_update_post( $post_data ) : wp_insert_post( $post_data ); 399 400 370 401 // If the save failed, see if we can sanity check the main fields and try again 371 if ( ! $success&& is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) {402 if ( ( ! $post_ID || 0 === $post_ID ) && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) { 372 403 $fields = array( 'post_title', 'post_content', 'post_excerpt' ); 373 404 374 405 foreach ( $fields as $field ) { … … 1686 1717 $post_ID = (int) $_POST['post_ID']; 1687 1718 $_POST['ID'] = $post_ID; 1688 1719 1720 $parent = null; 1721 $is_advanced_revision = null; 1689 1722 if ( ! $post = get_post( $post_ID ) ) { 1690 1723 wp_die( __( 'You are not allowed to edit this post.' ) ); 1691 1724 } … … 1694 1727 wp_die( __( 'You are not allowed to edit this post.' ) ); 1695 1728 } 1696 1729 1730 if ( 'revision' == $post->post_type ) { 1731 $parent = get_post( $post->post_parent ); 1732 if ( isset( $parent->post_type ) && post_type_supports( $parent->post_type, 'advanced-revisions' ) ) { 1733 $is_advanced_revision = true; 1734 } 1735 } 1736 1697 1737 $is_autosave = false; 1698 1738 1739 if ( $is_advanced_revision ) { 1740 $nonce = wp_create_nonce( 'post_preview_' . $post->ID ); 1741 $url = add_query_arg( array( 'preview' => 'true', 'preview_id' => $post->ID, 'preview_nonce' => $nonce ), get_permalink( $parent->ID ) ); 1742 return apply_filters( 'preview_post_link', $url, $post ); 1743 } 1744 1699 1745 if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'draft' == $post->post_status || 'auto-draft' == $post->post_status ) ) { 1700 1746 $saved_post_id = edit_post(); 1701 1747 } else { -
wp-admin/post.php
36 36 if ( $post ) { 37 37 $post_type = $post->post_type; 38 38 $post_type_object = get_post_type_object( $post_type ); 39 40 if ( post_type_supports( $post_type, 'advanced-revisions' ) ) { 41 $revisions = get_posts( array( 42 'post_parent' => $post->ID, 43 'post_type' => 'revision', 44 'post_status' => array( 'draft' ), 45 ) ); 46 47 if ( ! empty( $revisions ) && is_array( $revisions ) ) { 48 $revision = $revisions[0]; 49 if ( current_user_can( 'edit_post', $revision->ID ) ) 50 redirect_post( $revision->ID ); 51 } 52 } 39 53 } 40 54 41 55 /** … … 44 58 * @param int $post_id Optional. Post ID. 45 59 */ 46 60 function redirect_post($post_id = '') { 47 if ( isset($_POST['save']) || isset($_POST['publish']) ) { 61 $post = get_post( $post_id ); 62 63 $is_advanced_revision = false; 64 if ( 'revision' == $post->post_type ) { 65 $parent = get_post( $post->post_parent ); 66 if ( isset( $parent->post_type ) && post_type_supports( $parent->post_type, 'advanced-revisions' ) ) { 67 $is_advanced_revision = true; 68 } 69 } 70 71 if ( ( isset( $_POST['save'] ) || isset( $_POST['publish'] ) ) && ! $is_advanced_revision ) { 48 72 $status = get_post_status( $post_id ); 49 73 50 74 if ( isset( $_POST['publish'] ) ) { … … 62 86 $message = 'draft' == $status ? 10 : 1; 63 87 } 64 88 89 if ( ! empty( $_POST['publish_revision'] ) ) 90 $message = 13; 91 65 92 $location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) ); 66 93 } elseif ( isset($_POST['addmeta']) && $_POST['addmeta'] ) { 67 94 $location = add_query_arg( 'message', 2, wp_get_referer() ); … … 71 98 $location = add_query_arg( 'message', 3, wp_get_referer() ); 72 99 $location = explode('#', $location); 73 100 $location = $location[0] . '#postcustom'; 101 } elseif ( $is_advanced_revision ) { 102 $location = add_query_arg( 'post', $post->ID, get_edit_post_link( $parent->ID, 'url' ) ); 103 104 if ( ! empty( $_POST['save-version'] ) ) { 105 $message = 11; 106 } elseif ( ! empty( $_POST['save'] ) ) { 107 $message = 12; 108 } 109 110 if ( $message ) { 111 $location = add_query_arg( 'message', $message, $location ); 112 } 113 74 114 } else { 75 115 $location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) ); 76 116 } … … 309 349 wp_die( __( 'Error in deleting.' ) ); 310 350 } 311 351 352 if ( 'revision' == $post->post_type ) { 353 $parent = get_post( $post->post_parent ); 354 $sendback = get_edit_post_link( $post->post_parent, 'url' ); 355 $sendback = add_query_arg( 'message', 14, $sendback ); 356 } 357 312 358 wp_redirect( add_query_arg('deleted', 1, $sendback) ); 313 359 exit(); 314 360 -
wp-includes/post-functions.php
31 31 'rewrite' => false, 32 32 'query_var' => false, 33 33 'delete_with_user' => true, 34 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', ' post-formats' ),34 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'advanced-revisions', 'post-formats' ), 35 35 ) ); 36 36 37 37 register_post_type( 'page', array( … … 49 49 'rewrite' => false, 50 50 'query_var' => false, 51 51 'delete_with_user' => true, 52 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ),52 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions', 'advanced-revisions' ), 53 53 ) ); 54 54 55 55 register_post_type( 'attachment', array( … … 83 83 'labels' => array( 84 84 'name' => __( 'Revisions' ), 85 85 'singular_name' => __( 'Revision' ), 86 'edit_item' => __( 'Edit Revision' ), 86 87 ), 87 88 'public' => false, 88 89 '_builtin' => true, /* internal use only. don't use this when registering your own post type. */ -
wp-includes/revision.php
497 497 } 498 498 499 499 $preview = wp_get_post_autosave( $post->ID ); 500 501 // Possibly previewing a revision. 502 if ( isset( $_GET['preview_id'] ) ) { 503 $preview_id = (int) $_GET['preview_id']; 504 if ( ( ! $preview || $preview->ID != $preview_id ) && current_user_can( 'read_post', $preview_id ) ) { 505 $revision = get_post( $preview_id ); 506 if ( 'revision' == $revision->post_type && $revision->post_parent == $post->ID ) { 507 $preview = $revision; 508 } 509 } 510 } 511 500 512 if ( ! is_object( $preview ) ) { 501 513 return $post; 502 514 }