Ticket #24483: 24483.patch
| File 24483.patch, 3.9 KB (added by , 13 years ago) |
|---|
-
wp-admin/includes/post.php
1337 1337 $post = get_post($post_ID); 1338 1338 1339 1339 if ( 'page' == $post->post_type ) { 1340 if ( ! current_user_can('edit_page', $post_ID) )1341 wp_die( __('You are not allowed to edit this page.'));1340 if ( ! current_user_can('edit_page', $post_ID) ) 1341 wp_die( __('You are not allowed to edit this page.') ); 1342 1342 } else { 1343 if ( ! current_user_can('edit_post', $post_ID) )1344 wp_die( __('You are not allowed to edit this post.'));1343 if ( ! current_user_can('edit_post', $post_ID) ) 1344 wp_die( __('You are not allowed to edit this post.') ); 1345 1345 } 1346 1346 1347 1347 $user_id = get_current_user_id(); 1348 if ( 'draft' == $post->post_status && $user_id == $post->post_author ) { 1348 $locked = wp_check_post_lock( $post->ID ); 1349 if ( ! $locked && 'draft' == $post->post_status && $user_id == $post->post_author ) { 1349 1350 $id = edit_post(); 1350 1351 } else { // Non drafts are not overwritten. The autosave is stored in a special post revision. 1351 1352 $id = wp_create_post_autosave( $post->ID ); … … 1356 1357 if ( is_wp_error($id) ) 1357 1358 wp_die( $id->get_error_message() ); 1358 1359 1359 if ( $_POST['post_status'] == 'draft' && $user_id == $post->post_author ) {1360 if ( ! $locked && $_POST['post_status'] == 'draft' && $user_id == $post->post_author ) { 1360 1361 $url = add_query_arg( 'preview', 'true', get_permalink($id) ); 1361 1362 } else { 1362 1363 $nonce = wp_create_nonce('post_preview_' . $id); 1363 $url = add_query_arg( array( 'preview' => 'true', 'preview_id' => $id, 'preview_nonce' => $nonce ), get_permalink($id) ); 1364 $args = array( 1365 'preview' => 'true', 1366 'preview_id' => $id, 1367 'preview_nonce' => $nonce, 1368 ); 1369 1370 if ( isset( $_POST['post_format'] ) ) 1371 $args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] ); 1372 1373 $url = add_query_arg( $args, get_permalink($id) ); 1364 1374 } 1365 1375 1366 1376 return apply_filters( 'preview_post_link', $url ); -
wp-admin/js/post.js
898 898 }); 899 899 }); 900 900 }); 901 902 // When changing post formats, change the editor body class 903 $('#post-formats-select input.post-format').on( 'change.set-editor-class', function( event ) { 904 var editor, body, format = this.id; 905 906 if ( format && $( this ).prop('checked') ) { 907 editor = tinymce.get( 'content' ); 908 909 if ( editor ) { 910 body = editor.getBody(); 911 body.className = body.className.replace( /\bpost-format-[^ ]+/, '' ); 912 editor.dom.addClass( body, format == 'post-format-0' ? 'post-format-standard' : format ); 913 } 914 } 915 }); 901 916 } 902 917 }); -
wp-includes/revision.php
444 444 $post->post_title = $preview->post_title; 445 445 $post->post_excerpt = $preview->post_excerpt; 446 446 447 add_filter( 'get_the_terms', '_wp_preview_terms_filter', 10, 3 ); 448 447 449 return $post; 448 450 } 449 451 … … 466 468 } 467 469 468 470 /** 471 * Filters terms lookup to set the post format. 472 * 473 * @since 3.6.0 474 * @access private 475 */ 476 function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) { 477 if ( ! $post = get_post() ) 478 return $terms; 479 480 if ( empty( $_REQUEST['post_format'] ) || $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type ) 481 return $terms; 482 483 if ( 'standard' == $_REQUEST['post_format'] ) 484 $terms = array(); 485 elseif ( $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' ) ) 486 $terms = array( $term ); // Can only have one post format 487 488 return $terms; 489 } 490 491 /** 469 492 * Gets the post revision version. 470 493 * 471 494 * @since 3.6.0
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)