<?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>SEO Web Design with Binh Nguyen &#187; Debugging</title>
	<atom:link href="http://www.binh.name/computing/debugging/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.binh.name</link>
	<description>Freebies for SEO, Web design, computers, blogging</description>
	<lastBuildDate>Thu, 25 Jun 2009 21:40:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Fixing Post Teaser Plugin Bug for WP 2.3.1</title>
		<link>http://www.binh.name/fixing-post-teaser-plugin-bug-for-wp-231/</link>
		<comments>http://www.binh.name/fixing-post-teaser-plugin-bug-for-wp-231/#comments</comments>
		<pubDate>Fri, 16 Nov 2007 16:15:03 +0000</pubDate>
		<dc:creator>Bình</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Wordpress Plugins]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Site]]></category>

		<guid isPermaLink="false">http://www.binh.name/?p=39</guid>
		<description><![CDATA[Have you ever had problem with Post Teaser plugin for WordPress? I am using it and I found a bug. So I fixed the bug and now you can download it right from this page. I name it "Post Teaser 2" just so It won't mess up with the original one. It's now available for [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever had problem with <strong><a href="http://wordpress.org/extend/plugins/post-teaser/" title="Visit plugin homepage">Post Teaser</a></strong> plugin for WordPress? I am using it and I found a bug. So I fixed the bug and now you can download it right from this page. I name it "Post Teaser 2" just so It won't mess up with the original one.</p>
<p>It's now available for download from this page: <a href="http://www.binh.name/?attachment_id=43" rel="attachment wp-att-43" title="Post Teaser 2 - An Essential WordPress Plugin">Post Teaser 2 - An Essential WordPress Plugin</a>.</p>
<h2>The Bug</h2>
<p>When I click the Update Options button on the Manage Post Teaser page, I got this: "Cannot load post-teaser.php." as shown in the snapshot:</p>
<p align="center"><img src="http://binh.name/files/2007/11/post-teaser-bug.png" alt="Post Teaser Bug" /></p>
<h2>Locating the bug</h2>
<p>It's annoying abit, but it's also easy to fix. I notice the following URL after the button is clicked:</p>
<blockquote><p>http://binh.name/wp/wp-admin/options-general.php?page=post-teaser.php&amp;saved=true</p></blockquote>
<p>And this is the URL before the button is clicked:</p>
<blockquote><p>http://binh.name/wp/wp-admin/options-general.php?page=post-teaser/post-teaser.php</p></blockquote>
<p>The different here is noticable.</p>
<ul>
<li>The failed query is: post-teaser.php&amp;saved=true</li>
<li>The unfailed query is: post-teaser/post-teaser.php</li>
</ul>
<p>So the correct query for saving the options should be: <strong>post-teaser/post-teaser.php&amp;saved=true</strong></p>
<h2>Debugging it</h2>
<p><strong>Open </strong>file "post-teaser/post-teaser.php" in the Plugin Editor (found in the Plugins page in Admin panel).</p>
<p><strong>Search </strong>for the string "post-teaser.php&amp;saved=true" in the file , and found the following lines:</p>
<ul>
<li> 101: header('Location: ' . get_settings('siteurl') . '/wp-admin/options-general.php?page=post-teaser.php&amp;saved=true');</li>
<li>103: 				header('Location: ' . get_settings('siteurl') . '/wp-admin/options-general.php?page=post-teaser.php&amp;saved=true');</li>
</ul>
<p><strong>Replace </strong>"post-teaser.php&amp;saved=true" with "post-teaser/post-teaser.php&amp;saved=true" and we get:</p>
<ul>
<li>101: header('Location: ' . get_settings('siteurl') . '/wp-admin/options-general.php?page=post-teaser/post-teaser.php&amp;saved=true');</li>
<li>103: 				header('Location: ' . get_settings('siteurl') . '/wp-admin/options-general.php?page=post-teaser/post-teaser.php&amp;saved=true');</li>
</ul>
<p><strong>Alternatively</strong> you could edit the plugin file locally then upload it.</p>
<p>A <strong>screenshot</strong> where it is located:</p>
<p><a href="http://www.binh.name/?attachment_id=41" rel="attachment wp-att-41" title="Edit Post Teaser Code File"></a></p>
<p style="text-align: center"><a href="http://www.binh.name/?attachment_id=41" rel="attachment wp-att-41" title="Edit Post Teaser Code File"><img src="http://binh.name/files/2007/11/post-teaser-bug-edit.thumbnail.png" alt="Edit Post Teaser Code File" /></a></p>
<p><strong>Problem Fixed:</strong></p>
<p style="text-align: center"><a href="http://www.binh.name/?attachment_id=42" rel="attachment wp-att-42" title="Post Teaser Bug Fixed"><img src="http://binh.name/files/2007/11/post-teaser-bug-fixed.png" alt="Post Teaser Bug Fixed" /></a></p>
<h2>Conclusion</h2>
<p>The author of this plugin actually wrote it up to version 2.3 of WordPress. Or maybe because he just didn't mean to have the user keep the post-teaser.php file under the post-teaser folder. Either way, I hope when writing the plugin and packaging it the author should consider the end user first.</p>
<p>I, a web developer still didn't realise I had to extract the php file into the plugins folder instead of the whole folder which contains the php file? Most of the plugins come packaged with readme.txt, plugin-name.pot, etc. How does the user know what to do without reading pages of documentation? We should make it simple for the end users. KISS principle is appreciated.</p>
<p>Since this wonderful plugin has a public license I would like to continue supporting it. If you have any problem please feel free to leave a comment on this page.  And... sorry I couldn't fix the translation files. So if you are using another language, please bear not having it, or modify the original file as directed by this debugging tutorial.</p>
<p>You can directly <a href="http://binh.name/files/2007/11/post-teaser-2.zip">download Post Teaser 2 now</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.binh.name/fixing-post-teaser-plugin-bug-for-wp-231/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing Dangerous Permalink Redirect Bugs</title>
		<link>http://www.binh.name/fixing-dangerous-permalink-redirect-bugs/</link>
		<comments>http://www.binh.name/fixing-dangerous-permalink-redirect-bugs/#comments</comments>
		<pubDate>Thu, 15 Nov 2007 19:37:32 +0000</pubDate>
		<dc:creator>Bình</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Wordpress Plugins]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://www.binh.name/?p=35</guid>
		<description><![CDATA[Since I have more than one occasion encounter bug with Permalink Redirect, I recommend people wait for new version of this plug-in. The Bugs The following are the bugs: Redirect "/feed" URI to "/feed/" using 302 redirect. Ignoring the "/%postname%" rule having no trailing slash. Redirect "/?paged=x" to "/page/x/" (where x is paging number) ingoring [...]]]></description>
			<content:encoded><![CDATA[<p>Since I have more than one occasion encounter bug with <strong><a href="http://fucoder.com/code/permalink-redirect/" title="Permalink Redirect WordPress Plugin">Permalink Redirect</a></strong>, I recommend people wait for new version of this plug-in.</p>
<h2>The Bugs</h2>
<p>The following are the bugs:</p>
<ol>
<li>Redirect "/feed" URI to "/feed/" using 302 redirect. Ignoring the "/%postname%" rule having no trailing slash.</li>
<li>Redirect "/?paged=x" to "/page/x/" (where x is paging number) ingoring the fact ugly default URL is used, causing 404 message when paging.</li>
</ol>
<p>There is no doubt about these bugs, because I test it by enabling and disabling Permalink Redirect plugin.</p>
<h2>Fixing the bugs</h2>
<p>Indeed being a programmer gives me some advantages, I could fix the bugs on the fly.</p>
<h3>Feed redirect trailing slash</h3>
<p>For the /feed to /feed/ redirect problem, I found these lines:</p>
<blockquote><p>208        if (is_feed()) {<br />
209            $link = trailingslashit($link) . 'feed/';<br />
210        }</p></blockquote>
<p>Solution:</p>
<ol>
<li>If want no trailing slash, remove the "/" on line 209.</li>
<li>If it's WordPress 2.3.1+ simply remove the 3 lines because it's built-in.</li>
<li>If you don't want to touch code, include the  following in the Options &gt; Permalink Redirect &gt; Paths to be skipped: "<strong>.+/feed</strong>.*" (without the quotes)</li>
</ol>
<h3>Page redirect ignoring permalink rule</h3>
<p>For the /?page=x to /paged/x/ problem, I found this line:</p>
<blockquote><p>204    if ($paged)<br />
205        $link = trailingslashit($link) . "page/$paged/";</p></blockquote>
<p>Solution:</p>
<ol>
<li>If  WordPress 2.3.1+, remove the lines because it's done better.</li>
<li>If you don't want to touch code, include the  following in the Options &gt; Permalink Redirect &gt; Paths to be skipped: "<strong>.+/?paged=.*</strong>" (without the quotes)</li>
</ol>
<h2>Conclusion</h2>
<p>Even being buggy, and not recommended by WordPress 2.3.1 which claim having internal redirect, Permalink Redirect still provide some benefit that built-in redirect doesn't offer, such as:</p>
<ol>
<li>Redirect permalink from old structure to new structure</li>
<li>Redirect broken, or wrong URL, providing the post id is correct, or enough matching words in post slug.</li>
<li>Redirect feed url from "/?feed=rss" to "/feed" or "/feed/" depending your customization.</li>
</ol>
<p>This plug-in is indeed getting a lot of my attention. I have more liking for it than the bult-in redirect. So, whenever I have time I will investigate deeper into the code and optimize it for better usage.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.binh.name/fixing-dangerous-permalink-redirect-bugs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Case Sensitive &#8211; Firefox JavaScript Becomes Tricky</title>
		<link>http://www.binh.name/case-sensitive-firefox-javascript-become-tricky/</link>
		<comments>http://www.binh.name/case-sensitive-firefox-javascript-become-tricky/#comments</comments>
		<pubDate>Mon, 12 Nov 2007 15:51:05 +0000</pubDate>
		<dc:creator>Bình</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Google Adsense]]></category>
		<category><![CDATA[Plugin]]></category>

		<guid isPermaLink="false">http://www.binh.name/?p=21</guid>
		<description><![CDATA[Problem: On Tuesday the 25th of September 2007 I was having this annoying bug. I was testing my website using FireFox (my main browser). I found out I couldn't send my page description to Digg using the following Digg JavaScript variable: digg_body = document.getElementsByName("description")[0].content While Internet Explorer, my 2ndary browser worked fine with it. Debug [...]]]></description>
			<content:encoded><![CDATA[<h2>Problem:</h2>
<p>On Tuesday the 25th of September 2007 I was having this annoying bug. I was testing my website using FireFox (my main browser). I found out I couldn't send my page description to <a href="http://digg.com" title="Open Digg. Hold Ctrl to open in new window">Digg</a> using the following Digg JavaScript  variable:</p>
<p><code>digg_body = document.getElementsByName("description")[0].content</code></p>
<p>While Internet Explorer, my 2ndary browser worked fine with it.</p>
<h2>Debug Process:</h2>
<p>The debug process was done  using the alert statement to show the object.</p>
<p><code>alert (document.getElementsByName("description")[0].content);</code></p>
<p>When the page is loaded in Internet Explorer 7, the alert statement  shows a pop up message containing the page description. While in  FireFox it return NULL. I couldn't see anything wrong with the syntax.  After many hours trying to fix, the problem was actually too simple. In  the HTML page I got</p>
<p><code>&lt;meta name="Description" content="some text..."&gt;</code></p>
<p>Instead of</p>
<p><code>&lt;meta name="description" content="some text..."&gt;</code></p>
<h2>Debug Result:</h2>
<p>The only different here is the "D" in the actual code, as apposed to the "d" as what the FireFox JavaScript was looking for.</p>
<p>The cause of the problem is that, the meta Description tag was  placed automatically by the ASP.NET code, so I had to modify the  JavaScript instead.</p>
<h2>Lesson learned:</h2>
<p>FireFox is very strict in JavaScript casing. So watch out for the  bug similar to this and save you some time wondering what's wrong with  the "perfect" code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.binh.name/case-sensitive-firefox-javascript-become-tricky/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.362 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-09 22:31:03 -->
<!-- Compression = gzip -->
