Safe Redirect Short URLs
Add a short URL API to Safe Redirect Manager.
by Paul Clark, 10up · github.com/pdclark/safe-redirect-short-urls · website
★ 2stars
0forks
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/pdclark/safe-redirect-short-urls/archive/refs/heads/master.zipReadme
Turns Safe Redirect Manager into a Short URL service.
Setup
- Activate the plugin. It will auto-activate Safe Redirect Manager or request it be installed if it doesn't exist.
- Add
define( 'SHORT_URL_API_KEY', 'YOUR-API-KEY' );towp-config.php.
Generate a short URL:
Example request:
Example return:
Options
Override the default domain name. For example, if you have a short domain that also points to your site.
add_filter( 'srsu_site_url', function(){ return 'http://pd.cm'; } );
Set the API key using a filter. Useful for setting config in an mu-plugin instead of wp-config.php
add_filter( 'srsu_api_key', function(){ return 'kckRse'; } );
Details
- URL keys are Hash IDs based on the ID used for the redirect custom post type.
- Hash IDs are salted, causing them to not be easily guessed.
- Redirects are checked for duplicates. If a duplicate is found, the original Hash ID is returned.
- Hash IDs have no possibility for intersections -- every ID will be unique.
- Hash IDs will be as short as possible for the given post ID and salt.