# Single Tab Post Lock

**Contributors:** wpsqr  
**Tags:** post lock, editor, workflow, prevent overwrite
**Requires at least:** 5.2  
**Tested up to:** 6.8  
**Requires PHP:** 7.2  
**Stable tag:** 1.0.0  
**License:** GPLv2  
**License URI:** [https://www.gnu.org/licenses/gpl-2.0.html](https://www.gnu.org/licenses/gpl-2.0.html)

Prevent editing the same post in multiple tabs by the same user. Avoid conflicts, overwrites, and lost changes.

---

## Description

**Single-Tab Post Lock** is a lightweight WordPress plugin that ensures you don’t accidentally open and edit the same post in multiple browser tabs at once.  

While WordPress has a built-in post lock to stop **different users** from editing the same post simultaneously, it does not prevent **one user** from opening the same post across multiple tabs — leading to conflicts, lost changes, and overwrites.  

This plugin solves that problem by creating a **single-tab editing lock**. If you try to open the same post in another tab, you’ll see a warning message, and the editor will block duplicate access.

### Key Features
- **Single-Tab Editing:** Prevents duplicate editing of the same post by the same user.  
- **Auto-Cleanup:** Locks automatically clear when you close or leave the editor.  
- **Safe Timeout:** Locks expire after 30 minutes to handle crashes or session issues.  
- **Lightweight & Non-Intrusive:** Runs entirely in the browser using JavaScript.  
- **Gutenberg & Classic Support:** Works with both block editor and classic editor.  
- **No Server Load:** Locking is handled in the browser, no heavy database operations.  

---

## Installation

1. Upload the `single-tab-post-lock` folder to the `/wp-content/plugins/` directory, or install via the WordPress plugin installer.  
2. Activate the plugin through the **Plugins** screen in WordPress.  
3. Access the plugin via **Settings → Single Tab Post Lock**.  

---

## Frequently Asked Questions

### Does this plugin prevent multiple users from editing the same post?  
No. WordPress already has a native post lock for multiple users. This plugin only prevents **the same user** from editing the same post in multiple tabs.  

### What happens if my browser crashes or I close a tab without saving?  
The plugin automatically clears the lock when you close or leave the editor. If your browser crashes, the lock expires after 30 minutes by default.  

### Will this affect performance?  
No. The plugin is lightweight and only runs a small JavaScript snippet on post edit screens.  

---

## Changelog

### 1.0.0
- Initial release  
- Added single-tab locking for post editing  
- Automatic lock removal on tab close  
- 30-minute timeout fallback  

---

## Upgrade Notice

### 1.0.0
First release – prevents duplicate post editing tabs for the same user.  

---

## Troubleshooting

1. Ensure the Single-Tab Post Lock plugin is activated.  
2. Verify your WordPress version is at least 5.2.  
3. Clear your browser cache if the lock script does not run.  
4. If issues persist, check for conflicts with other admin-side JavaScript plugins.  

---


