On this page
wp_check_locked_posts( array $response, array $data, string $screen_id ): array
Checks lock status for posts displayed on the Posts screen.
Parameters
$responsearray Required-
The Heartbeat response.
$dataarray Required-
The $_POST data sent.
$screen_idstring Required-
The screen ID.
Return
array The Heartbeat response.
Source
File: wp-admin/includes/misc.php. View all references
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 ) {
$post_id = absint( substr( $key, 5 ) );
if ( ! $post_id ) {
continue;
}
$user_id = wp_check_post_lock( $post_id );
if ( $user_id ) {
$user = get_userdata( $user_id );
if ( $user && current_user_can( 'edit_post', $post_id ) ) {
$send = array(
'name' => $user->display_name,
/* translators: %s: User's display name. */
'text' => sprintf( __( '%s is currently editing' ), $user->display_name ),
);
if ( get_option( 'show_avatars' ) ) {
$send['avatar_src'] = get_avatar_url( $user->ID, array( 'size' => 18 ) );
$send['avatar_src_2x'] = get_avatar_url( $user->ID, array( 'size' => 36 ) );
}
$checked[ $key ] = $send;
}
}
}
}
if ( ! empty( $checked ) ) {
$response['wp-check-locked-posts'] = $checked;
}
return $response;
}
Related
Uses
| Uses | Description |
|---|---|
| get_avatar_url() wp-includes/link-template.php | Retrieves the avatar URL. |
| wp_check_post_lock() wp-admin/includes/post.php | Determines whether the post is currently being edited by another user. |
| current_user_can() wp-includes/capabilities.php | Returns whether the current user has the specified capability. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| get_userdata() wp-includes/pluggable.php | Retrieves user info by user ID. |
| absint() wp-includes/functions.php | Converts a value to non-negative integer. |
| get_option() wp-includes/option.php | Retrieves an option value based on an option name. |
Changelog
| Version | Description |
|---|---|
| 3.6.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_check_locked_posts