<?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>Jes.Gs v2.0 &#187; fixes</title>
	<atom:link href="http://www.jes.gs/tag/fixes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jes.gs</link>
	<description>The Portfolio and Blog of Minneapolis Web Designer Jessica C. Green</description>
	<lastBuildDate>Sat, 21 Jan 2012 19:56:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Fixing ThickBox in WordPress 2.8</title>
		<link>http://www.jes.gs/htmlcss/how-to-fix-thickbox-in-wordpress-2-8/</link>
		<comments>http://www.jes.gs/htmlcss/how-to-fix-thickbox-in-wordpress-2-8/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 20:45:49 +0000</pubDate>
		<dc:creator>Jess G.</dc:creator>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Recommended]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[fixes]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://dumpster-fairy.com/?p=324</guid>
		<description><![CDATA[How to restore ThickBox functionality in Wordpress 2.8 and higher.]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using ThickBox then you&#8217;ve probably noticed that ThickBox is technically broken in WordPress 2.8. After trial-and-error, I&#8217;ve tracked down the problems and this is what&#8217;s happening and here is how to fix it.</p>
<p><ins datetime="2010-02-27T05:35:41+00:00" style="font-size:  medium; text-decoration: none; line-height: 1em; "><em><strong>Edit</strong>: February 27th, 2009. Finally had to time to check but the missing ThickBox CSS is still a problem in WordPress 2.9. My guess is that it might not be an actual bug but a feature to accommodate designers creating their own custom ThickBox designs.</em></ins></p>
<h3>WordPress 2.8 requires themes to have <strong>wp_footer()</strong></h3>
<p>WP 2.8 introduced a new option when using wp_enqueue_script() to load JavaScript files. It allows you the option of having the scripts load in the footer, which is why WordPress themes now require wp_footer() to work properly. However, that wasn&#8217;t my problem since I&#8217;d always added wp_head(), wp_meta() and wp_footer() as a matter of course when designing themes. So if the absence or presence of wp_footer() wasn&#8217;t the problem, then what was really going on?</p>
<h3>What&#8217;s with ThickBox anyway?</h3>
<p>Now, for the problem with ThickBox. So we know that it <em>is</em> being loaded, just in the footer. What I <em>have</em> found is that WordPress is <em>not</em> loading all of the files that ThickBox needs to work. jQuery <em>is</em> being loaded, so that can be ruled out. What <em>isn&#8217;t</em> being loaded is the CSS file that ThickBox needs to format its popup window. Also, another part of the problem is the ThickBox.js file itself has the paths to the images it needs set to relative paths.</p>
<h3>How we fix it</h3>
<p>Starting off, if you haven&#8217;t added the code to load ThickBox, go ahead and add <code>wp_enqueue_script( 'jquery' )</code> and <code>wp_enqueue_script( 'thickbox' )</code> to your header. Now what we do is we add <strong>wp_enqueue_style(&#8216;thickbox&#8217;)</strong> to our &lt;head&gt; section. I&#8217;ve seen people asking for wp_enqueue_css and &#8220;lamenting&#8221; the fact there isn&#8217;t such a function but there actually <em>is</em>, it is <strong><a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_style">wp_enqueue_style()</a></strong>. The second part requires adding to an existing functions.php file or creating a functions.php if it doesn&#8217;t exist with your current theme. In your functions.php file, copy and paste this code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_footer'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'load_tb_fix'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> load_tb_fix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;script type=&quot;text/javascript&quot;&gt;tb_pathToImage = &quot;'</span> <span style="color: #339933;">.</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'siteurl'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-includes/js/thickbox/loadingAnimation.gif&quot;;tb_closeImage = &quot;'</span> <span style="color: #339933;">.</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'siteurl'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-includes/js/thickbox/tb-close.png&quot;;&lt;/script&gt;'</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This fixes those first few lines of the ThickBox.js file that calls the images that ThickBox uses, and it is inserted in the footer <em>after</em> the call that inserts the reference to ThickBox.js.</p>
<p>So now, ThickBox functionality should be restored. Quick recap:</p>
<ol>
<li>Add the code below to your &lt;head&gt; section:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
wp_enqueue_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'jquery'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
wp_enqueue_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'thickbox'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
wp_enqueue_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'thickbox'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

</li>
<li>Then add this code to your functions.php file:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_footer'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'load_tb_fix'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> load_tb_fix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;script type=&quot;text/javascript&quot;&gt;tb_pathToImage = &quot;'</span> <span style="color: #339933;">.</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'siteurl'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-includes/js/thickbox/loadingAnimation.gif&quot;;tb_closeImage = &quot;'</span> <span style="color: #339933;">.</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'siteurl'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-includes/js/thickbox/tb-close.png&quot;;&lt;/script&gt;'</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

</li>
</ol>
<h3>Conclusion</h3>
<p>Had do some research to figure out what was going on besides just looking at my own source code. The first reference to this issue I found was at this link: <em><a href="http://kovshenin.com/archives/thickbox-and-jquery-in-wordpress-2-8/">ThickBox and jQuery in WordPress 2.8</a></em>, then I figured out how to fix the ThickBox dependency image loading issues by looking at the code for the NextGen Gallery plugin.</p>
<p>Good luck! And enjoy your restored ThickBox functionality <img src='http://www.jes.gs/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.jes.gs/htmlcss/how-to-fix-thickbox-in-wordpress-2-8/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

