cross-screen marketing solutions

How WordPress Developers can Mobilize their Plugins

Mobile Web Junkie

Mobile Web Junkie

As I mentioned in my article regarding the release of my mobile WordPress plugin, the results of my plugin on a standard install of WordPress are awesome and blogs look amazing on mobile web (as you can see from the screenshot).

But because of the open source nature of WordPress, there are a whole load of other plugins that could be mobilized in order to work in tandem with mine. Content plugins that generate really simple HTML will already be catered for because of checks I perform on the content, but more specific code that outputs JavaScript or something a little bit out of the ordinary will need a little bit more attention to work perfectly.

To help developers along, I’ve added some functionality into my mobile plugin that allows you to create a WAPL version of your plugin that will work perfectly on mobile.

Plugins with special tags

If your plugin allows blog writers the ability to place special tags in their code so they get rendered into something else then you’re in luck! By creating a function inside a class and following my naming convention, your WAPL plugin extension automatically gets picked up and executed.

Here’s a quick example with a fictional WAPL plugin extension called “Hello World”, that allows you to place “[hello]” in your post and when viewed, will output “Hello World” – pretty basic but it should give you an idea of how it works.

<?php
class wapl_hello_world
{
	function format($content, $class)
	{
		$content = str_replace('[hello]', $this->start($class).'<wordsChunk><quick_text>Hello World</quick_text></wordsChunk>'.$this->end($class), $content);
		return $content;
	}
	function start($class)
	{
		return '</quick_text></wordsChunk>';
	}
	function end($class)
	{
		return '<wordsChunk class="'.$class.'"><quick_text>';
	}
}
?>

You can see from the code that wherever “[hello]” is in the content string, it gets replaced with a WAPL string to output “Hello World” inside a wordsChunk element. This in turns gets rendered in whichever mobile markup language is required by a handset at run-time via a SOAP call.

Done that – what next?

Once you’ve got a WAPL extension working, let me know and I’ll add it to my repository so it’s available automatically to anyone who might be using your plugin. You’ll also have to let people know to use my plugin to make it mobile friendly!

Making your plugin work for all devices has now become so easy that the question is now not “how do i do it?” but “why haven’t you done it yet!”

If you need any help with making your plugin work for mobile, contact me and I’ll do my best to help and if you want to find out how everything comes together, have a read of my article about How I Mobilized WordPress.

Alternatively, if you want to just get on with mobilizing your plugin, check out http://wapl.info – it should help you to create some WAPL.

Comments are closed.