WP Manifestindependent plugin directory
manifest / seo / safe-redirect-short-urls

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.zip

Readme

Turns Safe Redirect Manager into a Short URL service.

Setup

  1. Activate the plugin. It will auto-activate Safe Redirect Manager or request it be installed if it doesn't exist.
  2. Add define( 'SHORT_URL_API_KEY', 'YOUR-API-KEY' ); to wp-config.php.

Generate a short URL:

Example request:

http://site.com/wp-admin/admin-ajax.php?action=srm-short-url&key=YOUR-API-KEY&url=http://longurl.com/example

Example return:

http://site.com/Qr3

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.

Read the full README on GitHub →