<?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/topics/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>Sun, 06 May 2012 00:18:37 +0000</lastBuildDate>
	<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&#038;utm_medium=rss&#038;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>dgw / voyagerfan5761</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[My Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></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 [...]]]></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><a href="http://technobabbl.es/2011/09/google-books-and-the-book-industry/?utm_source=feedfooter&#038;utm_medium=link&#038;utm_campaign=feedfooter">Originally published</a> at <img src="http://bits.technobabbl.es/img/png/technobabbles_logo_16.png"> <a href="http://technobabbl.es/?utm_source=feedfooter&#038;utm_medium=link&#038;utm_campaign=feedfooter">Technobabbles</a><br />Content copyright © 2006-2012 by dgw / voyagerfan5761</p>
<div style="padding-top:5px;padding-right:0px;padding-bottom:5px;padding-left:0px;;">
											<iframe
												style="height:25px !important; border:0px solid gray !important; overflow:hidden !important; width:550px !important;" frameborder="0" scrolling="no" allowTransparency="true"
												src="http://www.linksalpha.com/social?blog=Technobabbles&link=http%3A%2F%2Ftechnobabbl.es%2F2010%2F01%2Fwibiya-toolbar-plugin-compatibility-patch%2F&title=My+First+WordPress+Plugin+Patch%3A+Wibiya+Toolbar&desc=The+beauty+of+using+WordPress+instead+of+Blogger+is%2C+in+a+nutshell%2C+the+freedom+that+comes+with+using+an+open+system+instead+of+a+closed+one.+Under+Blogger%2C+I+had+very+little+freedom+to+extend+the+platform.+Everything+I+could+do+had+to+be+added+by+someone+from+Google%2C+with+the+exception+of+a+few&fc=333333&fs=arial&fblname=like&fblref=facebook&fbllang=en_US&fblshow=1&fbsbutton=1&fbsctr=1&fbslang=en&fbsendbutton=1&twbutton=1&twlang=en&twmention=voyagerfan5761&twrelated1=voyagerfan5761&twrelated2=&twctr=1&lnkdshow=noshow&lnkdctr=0&buzzbutton=1&buzzlang=en&buzzctr=0&diggbutton=1&diggctr=0&stblbutton=1&stblctr=0&g1button=1&g1ctr=1&g1lang=en-US">
											</iframe>
										</div> <p><a href="http://technobabbl.es/?flattrss_redirect&amp;id=965&amp;md5=3488e4db45c9035a2b78ce0ca197882e" title="Flattr" target="_blank"><img src="http://technobabbl.es/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://technobabbl.es/2010/01/wibiya-toolbar-plugin-compatibility-patch/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=dgw&amp;popout=1&amp;url=http%3A%2F%2Ftechnobabbl.es%2F2010%2F01%2Fwibiya-toolbar-plugin-compatibility-patch%2F&amp;language=en_GB&amp;category=text&amp;title=My+First+WordPress+Plugin+Patch%3A+Wibiya+Toolbar&amp;description=The+beauty+of+using+WordPress+instead+of+Blogger+is%2C+in+a+nutshell%2C+the+freedom+that+comes+with+using+an+open+system+instead+of+a+closed+one.+Under+Blogger%2C+I+had...&amp;tags=blog" type="text/html" />
	</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&#038;utm_medium=rss&#038;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>dgw / 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://technobabbl.es/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, [...]]]></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><a href="http://technobabbl.es/2011/09/google-books-and-the-book-industry/?utm_source=feedfooter&#038;utm_medium=link&#038;utm_campaign=feedfooter">Originally published</a> at <img src="http://bits.technobabbl.es/img/png/technobabbles_logo_16.png"> <a href="http://technobabbl.es/?utm_source=feedfooter&#038;utm_medium=link&#038;utm_campaign=feedfooter">Technobabbles</a><br />Content copyright © 2006-2012 by dgw / voyagerfan5761</p>
<div style="padding-top:5px;padding-right:0px;padding-bottom:5px;padding-left:0px;;">
											<iframe
												style="height:25px !important; border:0px solid gray !important; overflow:hidden !important; width:550px !important;" frameborder="0" scrolling="no" allowTransparency="true"
												src="http://www.linksalpha.com/social?blog=Technobabbles&link=http%3A%2F%2Ftechnobabbl.es%2F2008%2F03%2Fgimp-script-to-make-sw-robotics-thumbs%2F&title=GIMP+Script+to+Make+SW+Robotics+Thumbs&desc=After+making+a+whole+bunch+of+thumbnail+images+for+the+member+and+mentor+profiles+on+the+Southwest+Robotics+site+this+past+season%2C+I+finally+decided+last+night+to+automate+the+process+with+a+GIMP+script%2C+in+preparation+for+next+year%27s+new+people.So%2C+what+does+it+do%3F+It+takes+the+image+it+is+run+on%2C&fc=333333&fs=arial&fblname=like&fblref=facebook&fbllang=en_US&fblshow=1&fbsbutton=1&fbsctr=1&fbslang=en&fbsendbutton=1&twbutton=1&twlang=en&twmention=voyagerfan5761&twrelated1=voyagerfan5761&twrelated2=&twctr=1&lnkdshow=noshow&lnkdctr=0&buzzbutton=1&buzzlang=en&buzzctr=0&diggbutton=1&diggctr=0&stblbutton=1&stblctr=0&g1button=1&g1ctr=1&g1lang=en-US">
											</iframe>
										</div> <p><a href="http://technobabbl.es/?flattrss_redirect&amp;id=418&amp;md5=a83fc374ba07ac1bfbe33cc3110a3f75" title="Flattr" target="_blank"><img src="http://technobabbl.es/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></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>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=dgw&amp;popout=1&amp;url=http%3A%2F%2Ftechnobabbl.es%2F2008%2F03%2Fgimp-script-to-make-sw-robotics-thumbs%2F&amp;language=en_GB&amp;category=text&amp;title=GIMP+Script+to+Make+SW+Robotics+Thumbs&amp;description=After+making+a+whole+bunch+of+thumbnail+images+for+the+member+and+mentor+profiles+on+the+Southwest+Robotics+site+this+past+season%2C+I+finally+decided+last+night+to+automate+the...&amp;tags=blog" type="text/html" />
	</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using disk: enhanced
Database Caching 9/31 queries in 0.367 seconds using disk: basic
Object Caching 2147/2180 objects using disk: basic

Served from: technobabbl.es @ 2012-05-18 22:00:14 -->
