<?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>fusi0n &#187; hack</title>
	<atom:link href="http://fusi0n.org/tag/hack/feed" rel="self" type="application/rss+xml" />
	<link>http://fusi0n.org</link>
	<description>pL&#039;s blog on tech/mobile</description>
	<lastBuildDate>Wed, 29 Feb 2012 20:19:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Make your WordPress plugins use a different version of a bundled JavaScript library</title>
		<link>http://fusi0n.org/coding/make-your-wordpress-plugins-use-a-different-version-of-a-bundled-javascript-library</link>
		<comments>http://fusi0n.org/coding/make-your-wordpress-plugins-use-a-different-version-of-a-bundled-javascript-library#comments</comments>
		<pubDate>Fri, 13 Feb 2009 05:45:10 +0000</pubDate>
		<dc:creator>pluc</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[WP-prettyPhoto]]></category>

		<guid isPermaLink="false">http://blog.fusi0n.org/?p=575</guid>
		<description><![CDATA[I've recently coded my first WordPress plugin, for the fun of it. I've been using WordPress for some time, and I know PHP quite well, so I figured it'd be fun. WordPress has a weird/interesting way of being extendable. I won't go into too much technical details about that, but suffices to say that it's [...]]]></description>
			<content:encoded><![CDATA[<p>I've recently coded my first <a href="http://codex.wordpress.org/Plugins" target="_blank">WordPress plugin</a>, for the fun of it. I've been using <a href="http://wordpress.org/" target="_blank">WordPress</a> for some time, and I know <a title="PHP" href="http://www.php.net" target="_blank">PHP</a> quite well, so I figured it'd be fun. WordPress has a <a href="http://codex.wordpress.org/Developer_Documentation" target="_blank">weird/interesting</a> way of being <em>extendable</em>. I won't go into too much technical details about that, but suffices to say that it's easy yet complicated to perform tasks you want to. Yeah, <em>that</em> weird.</p>
<p>All that being said, I upgraded my WordPress from 2.7 to <a href="http://wordpress.org/download/" target="_blank">2.7.1</a> in the middle of coding some new features for the latest release of <a title="WP-prettyPhoto" href="http://wordpress.org/extend/plugins/wp-prettyphoto" target="_blank">WP-prettyphoto</a>, 1.1. That made me realize that updating WordPress' core also <em>updates</em> the installed JavaScript modules, namely <a href="http://jquery.com/" target="_self">jQuery</a> (among <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Parameters" target="_blank">many others</a>). When I first coded <a title="WP-prettyPhoto" href="http://wordpress.org/extend/plugins/wp-prettyphoto" target="_blank">WP-prettyphoto</a>, when things weren't working I just replaced the <a href="http://jquery.com" target="_blank">jQuery</a> I had with the <a href="http://docs.jquery.com/Downloading_jQuery" target="_blank">latest official stable releas</a>e and things worked fine. I didn't give it much thought. So when I updated WordPress,  all hell broke loose and <a title="WP-prettyPhoto" href="http://wordpress.org/extend/plugins/wp-prettyphoto" target="_blank">WP-prettyphoto</a> was metaphorically crying in agony because jQuery wasn't man enough for it. I then tried performing the same manual updating procedure, and without really surprising anyone -- I was alone anyway -- <a title="WP-prettyPhoto" href="http://wordpress.org/extend/plugins/wp-prettyphoto" target="_blank">WP-prettyphoto</a> was back prettyfying my stuff like a starving fat kid eats a cheesecake.</p>
<p><span id="more-575"></span></p>
<p>Morale of the story, I needed to code a jQuery version check in my <a title="WP-prettyPhoto" href="http://wordpress.org/extend/plugins/wp-prettyphoto" target="_blank">WP-prettyphoto</a> code, and if jQuery's version wasn't matching what I wanted, I had to replace the script with one that would make <a title="WP-prettyPhoto" href="http://wordpress.org/extend/plugins/wp-prettyphoto/" target="_blank">WP-prettyPhoto</a> work the way it's supposed to. The goal's clear, the execution, however, was somewhat more obscure. Obviously, not being a WordPress plugin genius, I googled for solutions or anything that could help me achieve what I wanted. I didn't find much on how to replace a bundled script loaded by default. I found what I was looking for in a competing (and I use that term very, very loosely!) plugin for a jQuery Lightbox clone cleverly called <a href="http://wordpress.org/extend/plugins/jquery-lightbox-balupton-edition/" target="_blank">jQuery Lightbox</a> by <a href="http://www.pedrolamas.com/" target="_blank">Pedro Lamas</a>. It's basically de-registering the default WordPress jQuery plugin and replacing it with one bundled with the plugin. Using native functions. Nice. Here's the code:</p>
<pre class="brush: php; title: ; notranslate">// jQuery - removing to make sure we're using 1.3.1
//Deregister bundled jQuery (1.2.6 as of WP 2.7.1)
wp_deregister_script('jquery');
//Registering our up to date jQuery
//$wppp_url is WP_CONTENT_URL.'/plugins/'.plugin_basename(dirname(__FILE__));
wp_register_script('jquery', (&quot;$wppp_url/js/jquery-1.3.1.min.js&quot;), false, '1.3.1');
//Giving WordPress our new jQuery script to enqueue (display)
wp_enqueue_script('jquery');</pre>
<p>So there you have it. That's how to replace the version of a bundled WordPress JavaScript library.</p>
]]></content:encoded>
			<wfw:commentRss>http://fusi0n.org/coding/make-your-wordpress-plugins-use-a-different-version-of-a-bundled-javascript-library/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

