<?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>SleePyCode &#187; General</title>
	<atom:link href="http://sleepycode.com/tags/general/feed/" rel="self" type="application/rss+xml" />
	<link>http://sleepycode.com</link>
	<description>/dev/random</description>
	<lastBuildDate>Tue, 31 Jan 2012 05:05:35 +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>WordPress templates on non wordpress pages</title>
		<link>http://sleepycode.com/2011/11/wordpress-templates-on-non-wordpress-pages/</link>
		<comments>http://sleepycode.com/2011/11/wordpress-templates-on-non-wordpress-pages/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 04:09:32 +0000</pubDate>
		<dc:creator>SleePy</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Site]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://sleepycode.com/?p=1615</guid>
		<description><![CDATA[I have a couple pages such as my password generate that are non wordpress templates. However I want these to be styled as if they where from my wordpress. So after some google searches, I came up with very little information. I decided to dive into the code and came up with something that works [...]]]></description>
			<content:encoded><![CDATA[<p>I have a couple pages such as my password generate that are non wordpress templates.  However I want these to be styled as if they where from my wordpress.  So after some google searches, I came up with very little information.  I decided to dive into the code and came up with something that works for what I need it to do and requires little code edits to any of my pages to work.</p>
<p>This does also require a template edit to your wordpress templates.  Sadly I couldn&#8217;t avoid this, I looked around and tried to see if I could modify the_content(), however it doesn&#8217;t look very pleasant to do so.  I might in the future look into doing this.  If somebody has a better solution that requires no wordpress template edits, please let me know.  Back on topic, I modified page.php in my template and changed:</p>
<pre class="wp-code-highlight prettyprint linenums:1"  style="margin-bottom: 0 !important;">
					&lt;?php the_content(); ?&gt;
</pre>
<p>To this line:</p>
<pre class="wp-code-highlight prettyprint linenums:1" >
					&lt;?php if (isset($specialPageContent)) echo $specialPageContent; else the_content(); ?&gt;
</pre>
<p>Next I will just dump a file I named wp-ssi.php and explain how it works at the end.</p>
<pre class="wp-code-highlight prettyprint linenums:1" >
&lt;?php
// Change the default template to use.
define('WP_SSI_DEFAULT_TEMPLATE', 'page');

// Register a shutdown function (DOES THE ACTUAL WORK!)
register_shutdown_function('do_wp_ssi_wrap');

// Don't output anything yet.
ob_start();

// Get WordPress going.
require_once('./wp-blog-header.php');

// The shutdown function that does the actual work.
function do_wp_ssi_wrap()
{
	global $specialPageContent;

	// Simply get all contents.
	$specialPageContent = ob_get_clean();

	// Allow some over rides.
	$theme = defined('WP_SSI_THEME') ? WP_SSI_THEME : get_template_directory();
	$template = defined('WP_SSI_TEMPLATE') ? WP_SSI_TEMPLATE : WP_SSI_DEFAULT_TEMPLATE;

	// Pass it on as if it was a page.
	require($theme . '/' . $template . '.php');
}
</pre>
<p>Now for all my files I add at the very top.  Of course, you need to substitute the path to match yours.</p>
<pre class="wp-code-highlight prettyprint linenums:1" >
require('/path/to/wordpress/wp-ssi.php');
</pre>
<p>As for wp-ssi.php, I will can explain more about how that works.<br />
<span id="more-1615"></span></p>
<p></p>
<pre class="wp-code-highlight prettyprint linenums:1" >
define('WP_SSI_DEFAULT_TEMPLATE', 'page');
</pre>
<p>Our first bit of code, simply is a option, nothing more nothing less.  It just lets me define the default template, in this example code I used page, however for my theme I customized the page template to display full width and not have the sidebar.</p>
<pre class="wp-code-highlight prettyprint linenums:1" >
register_shutdown_function('do_wp_ssi_wrap');
</pre>
<p>This is the most important piece of code, without it this wouldn&#8217;t work.  This registers with php a function to run at the end of page execution.  I may of been able to use ob_start with a buffer function, but I avoided it.</p>
<pre class="wp-code-highlight prettyprint linenums:1" >
ob_start();
</pre>
<p>This is simple, we are turning on a output buffer.  I don&#8217;t need any buffer replacements, so I just call the function.</p>
<pre class="wp-code-highlight prettyprint linenums:1" >
require_once('./wp-blog-header.php');
</pre>
<p>This gets wordpress going.  This same piece of code is used to start wordpress in the index.php</p>
<pre class="wp-code-highlight prettyprint linenums:1" >
function do_wp_ssi_wrap()
{
	global $specialPageContent;
</pre>
<p>Consolidating some lines here, we are creating a new function called &#8216;do_wp_ssi_wrap&#8217;.  We also used &#8216;do_wp_ssi_wrap&#8217; in the argument lines with our register_shutdown_function a few lines up.  This is the shutdown function that is going to do some stuff before php exits and sends all contents to the browser.</p>
<pre class="wp-code-highlight prettyprint linenums:1" >
	$specialPageContent = ob_get_clean();
</pre>
<p>We are capturing all output sent to the buffer at this time.  Any output our script has sent is now in a easy to use variable.</p>
<pre class="wp-code-highlight prettyprint linenums:1" >
	$theme = defined('WP_SSI_THEME') ? WP_SSI_THEME : get_template_directory();
	$template = defined('WP_SSI_TEMPLATE') ? WP_SSI_TEMPLATE : WP_SSI_DEFAULT_TEMPLATE;
</pre>
<p>Some more overrides here.  I simply setup a way to override the theme, otherwise it uses wordpress functions to get the path to the current theme in use.  The next one allows me to override the template.  Both of these may come in handy if I have a page I want a different theme on or if I want to use a different template on it.</p>
<pre class="wp-code-highlight prettyprint linenums:1" >
	require($theme . '/' . $template . '.php');
}
</pre>
<p>This is simply just including the template from the theme we selected.  Oh and the closing function curly bracket.  That is all the code needed here.</p>
]]></content:encoded>
			<wfw:commentRss>http://sleepycode.com/2011/11/wordpress-templates-on-non-wordpress-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New theme</title>
		<link>http://sleepycode.com/2011/11/new-theme/</link>
		<comments>http://sleepycode.com/2011/11/new-theme/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 03:43:32 +0000</pubDate>
		<dc:creator>SleePy</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://sleepycode.com/?p=1604</guid>
		<description><![CDATA[It was time for a new theme. So here it is. A bit modified from the original version I downloaded. Including some css edits and the ability to fully work with mobile devices (I only have a andriod to test though). Interesting note on the mobile features though, both Android and iOS have a issue [...]]]></description>
			<content:encoded><![CDATA[<p>It was time for a new theme.  So here it is.  A bit modified from the original version I downloaded.  Including some css edits and the ability to fully work with mobile devices (I only have a andriod to test though).</p>
<p>Interesting note on the mobile features though, both Android and iOS have a issue where they can&#8217;t use the css overflow.  iOS at least lets you scroll the content, but none of them will show a scroll bar of some sort.</p>
]]></content:encoded>
			<wfw:commentRss>http://sleepycode.com/2011/11/new-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

