Ticket #18515: 18515-2.patch
File 18515-2.patch, 2.4 KB (added by , 12 years ago) |
---|
-
wp-admin/admin-ajax.php
1545 1545 echo json_encode( array( 'message' => $message, 'last_edited' => $last_edited ) ); 1546 1546 die(); 1547 1547 break; 1548 case 'wp-remove-post-lock' : 1549 1550 $post_id = isset($_POST['post_ID']) ? (int) $_POST['post_ID'] : 0; 1551 if ( !current_user_can('edit_post', $post_id) || empty($_POST['user_ID']) ) 1552 die(); 1553 1554 $post = $post_type = null; 1555 1556 if ( $post_id ) { 1557 $post = get_post($post_id); 1558 if ( $post ) 1559 $post_type = $post->post_type; 1560 } 1561 1562 check_ajax_referer('update-' . $post_type . '_' . $post_id); 1563 1564 sleep(4); 1565 1566 if ( !$lock = get_post_meta( $post_id, '_edit_lock', true ) ) 1567 die('-1'); 1568 1569 $lock = explode( ':', $lock ); 1570 $user_id = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post_id, '_edit_last', true ); 1571 $locked = (int) $lock[0]; 1572 1573 if ( time() - $locked < 5 ) // give a few seconds for the lock to be refreshed if the user reloaded the page 1574 die('0'); 1575 1576 if ( $user_id == $_POST['user_ID'] ) 1577 delete_post_meta( $post_id, '_edit_lock' ); 1578 1579 die('1'); 1580 break; 1548 1581 default : 1549 1582 do_action( 'wp_ajax_' . $_POST['action'] ); 1550 1583 die('0'); -
wp-admin/js/post.dev.js
643 643 } 644 644 645 645 wptitlehint(); 646 647 // remove the post lock on unload 648 $(window).unload(function() { 649 $.ajax({ 650 type: 'POST', 651 url: ajaxurl, 652 data: { 653 action: 'wp-remove-post-lock', 654 _wpnonce: $('#_wpnonce').val(), 655 post_ID: $('#post_ID').val(), 656 user_ID: $('#user_ID').val() 657 } 658 }); 659 }); 646 660 }); -
wp-includes/script-loader.php
281 281 282 282 $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20110822', 1 ); 283 283 284 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20110 524', 1 );284 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20110824', 1 ); 285 285 $scripts->add_script_data( 'post', 'postL10n', array( 286 286 'ok' => __('OK'), 287 287 'cancel' => __('Cancel'),