<?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>Stranger Studios Blog &#187; PHP</title>
	<atom:link href="http://www.strangerstudios.com/blog/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.strangerstudios.com/blog</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 12 Jan 2012 21:34:46 +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>Don&#8217;t Break The Code</title>
		<link>http://www.strangerstudios.com/blog/2011/11/dont-break-the-code/</link>
		<comments>http://www.strangerstudios.com/blog/2011/11/dont-break-the-code/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 21:57:07 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[New Projects]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://www.strangerstudios.com/blog/?p=282</guid>
		<description><![CDATA[Last Saturday at WordCamp Philly, I ran a session on &#8220;Building a Plugin in One Night&#8221;. Together, with about 50+ attendees, we brainstormed ideas for a new WordPress plugin that I could code that night. The brainstorming went great, coming up with some good ideas&#8230; like plugins to: Help first responders after a disaster (Big [...]]]></description>
			<content:encoded><![CDATA[<p>Last Saturday at WordCamp Philly, I ran a session on &#8220;Building a Plugin in One Night&#8221;. Together, with about 50+ attendees, we brainstormed ideas for a new WordPress plugin that I could code that night.</p>
<p>The brainstorming went great, coming up with some good ideas&#8230; like plugins to:</p>
<ul>
<li>Help first responders after a disaster (Big Idea!)</li>
<li>Add VIM (a Linux editor) shortcut commands to the Visual Editor</li>
<li>Disable the Visual Editor on a per-post basis (The Winner)</li>
<li>Allow users to create pages from the front end</li>
<li>Add easy donations</li>
<li>Log into WordPress via Google+ (<a href="http://wordpress.org/extend/plugins/wp-google-plus-connect/">Brian did it!</a>)</li>
<li>Add syntax highlighting to the Visual Editor (<a href="https://github.com/inxilpro/html-editor-syntax-highlighter">Chris did it!</a>)</li>
</ul>
<p>The concept that the audience voted for me to work on was a way to disable the Visual Editor tab on a per-post basis. The motivation for this is the fact that the autoformatting of the Visual tab will sometimes break a complicated (or not so complicated) HTML structure ruining your code. Folks wanted a way to say, &#8220;Hey, WordPress, back off on this page/post.&#8221;</p>
<p>And someone (you introduced yourself to me later, but I forget your name) came up with a kick ass name: Don&#8217;t Break the Code. It explains the purpose and also harkens back to my days at Haverford College, which has a strong social/academic honor code.</p>
<p>I had hoped for something a little more mainstream. Only a developer or power user will really appreciate a plugin to disable the Visual tab, but that&#8217;s okay. The effort would be appreciated.</p>
<p>Turns out there are already a few plugins that either disable the Visual tab or remove other filters to keep WordPress from breaking code. The started trickling in after the presentation wrapped:</p>
<ul>
<li><a href="http://wordpress.org/extend/plugins/disable-visual-editor-wysiwyg/">Disable Visual Editor WYSIWYG</a></li>
<li><a href="http://wordpress.org/extend/plugins/raw-html/">Raw HTML</a></li>
<li><a href="http://wordpress.org/extend/plugins/deactive-visual-editor/">Deactivate Visual Editor</a></li>
<li><a href="http://wordpress.org/extend/plugins/always-edit-in-html/">Always Edit in HTML</a></li>
</ul>
<p>&#8230; and probably a few more. So we weren&#8217;t blazing new ground.</p>
<p>Still, some good ideas came up during the session that could improve the experience of using a plugin like this. Like:</p>
<ul>
<li>Put the checkbox to disable the editor in the screen options area so it doesn&#8217;t clutter up the editor</li>
<li>Only allow admins to disable the editor. Other roles will see what the admin chose.</li>
<li>Allow admins to add a note RE why the Visual Editor is disable.</li>
<li>Remove other filters (like wpautop) to lower interference even more.</li>
</ul>
<p>I spent the spare time I had during that day and then after the after party from midnight to 5:30am the next morning looking through the code in the existing plugins and piecing together the best pieces of them. I liked how &#8220;Disable Visual Editor WYSIWYG&#8221; just grayed out and struckthrough the Visual tab instead of removing it directly. I liked how Raw HTML put things in the screen options space and also how they allowed for disabling the other filters.</p>
<p>Anyway, the plugin released that morning on GitHub and then later at the Dev Day to the WP repository. You can grab it here:</p>
<p><a href="http://wordpress.org/extend/plugins/dont-break-the-code/">Don&#8217;t Break the Code WordPress Plugin</a></p>
<p>So far it allows admins to disable the Visual Tab just like we said. I improved on the DVE WYSIWYG plugin by disabling via Ajax for a better user experience (you don&#8217;t have to click update for it to take affect). And after trying to copy Raw HTML&#8217;s method of placing things in the screen options, decided to scratch that and just code it myself using some tutorials I found online.</p>
<p>It works nicely. I plan to add checkboxes for disabling other filters similar to Raw HTML and also want to include that &#8220;add a notice&#8221; functionality somehow. I was going to incorporate the syntax highlighting, but that works really well as a stand alone plugin. Chris&#8217;s code had some problems on my setup that I hope to look into and patch for him.</p>
<p>Let me know what you think of Don&#8217;t Break the Code. If you want to contribute, you can fork and patch <a href="https://github.com/strangerstudios/dont-break-the-code">via GitHub here</a>.</p>
<p>Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.strangerstudios.com/blog/2011/11/dont-break-the-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Disable the WordPress Admin Bar for Non-Admins Only</title>
		<link>http://www.strangerstudios.com/blog/2011/06/disable-the-wordpress-admin-bar-for-non-admins-only/</link>
		<comments>http://www.strangerstudios.com/blog/2011/06/disable-the-wordpress-admin-bar-for-non-admins-only/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 21:31:35 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.strangerstudios.com/blog/?p=232</guid>
		<description><![CDATA[Here is a variation of some code I found on Yoast.com to disable the WP admin bar for non-admins only. function yoast_hide_admin_bar_settings() { ?&#62; &#60;style type=&#34;text/css&#34;&#62; .show-admin-bar { display: none; } &#60;/style&#62; &#60;?php &#125; function yoast_disable_admin_bar&#40;&#41; &#123; if&#40;!current_user_can&#40;'administrator'&#41;&#41; &#123; add_filter&#40; 'show_admin_bar', '__return_false' &#41;; add_action&#40; 'admin_print_scripts-profile.php', 'yoast_hide_admin_bar_settings' &#41;; &#125; &#125; add_action&#40;'init', 'yoast_disable_admin_bar', 9&#41;; Just copy and [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a variation of some <a href="http://yoast.com/disable-wp-admin-bar/">code I found on Yoast.com</a> to disable the WP admin bar for non-admins only.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">function yoast_hide_admin_bar_settings() 
{
?&gt;
	&lt;style type=&quot;text/css&quot;&gt;
		.show-admin-bar {
			display: none;
		}
	&lt;/style&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> yoast_disable_admin_bar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>current_user_can<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'administrator'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'show_admin_bar'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'__return_false'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'admin_print_scripts-profile.php'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'yoast_hide_admin_bar_settings'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'yoast_disable_admin_bar'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Just copy and paste this code into your functions.php or another plugin/theme file that can add hooks. Save/upload and watch it work.</p>
<p>Let me know if you have any trouble using this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.strangerstudios.com/blog/2011/06/disable-the-wordpress-admin-bar-for-non-admins-only/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Duplicate comment detected; it looks as though you’ve already said that!</title>
		<link>http://www.strangerstudios.com/blog/2010/10/duplicate-comment-detected-it-looks-as-though-you%e2%80%99ve-already-said-that/</link>
		<comments>http://www.strangerstudios.com/blog/2010/10/duplicate-comment-detected-it-looks-as-though-you%e2%80%99ve-already-said-that/#comments</comments>
		<pubDate>Fri, 22 Oct 2010 14:24:24 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.strangerstudios.com/blog/?p=211</guid>
		<description><![CDATA[Not sure how long WordPress has been doing this, but there is a check for duplicate comments. If the same user/email posts the same exact comment on the same post, the user will get a message like: Duplicate comment detected; it looks as though you’ve already said that! This is great actually, and keeps people [...]]]></description>
			<content:encoded><![CDATA[<p>Not sure how long WordPress has been doing this, but there is a check for duplicate comments. If the same user/email posts the same exact comment on the same post, the user will get a message like:</p>
<blockquote><p>Duplicate comment detected; it looks as though you’ve already said that!</p></blockquote>
<p>This is great actually, and keeps people from submitting the same comment twice if they get impatient waiting for moderation or otherwise click that submit button twice.</p>
<p>As a blog owner and WordPress developer, there may be situations where you want to allow people to post the same comment. If you want to enable duplicate comments on your blog for some reason, you can use this code here. Just add it to your theme&#8217;s functions.php or put this in a .php in your plugins folder and enable it.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> enable_duplicate_comments_preprocess_comment<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment_data</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//add some random content to comment to keep dupe checker from finding it</span>
	<span style="color: #000088;">$random</span> <span style="color: #339933;">=</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
	<span style="color: #000088;">$comment_data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'comment_content'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;disabledupes{&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$random</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;}disabledupes&quot;</span><span style="color: #339933;">;</span>	
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$comment_data</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'preprocess_comment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'enable_duplicate_comments_preprocess_comment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> enable_duplicate_comments_comment_post<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment_id</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//remove the random content</span>
	<span style="color: #000088;">$comment_content</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_var</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT comment_content FROM <span style="color: #006699; font-weight: bold;">$wpdb-&gt;comments</span> WHERE comment_ID = '<span style="color: #006699; font-weight: bold;">$comment_id</span>' LIMIT 1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
	<span style="color: #000088;">$comment_content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/disabledupes\{.*\}disabledupes/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$comment_content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UPDATE <span style="color: #006699; font-weight: bold;">$wpdb-&gt;comments</span> SET comment_content = '&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment_content</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;' WHERE comment_ID = '<span style="color: #006699; font-weight: bold;">$comment_id</span>' LIMIT 1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/*
		add your own dupe checker here if you want
	*/</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comment_post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'enable_duplicate_comments_comment_post'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>For reference, here is the dupe check code in wp-includes/comment.php. A newer version should probably have a hook above and/or below to allow people to override the dupe checker more directly.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Simple duplicate check</span>
	<span style="color: #666666; font-style: italic;">// expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)</span>
	<span style="color: #000088;">$dupe</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT comment_ID FROM <span style="color: #006699; font-weight: bold;">$wpdb-&gt;comments</span> WHERE comment_post_ID = '<span style="color: #006699; font-weight: bold;">$comment_post_ID</span>' AND comment_approved != 'trash' AND ( comment_author = '<span style="color: #006699; font-weight: bold;">$comment_author</span>' &quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$comment_author_email</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$dupe</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;OR comment_author_email = '<span style="color: #006699; font-weight: bold;">$comment_author_email</span>' &quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$dupe</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;) AND comment_content = '<span style="color: #006699; font-weight: bold;">$comment_content</span>' LIMIT 1&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_var</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dupe</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		do_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'comment_duplicate_trigger'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$commentdata</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DOING_AJAX'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Duplicate comment detected; it looks as though you&amp;#8217;ve already said that!'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		wp_die<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Duplicate comment detected; it looks as though you&amp;#8217;ve already said that!'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.strangerstudios.com/blog/2010/10/duplicate-comment-detected-it-looks-as-though-you%e2%80%99ve-already-said-that/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SS-Downloads WordPress Plugin</title>
		<link>http://www.strangerstudios.com/blog/2010/07/ss-downloads-wordpress-plugin/</link>
		<comments>http://www.strangerstudios.com/blog/2010/07/ss-downloads-wordpress-plugin/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 21:25:00 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Client Work]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.strangerstudios.com/blog/?p=133</guid>
		<description><![CDATA[Testing our new SS-Downloads plugin. It basically will require an email address before serving a specified file. Right now, I&#8217;m using a zip of the pre-release plugin for testing. I will update this to point to the latest version once it&#8217;s ready. Should see a form or download link here. Future plans: Option to require [...]]]></description>
			<content:encoded><![CDATA[<p>Testing our new SS-Downloads plugin. It basically will require an email address before serving a specified file. Right now, I&#8217;m using a zip of the pre-release plugin for testing. I will update this to point to the latest version once it&#8217;s ready.</p>
<p>Should see a form or download link here.</p>
<div id="ss-downloads">
	<h3>Enter your email address to download <em>ss-downloads.zip</em></h3>
        
    <form action="http://www.strangerstudios.com/blog/wp-content/plugins/ss-downloads/services/addemail.php" method="post">
        <input class="input-text" size="50" placeholder="Enter your email address..." type="text" name="email" value="" />
        <input type="hidden" name="title" value="ss-downloads.zip" />
        <input type="hidden" name="file" value="Xffv://444.rftO6Cctrf9BZRr.zR8/WaRC/4v-zR6fc6f/va9CZ6r/rr-BR46aROBr.hZv" />
        <input type="submit" value="SUBMIT" />
        <input type="hidden" name="postid" value="133" />
    </form>
</div>
<p>Future plans:</p>
<ul>
<li><span style="text-decoration: line-through;">Option to require account creation (instead of just an email address).</span> Done</li>
<li><span style="text-decoration: line-through;">Option to email file as attachment instead of showing a link.</span> Done</li>
<li>Icons for files in template.</li>
</ul>
<h3>FAQ</h3>
<div id="_mcePaste"><strong>Q: My downloads are incomplete, corrupt, or otherwise not downloading&#8230; especially large files.</strong></div>
<div id="_mcePaste">A: This may be caused by a low memory issue or some other issue with serving the file through the getfile.php script. You can configure the plugin to simply redirect to the chosen file rather than serving it through the script by editing /ss-downloads/includes/setup.php and setting the GETFILE_REDIRECT value to true. The file will have to be served in a public web folder, and 733t hackers will be able to see the actual URL of the file.</div>
<div></div>
<div>Note: I&#8217;ve changed the GETFILE_REDIRECT to default to true. But if you have the inverse problem (the download is working, but you want to make it more secure by avoiding the redirect &#8212; which savvy users might be able to watch to get the URL of the file) you can set that value to false.</div>
<div></div>
<div><strong>Edit:</strong></div>
<div>Bob at 2bretired.com has a good writeup of <a href="http://2bretired.com/wordpress/?p=1153">how to clear out the download stats for your files</a> if you want to do that sort of thing.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.strangerstudios.com/blog/2010/07/ss-downloads-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>143</slash:comments>
		</item>
		<item>
		<title>WordPress get_the_content_after_more() Function</title>
		<link>http://www.strangerstudios.com/blog/2010/07/wordpress-get_the_content_after_more-function/</link>
		<comments>http://www.strangerstudios.com/blog/2010/07/wordpress-get_the_content_after_more-function/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 21:49:56 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.strangerstudios.com/blog/?p=90</guid>
		<description><![CDATA[In WordPress, if you want to get just the excerpt of a post, you can use the built-in functions the_excerpt or get_the_excerpt. And if you want all of the content, you can of course use the the_content or get_the_content functions. But what if you want to get everything BUT the excerpt? The Code Here is [...]]]></description>
			<content:encoded><![CDATA[<p>In WordPress, if you want to get just the excerpt of a post, you can use the built-in functions <a href="http://codex.wordpress.org/Template_Tags/the_excerpt">the_excerpt</a> or <a href="http://codex.wordpress.org/Function_Reference/get_the_excerpt">get_the_excerpt</a>. And if you want all of the content, you can of course use the <a href="http://codex.wordpress.org/Function_Reference/the_content">the_content</a> or <a href="http://codex.wordpress.org/Function_Reference/get_the_content">get_the_content</a> functions. <strong>But what if you want to get everything BUT the excerpt?</strong></p>
<h3>The Code</h3>
<p>Here is a function that will do that: get_the_content_after_more()</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> get_the_content_after_more<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> get_the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$moretag</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/\&lt;span id=&quot;</span>\<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>more<span style="color: #339933;">-</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*</span>\<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>\<span style="color: #0000ff;">&quot;&gt;\&amp;lt;\/span\&amp;gt;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$moretag</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$morespan</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$morespan_pos</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$morespan</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$newcontent</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$morespan_pos</span> <span style="color: #339933;">+</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$morespan</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$morespan</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$newcontent</span> <span style="color: #339933;">=</span> apply_filters<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newcontent</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$newcontent</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>How to Use This</h3>
<p>Notice that this is a &#8220;get_&#8221; version of the function. So you will get to echo the results or save them to a variable for future use. Just plop an <strong>echo get_the_content_after_more()</strong> into your LOOP and you&#8217;re good to go.</p>
<h3>How it Works</h3>
<p>The function works by getting the post content through &#8220;get_the_content&#8221; (and so will give you the content for the current post in your loop) and looking (preg_match) for the span tag that WordPress puts at the more break. (If older versions of WordPress don&#8217;t add this tag, this function won&#8217;t work. But this works in 2.9-3.0 at least.)</p>
<p>If a more tag is found, I create a variable $newcontent holding everything after the more tag. Then I run it through apply_filters to all of your plugins/etc that work on the_content will work on this.</p>
<p>If a post doesn&#8217;t have an excerpt (no excerpt or more tag in the post), the function returns an empty string.</p>
<p>The function could easily be called get_the_inverse_excerpt or get_the_content_after_excerpt or get_the_content_minus_excerpt. Let me know if you have a better idea for this&#8230; or tell me what you searched for to figure this out.</p>
<h3>Why Would I Use This?</h3>
<p>Kim was updating our portfolio page, which is really a list of WordPress posts. She wanted to style the &#8220;excerpt&#8221; differently from the rest of the content. Notice how the top section (&#8220;WineLog is&#8230;&#8221;) is in a gradient box on the <a href="http://www.strangerstudios.com/2009/07/winelog-net/">WineLog portfolio item</a>&#8230; and then the rest is styled as written in the post content. We used code like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;div class=&quot;excerpt&quot;&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>    
    the_excerpt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>     	
    <span style="color: #b1b100;">echo</span> get_the_content_after_more<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>			
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>When we decided to do this, I first checked if WordPress was adding some tag around the excerpt that we could piggy back on. Nope. All that is added is a span like <span class="more-222"> </span> at the point where the more break is. Then I looked for a buit-in function or some parameter of the_content that could be used to do this. No luck. (Let me know if there is a built-in way to do this.)</p>
<h3>If I Were Updating WordPress&#8230;</h3>
<p>&#8230; and it&#8217;s open source. So maybe I will. One could add a parameter to the_content/get_the_content functions to exclude the excerpt. The code would be largely the same, though they could look for the more tag itself since they won&#8217;t have that stripped out yet. That feels clunky to me. Let me know if you have better ideas.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.strangerstudios.com/blog/2010/07/wordpress-get_the_content_after_more-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On Ustream: WordPress Plugin to Capture Email Addresses in Exchange For a File Download</title>
		<link>http://www.strangerstudios.com/blog/2010/06/on-ustream-wordpress-plugin-to-capture-email-addresses-in-exchange-for-a-file-download/</link>
		<comments>http://www.strangerstudios.com/blog/2010/06/on-ustream-wordpress-plugin-to-capture-email-addresses-in-exchange-for-a-file-download/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 18:58:33 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Client Work]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Constant Contact]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugin Directory]]></category>

		<guid isPermaLink="false">http://www.strangerstudios.com/blog/?p=61</guid>
		<description><![CDATA[Update: No longer streaming. The plugin works great. Kim is going to make it pretty, then I&#8217;ll post to WordPress and do a right up. I&#8217;m streaming live right now while I work on a WordPress plugin. Follow me at ustream.tv/channel/stranger-studios. I&#8217;ll be working on a plugin for a feature that we&#8217;ve done a million [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> No longer streaming. The plugin works great. Kim is going to make it pretty, then I&#8217;ll post to WordPress and do a right up.</p>
<p>I&#8217;m <a href="http://www.ustream.tv/channel/stranger-studios">streaming live</a> right now while I work on a WordPress plugin. Follow me at <a href="http://www.ustream.tv/channel/stranger-studios">ustream.tv/channel/stranger-studios</a>.</p>
<p>I&#8217;ll be working on a plugin for a feature that we&#8217;ve done a million different ways: asking for a user&#8217;s email address in exchange for a link to a file download. A solid plugin for this will save us a lot of time. If it turns out well, I&#8217;ll put it in the WP plugin directory and link to it from here.</p>
<p>Here are the requirements/specs I have for this plugin:</p>
<ul>
<li>Should use a short code of the form [filedownload: /path/to/file.txt] to define where the form should go and what file.</li>
<li>The form will submit to the current page, log the email entered, add a session flag.</li>
<li>If an email is in $_POST, the post/page will show the download link instead of the email form.</li>
<li>Files will be hidden behind a script to obscure the path to the file. The script will check for the session flag before returning the file.</li>
<li>Should use a template to make it easy to change the HTML/CSS for the form.</li>
<li>Should be easy to adjust the addEmail code to work with Constant Contact/etc.</li>
</ul>
<p>That&#8217;s it. Please join me. Post questions to the chat. Again, if this code comes out clean, I hope to share it.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="border: none; float: right;" src="http://img.zemanta.com/zemified_e.png?x-id=d354f9b6-a336-4f12-8416-77025c673772" alt="Enhanced by Zemanta" /></a><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.strangerstudios.com/blog/2010/06/on-ustream-wordpress-plugin-to-capture-email-addresses-in-exchange-for-a-file-download/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Unit of Measure PHP Class</title>
		<link>http://www.strangerstudios.com/blog/2010/02/unit-of-measure-php-class/</link>
		<comments>http://www.strangerstudios.com/blog/2010/02/unit-of-measure-php-class/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 03:17:55 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[New Projects]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.strangerstudios.com/blog/?p=52</guid>
		<description><![CDATA[For a recent project, we developed a php class that made it easier to work with units of measure. I was surprised that there wasn&#8217;t anything like this available out there, so we decided to open source the code once it was in a good state. That day has come. We will be updating this [...]]]></description>
			<content:encoded><![CDATA[<p>For a recent project, we developed a php class that made it easier to work with units of measure. I was surprised that there wasn&#8217;t anything like this available out there, so we decided to open source the code once it was in a good state. That day has come.</p>
<p>We will be updating this code (and this blog post) over the next few days and likely down the road as well. But in the meantime, here is a link to the GitHub repository: <a href="http://github.com/strangerstudios/phpUOM">phpUOM on GitHub</a>.</p>
<p>(If this goes well, we&#8217;ll hopefully be open sourcing a bit more of our code in the future.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.strangerstudios.com/blog/2010/02/unit-of-measure-php-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hidden 404 Errors with WordPress Plugin Pages</title>
		<link>http://www.strangerstudios.com/blog/2009/08/hidden-404-errors-with-wordpress-plugin-pages/</link>
		<comments>http://www.strangerstudios.com/blog/2009/08/hidden-404-errors-with-wordpress-plugin-pages/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 18:01:04 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.strangerstudios.com/blog/?p=46</guid>
		<description><![CDATA[After a couple hours, I've tracked down and fixed a bug I was having with some of our Wordpress plugins. I believe that there are a few people out there having the same problem. I think there may be another solution online, but it is one of those issues that is difficult to pare down to a good search query.

Anyway here is a solution for "404 issues with plugin pages" or "lynx shows a 404, but the page still loads", or "Google Webtools says there is a 404, but I can get to the page", or "setting status to 200:OK still results in 404", or "I get a 404 in IE, but refreshing the page brings it up", or "I get random 404 errors in IE", or "I'm getting an <em style="font-weight: bold; font-style: normal;">HTTP</em>/<em style="font-weight: bold; font-style: normal;">1.1 404</em><span> </span>Not Found error but the page still loads".]]></description>
			<content:encoded><![CDATA[<p>After a couple hours, I&#8217;ve tracked down and fixed a bug I was having with some of our WordPress plugins. I believe that there are a few people out there having the same problem. I think there may be another solution online, but it is one of those issues that is difficult to pare down to a good search query.</p>
<p>Anyway here is a solution for &#8220;404 issues with plugin pages&#8221; or &#8220;lynx shows a 404, but the page still loads&#8221;, or &#8220;Google Webtools says there is a 404, but I can get to the page&#8221;, or &#8220;setting status to 200:OK still results in 404&#8243;, or &#8220;I get a 404 in IE, but refreshing the page brings it up&#8221;, or &#8220;I get random 404 errors in IE&#8221;, or &#8220;I&#8217;m getting an <em style="font-weight: bold; font-style: normal;">HTTP</em>/<em style="font-weight: bold; font-style: normal;">1.1 404</em><span> </span>Not Found error but the page still loads&#8221;.</p>
<p>You may <a href="#finalsolution">skip ahead to the Final Solution code</a>, but it is probably a good idea to read everything below to make sure that you are indeed having the same issue I had&#8230; and that this will actually fix your problem.</p>
<h3>The Context</h3>
<p>I have some WordPress plguins (Stranger Products, Stranger Events) that generate pages outside of the core WordPress system (i.e. they are not &#8220;wordpress pages&#8221; in the WP DB, they are web pages generated by our plugin script). To serve these pages, I add a bunch of rules to the .htaccess file to redirect stuff like /products/1/ to a product info page.</p>
<p>Some gallery plugins or other plugins that generate new pages may have a similar setup/issue.</p>
<h3>The Problem</h3>
<p>While the mod rewrite works fine, and the page loads fine, WordPress doesn&#8217;t find a WP page or post for the query string and so sends a &#8220;HTTP/1.1 404 File Not Found&#8221; status in the header. Most web browsers will ignore this and show the content that comes after the header. It seems that IE will sometimes choke on this status, and other times show the page. Funny IE!</p>
<p>Google&#8217;s crawler however will not crawl that page and will let you know in a web toolkit report. Also, I noticed that the lynx command line browser for Linux would show the 404 error and then load the page.</p>
<p>The big issue here is that Google is not going to crawl our page.</p>
<h3>The Fix</h3>
<p>I spent a lot of time tracking down where in the WordPress code the 404 status is set. Ideally, there would be a plugin &#8220;hook&#8221; near this that we could use to prevent the 404 status from reaching the browser.</p>
<p>The function that makes the 404 decision is handle_404(), which can be found in the /wp-includes/classes.php file. Here is the code (for WordPress 2.8.4, similar for previous versions I looked at too):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> handle_404<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">==</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">posts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>is_404<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>is_search<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">did_permalink</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'QUERY_STRING'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">===</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'?'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Don't 404 for these queries if they matched an object.</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> is_tag<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_category<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_author<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_queried_object</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>is_404<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
				status_header<span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">200</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_404</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		status_header<span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">404</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		nocache_headers<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>is_404<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		status_header<span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">200</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This would be the ideal place to say, &#8220;Hey, don&#8217;t 404 this page&#8221;, but there is no hook in here. I tried setting the $wp->did_permalink flag to FALSE, which worked sometimes, but sometimes WordPress would write that back to TRUE after I reset it. And I&#8217;m not even sure what that flag is doing; so playing with it might cause some bugs elsewhere.</p>
<p>The next place to check is the status_header() function called by handle_404. This function is found in the /wp-includes/functions.php file. Here is the code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> status_header<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$header</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> get_status_header_desc<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$header</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$text</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$protocol</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SERVER_PROTOCOL&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'HTTP/1.1'</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$protocol</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #0000ff;">'HTTP/1.0'</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$protocol</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$protocol</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'HTTP/1.0'</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$status_header</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$protocol</span> <span style="color: #006699; font-weight: bold;">$header</span> <span style="color: #006699; font-weight: bold;">$text</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'apply_filters'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$status_header</span> <span style="color: #339933;">=</span> apply_filters<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'status_header'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$status_header</span><span style="color: #339933;">,</span> <span style="color: #000088;">$header</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$protocol</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #339933;">@</span><span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$status_header</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #000088;">$header</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Tada! This function uses the &#8220;status_header&#8221; hook/filter before updating the header. So we can create a function in our plugin to check the status for a 404 and then return false/NULL if we know that there really is a page to load. Here&#8217;s how I did it.</p>
<p><a name="finalsolution"></a><br />
<h3>The Final Solution</h3>
<p>In PHP code for my pages, I created a global variable called $isapage and set it to true. So at the very top of any page that is giving the 404 errors, add this code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$isapage</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$isapage</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now I add the following function and filter to my plugin code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//this function checks if we have set the $isapage variable, and if so prevents WP from sending a 404</span>
<span style="color: #000000; font-weight: bold;">function</span> ssp_status_filter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$isapage</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$isapage</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;404&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">//don't send the 404</span>
	<span style="color: #b1b100;">else</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$s</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'status_header'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ssp_status_filter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I hope this helps some people out there. </p>
<p>Feel free to critique this solution. Let me know if I missed something or if there are better ways to do this. </p>
<p>Feel free to post related issues. I may have found solutions to those along the way&#8230; or maybe a commenter can help you out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.strangerstudios.com/blog/2009/08/hidden-404-errors-with-wordpress-plugin-pages/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Introducing TopWhatever</title>
		<link>http://www.strangerstudios.com/blog/2009/02/introducing-topwhatever/</link>
		<comments>http://www.strangerstudios.com/blog/2009/02/introducing-topwhatever/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 20:43:40 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[New Projects]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.strangerstudios.com/blog/2009/02/05/introducing-topwhatever/</guid>
		<description><![CDATA[A new product from Stranger Studios. TopWhatever will change your life. From the about page: TopWhatever helps you make decisions by walking you through the process of creating a &#8220;decision matrix&#8221;. Using the matrix, you can weigh your options against the criteria that are important to you. Some decisions can get complicated quickly. The decisions [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.topwhatever.com"><img border="0" align="right" style="padding: 0pt 0pt 5px 5px" alt="TopWhatever" src="http://www.strangerstudios.com/blog/wp-content/uploads/2009/02/TopWhatever.gif" /></a>A new product from Stranger Studios. <a href="http://www.topwhatever.com">TopWhatever</a> will change your life. From the about page:</p>
<blockquote><p><span class="Apple-style-span" style="border-collapse: separate; color: #222222; font-family: Verdana; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px" /></p>
<p style="margin: 5px 0px 8px; padding: 0px">TopWhatever helps you make decisions by walking you through the process of creating a &#8220;decision matrix&#8221;. Using the matrix, you can weigh your options against the criteria that are important to you.</p>
<p style="margin: 5px 0px 8px; padding: 0px">Some decisions can get complicated quickly. The decisions you end up making can feel subjective rather than objective. TopWhatever helps you take things step by step. You end up with a decision that is sound, with the math to prove it.</p>
<p style="margin: 5px 0px 8px; padding: 0px">The best way to understand how TopWhatever works is to view<span class="Apple-converted-space"> </span><a style="color: #58b7dd" href="http://www.strangerstudios.com/browse">decisions that have already been made</a>.</p>
</blockquote>
<p>So check it out already. <a title="TopWhatever - Decision Matrix Tool" href="http://www.topwhatever.com">Use TopWhatever to make a decision</a> that has been on your mind lately.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.strangerstudios.com/blog/2009/02/introducing-topwhatever/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interactive 8-Ball Facebook App</title>
		<link>http://www.strangerstudios.com/blog/2007/06/interactive-8-ball-facebook-app/</link>
		<comments>http://www.strangerstudios.com/blog/2007/06/interactive-8-ball-facebook-app/#comments</comments>
		<pubDate>Thu, 28 Jun 2007 22:21:59 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Interactive 8ball]]></category>
		<category><![CDATA[New Projects]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WineLog]]></category>

		<guid isPermaLink="false">http://www.strangerstudios.com/blog/2007/06/28/interactive-8-ball-facebook-app/</guid>
		<description><![CDATA[So we&#8217;ve jumped on the Facebook bandwagon a bit. You can now install the Interactive 8-Ball application to your Facebook profile. Why would you want to install I8B on your Facebook profile? I don&#8217;t know, but if you use Facebook as your homepage instead of iGoogle it&#8217;s nice to have I8B right there. We also [...]]]></description>
			<content:encoded><![CDATA[<p>So we&#8217;ve jumped on the Facebook bandwagon a bit. You can now <a href="http://apps.facebook.com/bettereightball">install the Interactive 8-Ball application to your Facebook profile</a>.</p>
<p><strong>Why would you want to install I8B on your Facebook profile?<br />
</strong>I don&#8217;t know, but if you use Facebook as your homepage instead of <a href="http://www.google.com/ig">iGoogle</a> it&#8217;s nice to have I8B right there. We also update your profile and mini feed every time you ask a question through Facebook. Although this last bit can get tricky; we had a lady email us to take down a question she asked about a love prospect for fear of being had. (Which only gave us another idea for a Facebook app that we might share at some point.)</p>
<p><strong>And What Happened?</strong><br />
I8B got a ton of traffic. In three days, we got 400 people to install the new application. Traffic to I8B trippled to 800 visits a day and then&#8230; leveled out. We actually lost 5-10 users today as people have started to uninstall the application. So growth is not exactly parabolic so far.</p>
<p>I guess we need something more to help the spread. (This blog post? A mention at <a href="http://www.techcrunch.com">TechCrunch</a>? Maybe I&#8217;ll resubmit I8B to <a href="http://www.emilychang.com/go/ehub">Emily Chang&#8217;s eHub</a>.) It would be nice to have the 20,000 users that the other lame-o eight ball application on there has. Of course they got there first and so are high in the app directory and have the catchy URL at apps.facebook.com/eightball. (ours is apps.facebook.com/bettereightball) <img src='http://www.strangerstudios.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>What&#8217;s next?<br />
</strong>A <a href="http://www.winelog.net">WineLog</a> app for Facebook, duh. The I8B stuff was kind of a primer for work on a WineLog application. And good thing too. It is nice to work out all of the kinks using a brand that we aren&#8217;t as invested in. <a href="http://padrenel.blogs.experienceproject.com/3459.html">This article</a> helped me a bunch, but it also took a lot of hacking around to figure out what he meant by everything. The toughest part was fixing Facebook&#8217;s broken PHP4 client. Don&#8217;t even try messing with that unofficial one. If anyone needs help, shoot me an email or IM.</p>
<p>Anyway, a WineLog app would be fun. Again, I would rather just go to WineLog to see what my friends are drinking. But if you spend your day at Facebook, it&#8217;s sweet to get notifications on what people are logging. And it will hopefully introduce WineLog to some new folks. Cross your fingers.</p>
<p><strong>UPDATE:</strong> Here are links to my versions of the facebook api scripts. Download them and rename them to .php. I hope to comment up the code when I get a chance, so you can see what I changed. But in the meantime, this might be a better starting place for you than Facebook&#8217;s version.</p>
<blockquote><p><a href="http://www.strangerstudios.com/sandbox/facebook/facebook.txt">facebook.php</a><br />
<a href="http://www.strangerstudios.com/sandbox/facebook/facebookapi_php4_restlib.txt">facebookapi_php4_restlib.php</a><br />
<a href="http://www.strangerstudios.com/sandbox/facebook/IsterXmlSimpleXMLImpl.txt">IsterXmlSimpleXMLImpl.php</a></p>
</blockquote>
<p>Download all of the above files, rename them to .php, and follow the <a href="http://developers.facebook.com/step_by_step.php">tutorial instructions here</a> (or do whatever you&#8217;re doing). The strange one at the bottom is a library to handle XML objects (PHP5 does this natively I suppose). Read here for <a href="http://www.ister.org/code/simplexml44/index.html">more on simplexml44</a>. Or here is <a href="http://www.strangerstudios.com/sandbox/facebook/simplexml44-0_4_4.tar.gz">the entire simplexml gzip file</a> as I unzipped and installed it on my server.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.strangerstudios.com/blog/2007/06/interactive-8-ball-facebook-app/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

