| js | ||
| README.md | ||
| simple-lock-toggle.php | ||
Simple Lock Toggle
Contributors: Vratislav Hutsky
Plugin URI: https://codeberg.org/vex/simple-lock-toggle
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
A simple WordPress plugin that adds a lock/unlock button to the admin interface and writes the current state to a file.
Description
Simple Lock Toggle provides a straightforward way for site administrators to toggle a system-wide lock state. This state is saved as a simple integer (0 for unlocked, 1 for locked) in a file located in the wp-content/uploads directory.
This plugin is useful for developers who need a simple, file-based flag that can be checked by other plugins, themes, or external scripts to enable or disable specific functionalities.
Features
- Adds a "Lock/Unlock" button to the WordPress admin bar for quick access.
- Provides a dedicated admin page under the "Lock Toggle" menu to view the current status and file path.
- Saves the lock state to
wp-content/uploads/lock_state.txt. - Uses AJAX, so toggling the state happens instantly without a page reload.
- Implemented using WordPress nonces.
- Functionality is restricted to users with
manage_optionscapability (typically administrators).
Installation
- Upload the
simple-lock-togglefolder to the/wp-content/plugins/directory on your web server. - Activate the plugin through the 'Plugins' menu in your WordPress admin dashboard.
- Upon activation, the plugin will attempt to create the
lock_state.txtfile in yourwp-content/uploadsdirectory. Please ensure this directory is writable by the web server.
Usage
Once the plugin is activated:
- A lock/unlock button (🔒 / 🔓) will appear in the top admin bar for logged-in administrators.
- Click this button to toggle the lock state. The button text and icon will update automatically.
- To see more details, navigate to the Lock Toggle menu item in the left-hand admin sidebar. This page displays the current status (LOCKED/UNLOCKED), the exact path to the lock file, and the raw value stored within it.
You can then use any file-reading function in your other PHP or bash scripts to check the contents of wp-content/uploads/lock_state.txt and alter behavior accordingly.
License
This plugin is licensed under the GNU General Public License v2 or later. See the license file for more details.