检查“帖子”屏幕上显示的帖子的锁定状态
原型
wp_check_locked_posts( array $response, array $data, string $screen_id )
参数
$response
(array)
(Required)
心跳响应。
$data
(array)
(Required)
发送了$ _POST数据。
$screen_id
(string)
(Required)
屏幕ID。
返回值
(array)
心跳响应。
源文件
路径:wp-admin/includes/misc.php
<?php
...
function wp_check_locked_posts( $response, $data, $screen_id ) {
$checked = array();
if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
foreach ( $data['wp-check-locked-posts'] as $key ) {
if ( ! $post_id = absint( substr( $key, 5 ) ) )
continue;
if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) && current_user_can( 'edit_post', $post_id ) ) {
$send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) );
if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) )
$send['avatar_src'] = $matches[1];
$checked[$key] = $send;
}
}
}
if ( ! empty( $checked ) )
$response['wp-check-locked-posts'] = $checked;
return $response;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/wp_check_locked_posts/