To cut a long story short I went to the Liverpool WordPress interest group last night and one thing that came up that no one seemed to have a solution for was users messing up short codes and how could we replace the short code with a more user friendly image just like the WordPress gallery short code.This must have played on my mind because I woke this morning a couple of hours before the alarm and just had to get up and find a solution.
To create the plugin I had to find a short code which I could then attempt to replace with a graphic and since Spots from Interconnect IT is one of my favourite plugins right now I thought I would use that. So I have created a plugin that will replace any “icitspot” short codes with a small graphic. This plugin isn’t meant for release, it was made quickly this morning (when I say quickly I mean the whole morning) and isn’t thoroughly tested. Hopefully it may help someone who is trying to achieve similar things with their own plugin short codes.
Quick rundown on how the plugin works
The plugins main php file uses just two filters (mce_external_plugins, tiny_mce_before_init) to add our TinyMCE plugin and an extra CSS file for styling.
Most of the code that does the bulk of the work is inside tinymce-plugin/icitspots/editor_plugin.js which is in effect a TinyMCE plugin.
I borrowed some code and structure from \wp-includes\js\tinymce\plugins\wpgallery\editor_plugin.dev so if you want to add buttons and click events to this then take a look at that file for guidance.
Hopefully this will be of use to someone. I’d like to think the code is pretty straight forward. Send us a comment if you have any questions or observations.