Simple Math Site Lock
A lightweight WordPress plugin that uses random math challenges to control website access.
by Ishani · github.com/ishanishrestha/simple-math-site-lock · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/ishanishrestha/simple-math-site-lock/archive/refs/heads/main.zipReadme
Simple Math Site Lock 🔒
A lightweight WordPress plugin that protects website access with a simple math challenge.
Visitors are asked to solve a randomly generated addition problem before they can access the website. Administrators can bypass the lock and access the WordPress dashboard normally.
Demo 🎬
Try the plugin on my website:
View Live Demo: https://ishanishrestha.com.np
Features
- Random math challenges — Generates a new addition question for visitors.
- Access protection — Visitors must answer the challenge correctly before accessing the site.
- WordPress security — Uses WordPress nonces to help protect form submissions.
- Server-side challenge storage — Correct answers are stored using WordPress transients rather than being exposed in the page.
- Administrator bypass — Administrators with the appropriate capability can access the website without completing the challenge.
- Custom lock page — Includes a separate template and CSS file for the lock screen.
- Translation-ready — User-facing text uses WordPress internationalization functions so it can be translated into other languages.
- Lightweight — Built with PHP and standard WordPress functionality without requiring additional plugins or libraries.
Requirements
- WordPress: 6.2 or later
- PHP: 8.0 or later
Installation
Method I: Upload the plugin
- Download this repository as a ZIP file.
- In your WordPress dashboard, go to Plugins → Add New Plugin.
- Select Upload Plugin.
- Upload the ZIP file.
- Install and activate Simple Math Site Lock.
Method II: Manual installation
- Download or clone this repository.
- Place the
simple-math-site-lockfolder insidewp-content/plugins/ - Go to WordPress Dashboard → Plugins.
- Find Simple Math Site Lock.
- Click Activate.
Once activated, visitors to the website will be presented with the math challenge.
Project Structure
simple-math-site-lock/
│
├── simple-math-site-lock.php # Main plugin file
├── README.md # GitHub documentation
├── readme.txt # WordPress.org plugin information
│
├── assets/
│ └── style.css # Lock page styling
│
└── templates/
└── lock-page.php # Lock page template
How It Works
When a visitor accesses the website, the plugin:
- Checks whether the visitor should be exempt from the lock.
- Generates two random numbers.
- Creates an addition challenge.
- Stores the correct answer temporarily on the server.
- Displays the lock page.
- Verifies the submitted answer.
- Unlocks the website when the correct answer is provided.
Administrators with the required capability are allowed to bypass the lock.
Translation
The plugin uses WordPress internationalization functions for user-facing strings which makes the interface ready for translation.
For example, strings such as:
Access RequiredPlease solve the math question to continue.Enter your answerContinue
are prepared for translation using the plugin's text domain is-smsl.
Additional translation files can be added in the future.
Development
This project can be tested on a local WordPress installation using a local development environment such as XAMPP.
After making changes:
- Update the plugin version when appropriate.
- Test the plugin on the supported WordPress/PHP versions.
- Test both correct and incorrect answers.
- Check administrator access.
- Check the lock page on different screen sizes.
- Review the changelog before creating a release.
License
Simple Math Site Lock is free software licensed under the GNU General Public License v2 or later (GPLv2+).
See the LICENSE information and readme.txt for additional details.
Author
Ishani
Developed as a WordPress plugin project.