WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Artiss URL Shortener

Artiss URL Shortener will shorten a supplied URL using one of over 80 different shortening services

Parameters

There are 2 parameters when using the url_shortener function..

The first parameter is the URL that you wish to have shortened. If left blank it will use the URL of the current post/page.

The second parameter is a list of options. These are separated by an ampersand and can be any of the following...

  • service= - Which shortening service do you wish to use?
  • cache=reset - This is the only option for this parameter and, if specified, will reset the cache.

Additionally, some services require information such as keys and password to be specified. In which case, use one of the following to supply this...

  • apikey=
  • login=
  • password=
  • username=
  • uid=
  • token=

For example...

<?php echo url_shortener( 'http://www.artiss.co.uk', 'service=bit.ly+key&apikey=3003948393993&login=test' ); ?>

I've not used a valid API key in the above example - you will need to get one for yourself.

For a list of which services are available and which additional information they require, a screen within administration will list them. Within Administration, click on "Services" under the "URL Shortener" menu option.

Options Screen

Within the Administration screen there is a side menu named "URL Shortener". Clicking on this will present you wish an options screen. From here you can specify default settings. So, if you nearly always use the same shortening service you can specify it here - you then don't need to supply it when calling the url_shortener function.

Developers

It is envisaged that this plugin is probably more of use to developers who want to include it as part of a plugin or theme. In particular, this plugin can be called from another. For example, a social bookmarking plugin could use this to provide a number of possible URL shortening services.

To this end another routine is provided, validate_url_shortener, which can be used to validate whether a shortening service is valid.

This routine has two parameters. The first parameter is a line of text that you wish to have checked to see if it includes a validate shortening service.

The second, optional, parameter is a mask. Use the text {service} to indicate where in the mask the name of the service should appear.

If the shortening service was valid, the name of it will be returned.

Let's try some examples...

validate_url_shortener( 'is.gd' );

This will return is.gd if is.gd is, indeed, one of the shortening services that this plugin accepts. Otherwise a null will be returned.

validate_url_shortener( 'Is there a shortening service in this sentence is.gd' );

Again, this will return is.gd, as it was found within the first parameter.

validate_url_shortener( 'Start %is.gd% End', '%{service}%' );

This time a mask has been specified showing that the service should appear within percent signs. As a valid service is found within the first parameter in this format, it will be valid and is.gd will once again be return.

In this example, a null will be specified as the mask condition was not met...

validate_url_shortener( 'Start is.gd End', '%{service}%' );

Use this routine in conjunction with the actual shortener to validate passed services before then using them. However, if Artiss URL Shortener is passed a service that is not valid, it will simply return the original URL.

Caching

This plugin makes use of caching to improve performance. When a shortening services returns a short URL, theoretically that should never need to change. Therefore, this plugin will cache them indefinately. If, for whatever reason, you need it to be re-fetched you can do this by simply using the cache=reset parameter.

Caching is performed using WordPress Transients. Housekeeping of these is a known issue and I would highly recommend using another plugin of mine - Artiss Transient Cleaner. In particular, if you are upgrading from a version prior to 2.0 then all the old cache will remain indefinately (apologies for this, I didn't use a naming convention that would allow me to identify it at a later time) - this plugin will clear this down.

Licence

This WordPress plugin is licensed under the GPLv2 (or later).

Support

All of my plugins are supported via my website.

Please feel free to visit the site for plugin updates and development news - either visit the site regularly or follow me on Twitter (@artiss_tech).

For problems, suggestions or enhancements for this plugin, there is a dedicated page and a forum. The dedicated page will also list any known issues and planned enhancements.

This plugin, and all support, is supplied for free, but donations are always welcome.

Reviews & Mentions

Custom Short URLs in WordPress

Behind the Scenes - The Brooks Review

How to make a Twitter button with your choice of service URL

Requires: 2.0 or higher
Compatible up to: 3.4.2
Last Updated: 2012-12-5
Downloads: 7,485

Ratings

3 stars
3.5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 100,1,1
100,1,1
100,1,1
100,1,1
100,1,1