Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/valentin-grenier/swapurl/archive/refs/heads/main.zipNo built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.
SwapURL Plugin (Under Development)
SwapURL is a WordPress plugin that allows administrators to replace specific URLs in post content based on a JSON file. This ensures that outdated links are updated efficiently across all posts.
Features
- [x] Admin interface for uploading JSON files containing old and new URLs.
- [ ] Automated processing via WP Cron to replace URLs in post content.
- [ ] Logging of successful replacements and errors.
- [ ] Secure file handling with nonce verification.
- [ ] Simple progress tracking.
Installation
- Upload the
swapurlplugin to thewp-content/plugins/directory. - Activate the plugin through the 'Plugins' menu in WordPress.
- Navigate to SwapURL in the WordPress admin menu.
- Upload a JSON file containing URL mappings.
JSON File Format
The JSON file should be an array of objects, each containing:
[
{
"old_url": "https://old-url.com",
"new_url": "https://new-url.com"
},
{
"old_url": "https://another-old-url.com",
"new_url": "https://another-new-url.com"
}
]
How It Works
- Upload a JSON file via the SwapURL admin page.
- A cron job runs 15 seconds after the successful upload.
- The plugin searches
post_contentinwp_postsand replaces old URLs with the new ones. - Logs are stored and displayed on the admin page.
Security & Validation
- Nonce verification prevents unauthorized uploads.
- Uploaded JSON files are validated to ensure they contain only
to_replaceandnew_urlkeys.
Uninstallation
- Deactivating the plugin will stop processing but retain logs and settings.
- Manually delete uploaded JSON files from
wp-content/json-files/if necessary.
Author
Developed by Valentin Grenier, freelance WordPress Developer from Studio Val.