<?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>CodeDump &#187; PHP</title>
	<atom:link href="http://codedump.tsdme.nl/category/php/feed" rel="self" type="application/rss+xml" />
	<link>http://codedump.tsdme.nl</link>
	<description>A little blog where I write about my experiences while coding.</description>
	<lastBuildDate>Sat, 16 Oct 2010 18:42:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Impressed about WordPress</title>
		<link>http://codedump.tsdme.nl/php/impressed-about-wordpress</link>
		<comments>http://codedump.tsdme.nl/php/impressed-about-wordpress#comments</comments>
		<pubDate>Sat, 16 Oct 2010 18:42:21 +0000</pubDate>
		<dc:creator>Ezra</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://codedump.tsdme.nl/?p=139</guid>
		<description><![CDATA[Lately I&#8217;ve been doing a lot of developing for the WordPress platform at my new work. Before I&#8217;ve done very little with WordPress, but I have to say I&#8217;m impressed with the latest version. There are several nice features I&#8217;ve been introduced to like menu&#8217;s and feature images. But one of the best functions I [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been doing a lot of developing for the WordPress platform at my new work. Before I&#8217;ve done very little with WordPress, but I have to say I&#8217;m impressed with the latest version.</p>
<p>There are several nice features I&#8217;ve been introduced to like menu&#8217;s and feature images.</p>
<p>But one of the best functions I found is wp_enqueue_script and wp_enqueue_style. The best thing about these functions are that they have the ability to solve dependencies. Simply tell the system you need jquery and voila, it will be included.</p>
<p>Sadly I also noticed that some theme&#8217;s and plugins are not using this system yet, causing some scripts to be included twice. So all theme and plugin author&#8217;s <strong>please</strong> use these functions to include styles and scripts!</p>
<p><a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script">http://codex.wordpress.org/Function_Reference/wp_enqueue_script</a><br />
<a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_style">http://codex.wordpress.org/Function_Reference/wp_enqueue_style</a></p>
]]></content:encoded>
			<wfw:commentRss>http://codedump.tsdme.nl/php/impressed-about-wordpress/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My new favorite function: map</title>
		<link>http://codedump.tsdme.nl/php/my-new-favorite-function-map</link>
		<comments>http://codedump.tsdme.nl/php/my-new-favorite-function-map#comments</comments>
		<pubDate>Mon, 28 Dec 2009 03:46:55 +0000</pubDate>
		<dc:creator>Ezra</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[formulae]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[memoization]]></category>

		<guid isPermaLink="false">http://codedump.tsdme.nl/?p=111</guid>
		<description><![CDATA[Map, that&#8217;s my new favorite pure function. It&#8217;s very simple in use and has tons of uses! Ever been fidgeting with numbers trying to get the right output? Save your time the next time and use Map! 1234function map&#40;$v, $a, $b, $x = 0, $y = 1&#41; &#123; &#160; return &#40;$v == $a&#41; ? $x [...]]]></description>
			<content:encoded><![CDATA[<p>Map, that&#8217;s my new favorite pure function. It&#8217;s very simple in use and has tons of uses! Ever been fidgeting with numbers trying to get the right output? Save your time the next time and use Map!</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> map<span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #339933;">,</span> <span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #000088;">$b</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> 0<span style="color: #339933;">,</span> <span style="color: #000088;">$y</span> <span style="color: #339933;">=</span> 1<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$x</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$y</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$b</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$x</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>As you can see it&#8217;s very easy in use. The first parameter is the value that needs to be mapped, the next two values are respectfully the minimum and maximum value of the input and the last two are respectfully the min and max of the output.</p>
<p>So lets take an example: It&#8217;s 20 degrees Celsius outside, but we want to map it to Fahrenheit.</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">map<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'c'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span>40<span style="color: #339933;">,</span> 200<span style="color: #339933;">,</span> <span style="color: #339933;">-</span>40<span style="color: #339933;">,</span> 392<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>And that&#8217;s it!, we know that -40 degrees Celsius is -40 degrees Fahrenheit and that 200 degrees Celsius is 392 degrees Fahrenheit, and this way the value of c gets mapped from Celsius to Fahrenheit, that simple! No more fidgeting with formulae.</p>
<p>Also because it&#8217;s a pure function it&#8217;s easily memoized, this will make the already fast function even faster by caching the inputs and the outputs. But because I don&#8217;t know an easy way of Memoizing functions in PHP except for explicitly making the function memoized, i&#8217;ll leave it with a link to <a title="Memoization" href="http://en.wikipedia.org/wiki/Memoization">Wikipedia</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://codedump.tsdme.nl/php/my-new-favorite-function-map/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenSearch WordPress Plugin</title>
		<link>http://codedump.tsdme.nl/php/opensearch-wordpress-plugin</link>
		<comments>http://codedump.tsdme.nl/php/opensearch-wordpress-plugin#comments</comments>
		<pubDate>Mon, 06 Oct 2008 18:01:47 +0000</pubDate>
		<dc:creator>Ezra</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[opensearch]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://codedump.tsdme.nl/?p=9</guid>
		<description><![CDATA[I&#8217;ve been searching for a plugin for WordPress that makes an OpenSearch file. Found nothing so i&#8217;ve been working on it myself, however lately I&#8217;ve seen another OpenSearch plugin appear in the plugins database. The plugin system of wordpress is ok, but could be a lot better, namely a class system. The way it works [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been searching for a plugin for WordPress that makes an OpenSearch file.</p>
<p>Found nothing so i&#8217;ve been working on it myself, however lately I&#8217;ve seen another OpenSearch plugin appear in the plugins database.</p>
<p>The plugin system of wordpress is ok, but could be a lot better, namely a class system. The way it works now is there are a lot of events that you can register functions to, that will fire when the event happens. You can also create some filters that will for example pass the text that has been written in a new post to alter some text like tags added to the post.</p>
<p>It would have been very nice if the plugin system would have worked with a class system, by simply creating a class to expand on the features.</p>
<p>But enough talk about the plugin system, let me tell you some about the plugin. It&#8217;s my first plugin so I&#8217;m still experimenting with the API. The way it works now is it creates a OpenSearch.xml file when the plugin activates and the file is basically static with some variable values that make the file specific for your blog.</p>
<p>As I said before, now someone else started working on the plugin so mine has become useless as the other one is superior to mine. So without further ado, the code that I had for anyone to download if they please.</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #009933; font-style: italic;">/** <br />
&nbsp; Edits:<br />
&nbsp; &nbsp; Ezra &nbsp; &nbsp; &nbsp;18-08-08 &nbsp; &nbsp;Eerste versie<br />
&nbsp; &nbsp; Ezra &nbsp; &nbsp; &nbsp;19-08-08 &nbsp; &nbsp;Hij werkt, gzip ook!<br />
&nbsp; &nbsp; Ezra &nbsp; &nbsp; &nbsp;28-08-08 &nbsp; &nbsp;Bij Deactivaten wordt het bestand verwijderd. Encoding veranderd naar US-ASCII.<br />
&nbsp; <br />
*/</span><br />
<br />
<span style="color: #666666; font-style: italic;">/*<br />
Plugin Name: OpenSearch<br />
Plugin URI: http://codedump.tsdme.nl<br />
Description: Add a OpenSearch description to your blog<br />
Version: 0.1<br />
Author: Ezra (Ezra@tsdme.nl)<br />
Author URI: http://codedump.tsdme.nl/Admin<br />
*/</span><br />
<br />
<span style="color: #666666; font-style: italic;">//Definitions</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;OS_LOCATION&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;OpenSearch.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;PLUGIN_BORDER&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;!-- OpenSearch Plugin --&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//Hooks</span><br />
register_activation_hook<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'OS_Activate'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
register_deactivation_hook<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'OS_Deactivate'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_head'</span><span style="color: #339933;">,</span> OS_Head<span style="color: #339933;">,</span> 10<span style="color: #339933;">,</span> 0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//Functions</span><br />
<span style="color: #000000; font-weight: bold;">function</span> SO_add_pages<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; add_options_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'OpenSearch'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'OpenSearch'</span><span style="color: #339933;">,</span> 10<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'OS_Menu'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">function</span> OS_Activate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; <a href="http://www.php.net/clearstatcache"><span style="color: #990000;">clearstatcache</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #000088;">$os_file</span> &nbsp;<span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;?xml version=<span style="color: #000099; font-weight: bold;">\&quot;</span>1.0<span style="color: #000099; font-weight: bold;">\&quot;</span> encoding=<span style="color: #000099; font-weight: bold;">\&quot;</span>US-ASCII<span style="color: #000099; font-weight: bold;">\&quot;</span>?&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000088;">$os_file</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;OpenSearchDescription xmlns=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://a9.com/-/spec/opensearch/1.1/<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000088;">$os_file</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;ShortName&gt;&quot;</span><span style="color: #339933;">.</span>get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/ShortName&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000088;">$os_file</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;LongName&gt;Search &quot;</span><span style="color: #339933;">.</span>get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/LongName&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000088;">$os_file</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;Description&gt;Search &quot;</span><span style="color: #339933;">.</span>get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'home'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/Description&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000088;">$os_file</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;Tags&gt;&quot;</span><span style="color: #339933;">.</span>get_the_tag_list<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/Tags&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000088;">$os_file</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;Contact&gt;&quot;</span><span style="color: #339933;">.</span>get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_email'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/Contact&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000088;">$os_file</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;Url type=<span style="color: #000099; font-weight: bold;">\&quot;</span>text/html<span style="color: #000099; font-weight: bold;">\&quot;</span> template=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://gedachtegoed.tsdme.nl/?s={searchTerms}<span style="color: #000099; font-weight: bold;">\&quot;</span>/&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000088;">$os_file</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;Image height=<span style="color: #000099; font-weight: bold;">\&quot;</span>48<span style="color: #000099; font-weight: bold;">\&quot;</span> width=<span style="color: #000099; font-weight: bold;">\&quot;</span>48<span style="color: #000099; font-weight: bold;">\&quot;</span> type=<span style="color: #000099; font-weight: bold;">\&quot;</span>image/png<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">.</span>get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'home'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/favicon.png&lt;/Image&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000088;">$os_file</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;Query role=<span style="color: #000099; font-weight: bold;">\&quot;</span>example<span style="color: #000099; font-weight: bold;">\&quot;</span> searchTerms=<span style="color: #000099; font-weight: bold;">\&quot;</span>cat<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000088;">$os_file</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/OpenSearchDescription&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #000088;">$os_xml</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><a href="http://www.php.net/fopen"><span style="color: #990000;">fopen</span></a><span style="color: #009900;">&#40;</span>GetHomePath<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>OS_LOCATION<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;wb&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$os_xml</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/flock"><span style="color: #990000;">flock</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$os_xml</span><span style="color: #339933;">,</span> LOCK_EX<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/fwrite"><span style="color: #990000;">fwrite</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$os_xml</span><span style="color: #339933;">,</span> <span style="color: #000088;">$os_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/fclose"><span style="color: #990000;">fclose</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$os_xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #000088;">$gz_xml</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><a href="http://www.php.net/gzopen"><span style="color: #990000;">gzopen</span></a><span style="color: #009900;">&#40;</span>GetHomePath<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>OS_LOCATION<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.gz&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;wb9&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$gz_xml</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/flock"><span style="color: #990000;">flock</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$gz_xml</span><span style="color: #339933;">,</span> LOCK_EX<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/gzwrite"><span style="color: #990000;">gzwrite</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$gz_xml</span><span style="color: #339933;">,</span> <span style="color: #000088;">$os_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/gzclose"><span style="color: #990000;">gzclose</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$gz_xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> OS_Deactivate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span>GetHomePath<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>OS_LOCATION<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/unlink"><span style="color: #990000;">unlink</span></a><span style="color: #009900;">&#40;</span>GetHomePath<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>OS_LOCATION<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span>GetHomePath<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>OS_LOCATION<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.gz&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/unlink"><span style="color: #990000;">unlink</span></a><span style="color: #009900;">&#40;</span>GetHomePath<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>OS_LOCATION<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.gz&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> OS_Head<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #b1b100;">echo</span> PLUGIN_BORDER<span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;link rel=<span style="color: #000099; font-weight: bold;">\&quot;</span>search<span style="color: #000099; font-weight: bold;">\&quot;</span> type=<span style="color: #000099; font-weight: bold;">\&quot;</span>application/opensearchdescription+xml<span style="color: #000099; font-weight: bold;">\&quot;</span> title=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">.</span>get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; Search<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">.</span>get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span>OS_LOCATION<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #b1b100;">echo</span> PLUGIN_BORDER<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp;* Returns the path to the blog directory<br />
&nbsp; &nbsp;* <br />
&nbsp; &nbsp;* @since 3.0<br />
&nbsp; &nbsp;* @access public<br />
&nbsp; &nbsp;* @author Arne Brachhold<br />
&nbsp; &nbsp;* @return string The full path to the blog directory<br />
&nbsp; */</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">function</span> GetHomePath<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000088;">$res</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Check if we are in the admin area -&gt; get_home_path() is avaiable</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;get_home_path&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> get_home_path<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//get_home_path() is not available, but we can't include the admin</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//libraries because many plugins check for the &quot;check_admin_referer&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//function to detect if you are on an admin page. So we have to copy</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//the get_home_path function in our own...</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$home</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'home'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$home</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$home</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: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$home_path</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/parse_url"><span style="color: #990000;">parse_url</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$home</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$home_path</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$home_path</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'path'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$root</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;PHP_SELF&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SCRIPT_FILENAME&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$home_path</span> <span style="color: #339933;">=</span> trailingslashit<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$root</span><span style="color: #339933;">.</span><span style="color: #000088;">$home_path</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$home_path</span> <span style="color: #339933;">=</span> ABSPATH<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$home_path</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$res</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<p>Have fun with it and good luck to the person that is developing the other OpenSearch plugin!</p>
]]></content:encoded>
			<wfw:commentRss>http://codedump.tsdme.nl/php/opensearch-wordpress-plugin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

