Matt Gifford aka coldfumonkeh | Consultant Developer
View Github Profile

RIAForge project link Wordpress shortcode plugin

Jul 8, 2011

I've created a very simple Wordpress plugin that makes use of the awesome shortcode API to generate content within the editor.

In this case, I wanted something to automatically generate a link to a specific project page on RIAForge. When I release open source projects on the site, I always link to the product page on RIAForge, manually typing the link every time. Although that's no massive loss of time, but any savings are certainly welcome.

The plugin simply accepts the id of the specific project you want to link to as an attribute within the shortcode, so placing something like so in the editor:

will generate and render the following URL when someone views the page:

Simple in nature and function, it may be something I expand over time and add in an admin interface, but for now this will certainly be a massive timesaver for me (and hopefully others too).

Plugin Name: riaforge Shortcode Generator
Description: This plugin obtains information and generates a
			link to a specific project on riaforge using the
            ID as an attribute in the shortcode.
            For example: [riaforge projectid="100"]
Version: 0.1
License: GPL
Author: Matt Gifford aka coldfumonkeh
Author URI:

/* 	add the filter to allow the
	shortcode to run in our widgets
add_filter('widget_text', 	'do_shortcode');

function getProjectInfo($atts, $content=null) {
		// Our shortcode attributes and default values
			"projectid"		=> ''
		), $atts));
		// Build the URL for the get request
		$strURL 	= 	'
						$projectid .'&returnFormat=json';
		// Run the get request
		$json 		= wp_remote_get($strURL);
		// get the array of data from the response
		$array 		= json_decode($json['body']);
		$jsonData	= $array->DATA;

		// Build the HTML tag to return
		return '<a href="http://'. $jsonData[0][4] .'"
				title="Download '. $jsonData[0][1] .' from">
				Download '. $jsonData[0][1] .' from</a>';

add_shortcode('riaforge', 'getProjectInfo');


Shortcodes are a superb addition to Wordpress (since version 2.5) and can transform the simplest thing into an automatic process. Superb!

Latest Blog Posts

Jul 16, 2020
Github Actions with CommandBox and TestBox
Read More
Jul 9, 2020
Azure pipelines with CommandBox and TestBox
Read More
Dec 23, 2019
CFML content moderation detection component library
Read More