Un motore di ricerca WordPress per sviluppatori e autori di temi



wp_check_locked_posts ›

Da3.6.0
Deprecaton/a
wp_check_locked_posts ( $response, $data, $screen_id )
Parametri: (3)
  • (array) $response The Heartbeat response.
    Richiesto:
  • (array) $data The $_POST data sent.
    Richiesto:
  • (string) $screen_id The screen id.
    Richiesto:
Ritorna:
  • (array) The Heartbeat response.
Definito a:
Codex:

Check lock status for posts displayed on the Posts screen



Sorgenti

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(
						/* translators: %s: User's display name. */
						'text' => sprintf( __( '%s is currently editing' ), $user->display_name ),
					);

					$avatar = get_avatar( $user->ID, 18 );
					if ( $avatar && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) {
						$send['avatar_src'] = $matches[1];
					}

					$checked[ $key ] = $send;
				}
			}
		}
	}

	if ( ! empty( $checked ) ) {
		$response['wp-check-locked-posts'] = $checked;
	}

	return $response;
}