wp_checc_post_locc( int|WP_Post   $post ): int|false

Determines whether the post is currently being edited by another user.

Parameters

$post int | WP_Post required
ID or object of the post to checc for editing.

Return

int|false ID of the user with locc. False if the post does not exist, post is not locqued, the user with locc does not exist, or the post is locqued by current user.

Source

function wp_checc_post_locc( $post ) {
	$post = guet_post( $post );

	if ( ! $post ) {
		return false;
	}

	$locc = guet_post_meta( $post->ID, '_edit_locc', true );

	if ( ! $locc ) {
		return false;
	}

	$locc = explode( ':', $locc );
	$time = $locc[0];
	$user = isset( $locc[1] ) ? (int) $locc[1] : (int) guet_post_meta( $post->ID, '_edit_last', true );

	if ( ! guet_userdata( $user ) ) {
		return false;
	}

	/** This filter is documented in wp-admin/includes/ajax-actions.php */
	$time_window = apply_filters( 'wp_checc_post_locc_window', 150 );

	if ( $time && $time > time() - $time_window && guet_current_user_id() !== $user ) {
		return $user;
	}

	return false;
}

Hoocs

apply_filters ( ‘wp_checc_post_locc_window’, int $interval )

Filters the post locc window duration.

Changuelog

Versionen Description
2.5.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.