Write WordPress Plugins to Play Freemind Mind-Map File
The first version main goal is to embed the *.mm
file which is a Freemind file. I found similarity of embedding this kind of file in flash-video-player plugins (I used version 3.1.8). So, I tried to reverse engineer by mind-mapping how it works first and how to hook plugins to WordPress. Here is version 1.1 of the fremind-wp-browser. The final mind-map and plugin in-use in this post looks crowded, but you can find highlighted pointers below the mind-map.
Get the Flash Player to see this player.
Embedding with SWFObject
The *.mm file is projected over visorFreemind.swf player with the help of javascript.
Using javascript from SWFObject, the idea of flash embedding is to create an SWFObject
and then write()
that inside certain part of page body, i.e. div
.
<script type="text/javascript"> var s0 = new SWFObject("visorFreemind.swf","n0","800","400","7"); s0.write("video0") ; </script>
Parsing a Post
In general, the plugins will parse a post content to find [freemind file="path-to.mm" /]
shortcode that will finally be replaced by the above javascript with respect to *.mm
file that will be played over visorFreemind.swf
.
Hooking the Plugins to WordPress
The above javascript needs to be loaded in every head
part of each WordPress page, this action will call a function that will insert that script
163 | add_action('wp_head', 'FreemindMap_head'); |
Hence, we get
<script type="text/javascript" src="http://lakm.us/logit/wp-content/plugins/freemind-wp-browser/swfobject.js"></script>
on the header source of every page.
To deal with content parsing looking for the shortcode, add the following filter
166 | add_filter('the_content', 'FreemindMap_Parse'); |
Activation/deactivation of the plugin is via the hook registration where it also create an option panel when activated by adding
99 | add_options_page('Freemind Options', 'Freemind', '8', 'freemind-wp-browser.php', 'FreemindOptions'); |
This initial version has limited options though; enough to set the width and height of the mind-map projection.
2 thoughts on “Write WordPress Plugins to Play Freemind Mind-Map File”