# extendify/3.1.5/src/Agent/hooks/useLockPost.js

Extendify, version 3.1.5. 21 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.1.5/code/src/Agent/hooks/useLockPost.js
- Raw: https://pluginprobe.com/plugins/extendify/3.1.5/raw/src/Agent/hooks/useLockPost.js
- Modified: 2026-03-24T14:55:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.1.5/code/src/Agent/hooks/useLockPost.js#L10-L20`.

```javascript
import apiFetch from '@wordpress/api-fetch';
import { useEffect } from '@wordpress/element';

export const useLockPost = ({ postId, enabled }) => {
	useEffect(() => {
		if (!postId || !enabled) return;
		let timeoutId;
		const lockPost = async () => {
			await apiFetch({
				path: '/extendify/v1/agent/lock-post',
				method: 'POST',
				data: { postId },
			}).catch(() => undefined);
			// Send lock post signal every 2 minutes (must be under WP's 150s lock expiry)
			timeoutId = setTimeout(lockPost, 2 * 60 * 1000);
		};
		lockPost();
		return () => clearTimeout(timeoutId);
	}, [postId, enabled]);
};

```
