<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Technobabbles &#187; My Code</title>
	<atom:link href="http://technobabbl.es/category/my-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://technobabbl.es</link>
	<description>I try to sound like I know what I&#039;m talking about. Don&#039;t be fooled.</description>
	<lastBuildDate>Thu, 24 Jun 2010 18:04:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=9156</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>My First WordPress Plugin Patch: Wibiya Toolbar</title>
		<link>http://technobabbl.es/2010/01/wibiya-toolbar-plugin-compatibility-patch/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://technobabbl.es/2010/01/wibiya-toolbar-plugin-compatibility-patch/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 01:46:38 +0000</pubDate>
		<dc:creator>Voyagerfan5761</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[My Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[ideas]]></category>

		<guid isPermaLink="false">http://technobabbl.es/?p=965</guid>
		<description><![CDATA[The beauty of using WordPress instead of Blogger is, in a nutshell, the freedom that comes with using an open system instead of a closed one. Under Blogger, I had very little freedom to extend the platform. Everything I could do had to be added by someone from Google, with the exception of a few [...]<p>Originally published at <img src="http://voyagerfan5761.googlepages.com/technobabbles_logo_16.png" /> <a href="http://technobabbl.es/?utm_source=feedfooter&utm_medium=link&utm_campaign=feedfooter">Technobabbles</a><br />
Content copyright &copy; 2006-2010 by Voyagerfan5761</p>
]]></description>
			<content:encoded><![CDATA[<p>The beauty of using WordPress instead of Blogger is, in a nutshell, the freedom that comes with using an open system instead of a closed one. Under Blogger, I had very little freedom to extend the platform. Everything I could do had to be added by someone from Google, with the exception of a few JavaScript- and Flash-based sidebar widgets. Under WordPress, I have access to literally thousands of open-source plugins to modify, extend, and replace the functionality of the site.</p>
<p>The beauty of using this open system is that if something doesn't work the way I want it to, I am free to simply change it; every plugin is editable from within WordPress' administrative back-end, and the core code is also hackable (though I don't like messing with it because upgrades will break changes). When I discovered that the <a href="http://wibiya.com/" rel="nofollow" >Wibiya</a> Toolbar (or Wibar) was showing on the mobile version of the website (which is generated by <a href="http://mobilepress.co.za/" rel="nofollow" >MobilePress</a>, another good plugin), I simply looked in the source of Wibiya's plugin to see how the JavaScript for the toolbar was being inserted.</p>
<p>I found that instead of using the <code>wp_enqueue_script()</code> function as WordPress plugin developers are supposed to do, the Wibiya developers simply used <code>echo</code> to output a <code>&lt;script&gt;</code> tag. That explained why only the JavaScript for the Wibar was loading on the mobile site. Rewriting the plugin to use the official WordPress script-injection method solved the problem.</p>
<p>The original relevant code was:</p>
<pre><code>add_action('get_footer', 'filter_footer');
add_action('admin_menu', 'wibiya_config_page');

function filter_footer() {
    $wibiya_toolbarid = get_option('WibiyaToolbarID');
    $wibiya_enabled = get_option('WibiyaToolbarEN');

    if ($wibiya_toolbarid != '' and $wibiya_enabled) {
        echo '&lt;script src="http://cdn.wibiya.com/Loaders/Loader_'.$wibiya_toolbarid.'.js" type="text/javascript"&gt;&lt;/script&gt;';
    }
}</code></pre>
<p>I rewrote it just a little bit. My changes were pretty trivial, really. I changed the function name to be namespaced (including the plugin name) just so it'd be less likely to conflict with another plugin. I also switched actions to enable <code>wp_enqueue_script()</code> to work (<code>get_footer</code> is called too late) and added a check—<code>if( !is_admin() )</code>—to keep the toolbar off of admin pages, preserving the original behavior of the function (and the sanity of anyone using the modifications).</p>
<p>In short, <code>wp_enqueue_script()</code> takes five parameters, three of which are optional. The first two are the <code>$handle</code> and the <code>$src</code>, which specify a name for the script and its source address. Then come <code>$deps</code> (dependencies; Wibiya has none, so set to <code>false</code>), <code>$ver</code> (version; also <code>false</code> because it's irrelevant), and <code>$in_footer</code> (set to <code>true</code> because the toolbar should be inserted above the <code>&lt;/body&gt;</code> tag).</p>
<p>So with my changes, the code block above becomes:</p>
<pre><code>if( !is_admin() ) {
    add_action('wp_print_scripts', 'wibiya_filter_footer');
}
add_action('admin_menu', 'wibiya_config_page');

function wibiya_filter_footer() {
    $wibiya_toolbarid = get_option('WibiyaToolbarID');
    $wibiya_enabled = get_option('WibiyaToolbarEN');

    if ($wibiya_toolbarid != '' and $wibiya_enabled) {
        wp_enqueue_script( 'wibiyabar', 'http://cdn.wibiya.com/Loaders/Loader_'.$wibiya_toolbarid.'.js', false, false, true );
    }
}</code></pre>
<p>Following some light testing, I <a href="http://getsatisfaction.com/wibiya/topics/use_wp_enqueue_script_rather_than_manually_inserting_the_lt_script_gt_tag_in_wordpress" rel="nofollow" >submitted an idea</a> to the Wibiya feedback forum, where my update is currently being reviewed by the company. Hopefully, the change will be included in a future version of the Wibiya WordPress plugin. After all, it changes nothing for Wibiya but works wonders for compatibility with other plugins.</p>
<p>I'll just bet that this won't be the last time I'll send a patch to a plugin developer. I enjoy reporting bugs and coming up with fixes too much to not do it. <img src='http://technobabbl.es/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<div id="flaresmith" class="feedflare"><script src="http://feeds.technobabbl.es/~s/voyagerfan5761?i=http://technobabbl.es/2010/01/wibiya-toolbar-plugin-compatibility-patch/" type="text/javascript" charset="utf-8"></script></div><p>Originally published at <img src="http://voyagerfan5761.googlepages.com/technobabbles_logo_16.png" /> <a href="http://technobabbl.es/?utm_source=feedfooter&utm_medium=link&utm_campaign=feedfooter">Technobabbles</a><br />
Content copyright © 2006-2010 by Voyagerfan5761</p>
]]></content:encoded>
			<wfw:commentRss>http://technobabbl.es/2010/01/wibiya-toolbar-plugin-compatibility-patch/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>GIMP Script to Make SW Robotics Thumbs</title>
		<link>http://technobabbl.es/2008/03/gimp-script-to-make-sw-robotics-thumbs/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://technobabbl.es/2008/03/gimp-script-to-make-sw-robotics-thumbs/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 13:26:00 +0000</pubDate>
		<dc:creator>Voyagerfan5761</dc:creator>
				<category><![CDATA[GIMP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[My Code]]></category>
		<category><![CDATA[SW Robotics]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://technobabbles.gtaero.net/2008/03/gimp-script-to-make-sw-robotics-thumbs.html</guid>
		<description><![CDATA[After making a whole bunch of thumbnail images for the member and mentor profiles on the Southwest Robotics site this past season, I finally decided last night to automate the process with a GIMP script, in preparation for next year's new people.
So, what does it do?  It takes the image it is run on, [...]<p>Originally published at <img src="http://voyagerfan5761.googlepages.com/technobabbles_logo_16.png" /> <a href="http://technobabbl.es/?utm_source=feedfooter&utm_medium=link&utm_campaign=feedfooter">Technobabbles</a><br />
Content copyright &copy; 2006-2010 by Voyagerfan5761</p>
]]></description>
			<content:encoded><![CDATA[<p>After making a whole bunch of thumbnail images for the member and mentor profiles on the Southwest Robotics site this past season, I finally decided last night to automate the process with a <acronym title="GNU Image Manipulation Program">GIMP</acronym> script, in preparation for next year's new people.</p>
<p>So, what does it do?  It takes the image it is run on, scales it (<tt>gimp-image-scale</tt>) to 120px x 90px, and utilizes <tt>script-fu-drop-shadow</tt> to add a correctly-positioned drop-shadow.  (Correctly is, in this case, the same as all the other images I did manually.)</p>
<p>It's a rather simple script; here's the code:</p>
<pre>; Script-Fu script to automatically;   resize and drop-shadow files for;   SWR profile shots; IMPORTANT!; Image must be EXACTLY 4:3 aspect;   ratio or it will be distorted.; This script does not measure the;   image or do any cropping; it is;   up to you to crop the image properly.

(define (swr-make-profile-thumb img drawable)(gimp-image-scale img 120 90)(script-fu-drop-shadow img drawable 4 4 8 '(0 0 0) 80 TRUE))

(script-fu-register "swr-make-profile-thumb""Make SWR Profile Thumb""Scales the image to 120x90 and adds an appropriate drop-shadow""Voyagerfan5761""Voyagerfan5761""March 17, 2008""RGB*, GRAY*"SF-IMAGE "Image" 0SF-DRAWABLE "Layer" 0)(script-fu-menu-register "swr-make-profile-thumb""&lt;Image&gt;/Script-Fu/SWR")</pre>
<p>Note: The original has my real name and an email address, but I have stripped them out for purposes of posting this in view of Web crawlers.</p>
<p>Input images must be in 4:3 aspect ratio to avoid distortion. I currently have no validation for aspect ratio, nor am I certain that it's even possible to check such things, but if it is I will add it at some point.  As can be seen from <a href="http://twitter.com/voyagerfan5761/statuses/772689144" rel="nofollow" >two of</a> <a href="http://twitter.com/voyagerfan5761/statuses/772699680" rel="nofollow" >my updates</a> last night on Twitter, I only just learned Script-Fu Scheme less than 10 hours ago.</p>
<p>The only real problem I had was developing the <tt>script-fu-drop-shadow</tt> line, which kept choking when I tried to set an interactivity mode.  I eventually figured out that that parameter wasn't required in 2.4 (or some other weird problem; I'm still not sure).</p>
<p>It's obviously not much, just a few basic lines of the stripped-down Scheme that <acronym title="GNU Image Manipulation Program">GIMP</acronym> uses.  Nevertheless, if you use my script as a base for a released script of your own, I would appreciate an acknowledgment.  A link back here along the lines of, "Based on a short script by <a href="http://voyagerfan5761.blogspot.com/" rel="nofollow" >Voyagerfan5761</a>" would be sufficient (note the link on "Voyagerfan5761").</p>
<p>And of course, I'd appreciate any and all comments on this script, be they pointing out a better way to do things, something I missed, a suggestion for validating the aspect ratio (hey, it never hurts to ask).  Or even a note that you based a script of your own off of mine.  That's highly unlikely, considering I didn't even copy any code examples for this one.  (OK, I lifted and modified the registration function from <a href="http://www.gimp.org/tutorials/Basic_Scheme/" rel="nofollow" >a <acronym title="GNU Image Manipulation Program">GIMP</acronym> tutorial page</a> at <acronym title="GNU Image Manipulation Program">GIMP</acronym>'s website, but that's all.)</p>
<div id="flaresmith" class="feedflare"><script src="http://feeds.technobabbl.es/~s/voyagerfan5761?i=http://technobabbl.es/2008/03/gimp-script-to-make-sw-robotics-thumbs/" type="text/javascript" charset="utf-8"></script></div><p>Originally published at <img src="http://voyagerfan5761.googlepages.com/technobabbles_logo_16.png" /> <a href="http://technobabbl.es/?utm_source=feedfooter&utm_medium=link&utm_campaign=feedfooter">Technobabbles</a><br />
Content copyright © 2006-2010 by Voyagerfan5761</p>
]]></content:encoded>
			<wfw:commentRss>http://technobabbl.es/2008/03/gimp-script-to-make-sw-robotics-thumbs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
