mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Post locks: use heartbeat to dynamically update locked posts on the Posts screen, first run, see #23312
git-svn-id: https://develop.svn.wordpress.org/trunk@23487 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -561,3 +561,29 @@ function _ipad_meta() {
|
||||
}
|
||||
}
|
||||
add_action('admin_head', '_ipad_meta');
|
||||
|
||||
/**
|
||||
* Check lock status for posts displayed on the Posts screen
|
||||
*
|
||||
* @since 3.6
|
||||
*/
|
||||
function wp_check_locked_posts( $response, $data ) {
|
||||
$checked = array();
|
||||
|
||||
if ( array_key_exists( 'wp-check-locked', $data ) && is_array( $data['wp-check-locked'] ) ) {
|
||||
foreach ( $data['wp-check-locked'] as $key ) {
|
||||
$post_id = (int) substr( $key, 5 );
|
||||
|
||||
if ( current_user_can( 'edit_post', $post_id ) && ( $user_id = wp_check_post_lock( $post_id ) ) ) {
|
||||
if ( $user = get_userdata( $user_id ) )
|
||||
$checked[$key] = sprintf( __( '%s is currently editing' ), $user->display_name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $checked ) )
|
||||
$response['wp-check-locked'] = $checked;
|
||||
|
||||
return $response;
|
||||
}
|
||||
add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 2 );
|
||||
|
||||
Reference in New Issue
Block a user