WP Monitor Key
WordPress Plugin for use with monitoring applications like Uptime Robot. It as a unique key to the footer source code as a HTML comment which can be added to monitoring software to monitor instead of standard HTTP codes as HTTP codes can often be incorrect.
by Zac Dreyer · github.com/zacdreyer/wp-monitor-key · 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/zacdreyer/wp-monitor-key/archive/refs/heads/main.zipReadme
WP Monitor Key
WP Monitor Key is a WordPress plugin that injects a unique 25-character marker key into frontend HTML as a footer comment. Monitoring platforms can check page source for that marker to verify full render behavior, rather than relying only on HTTP status codes.
Quick Facts
- Option name:
wpm_monitor_key - Key format: 25 alphanumeric characters
- Marker format: ``
- Settings location: Tools > Monitor Key
- Target: WordPress 6.x
Features
- Auto-generate key on activation if missing
- Editable key in admin UI
- One-click key regeneration
- Frontend footer comment injection
- Key change log (action, user, old/new key, timestamp)
- Automated unit tests for core plugin logic
Documentation Index
Core documentation:
Agent guidance:
Implementation files:
- wp-monitor-key.php
- includes/class-key-generator.php
- includes/class-settings.php
- includes/class-footer-injector.php
- includes/class-logger.php
Test and tooling files:
- composer.json
- phpunit.xml.dist
- tests/bootstrap.php
- tests/Unit/KeyGeneratorTest.php
- tests/Unit/FooterInjectorTest.php
- tests/Unit/LoggerAndSettingsTest.php
Installation
- Clone or copy this directory into WordPress plugins:
/wp-content/plugins/wp-monitor-key/
- Activate WP Monitor Key from WordPress Admin > Plugins.
- Go to WordPress Admin > Tools > Monitor Key.
Usage
- Open Tools > Monitor Key.
- Copy current key, edit it manually, or generate a new one.
- Add a page-source check in your monitoring tool.
Regex example:
<!-- WP Monitor Key: [a-z0-9]{25} -->
Exact-match example:
<!-- WP Monitor Key: abcde12345fghij67890klmno -->
How It Works
- On activation, plugin creates a key if one is not present.
- Plugin injects marker comment into frontend output via
wp_footer. - Monitoring system checks source for the marker.
- Admin actions for edit/regenerate are logged.
Security and Behavior Notes
- This is not an authentication key and is intentionally visible in source.
- Admin writes require
manage_optionscapability. - Admin writes require valid nonce.
- Inputs are sanitized and outputs are escaped.
Testing
Automated tests use PHPUnit + Brain Monkey.
Run locally:
composer install
composer test
If composer is not installed on your machine, install Composer first, then rerun the commands above.
Detailed testing instructions are in TESTING.md.
Troubleshooting
Marker not present:
- Verify plugin is active.
- Verify key exists in Tools > Monitor Key.
- Check frontend page source (not admin pages).
- Search source for
WP Monitor Key.
Monitoring does not match marker:
- Confirm monitor is checking full HTML response body.
- Confirm regex pattern is correct.
- Confirm URL being checked is the intended frontend route.
Support
Issues and feature requests:
License
GPL v2 or later.