<?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>Einar Egilsson &#187; Wordpress</title>
	<atom:link href="http://einaregilsson.com/category/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://einaregilsson.com</link>
	<description>A site for my programming pet projects</description>
	<lastBuildDate>Fri, 10 Feb 2012 09:54:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Using WordPress authentication in Zenphoto</title>
		<link>http://einaregilsson.com/using-wordpress-authentication-in-zenphoto/</link>
		<comments>http://einaregilsson.com/using-wordpress-authentication-in-zenphoto/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 08:18:15 +0000</pubDate>
		<dc:creator>einar</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[ZenPhoto]]></category>

		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/08/08/using-wordpress-authentication-in-zenphoto/</guid>
		<description><![CDATA[In a previous post I talked about how to integrate ZenPhoto into WordPress. After I had done that for my own site I still wasn&#8217;t happy. I didn&#8217;t like the fact that I had to use seperate logins for WordPress and ZenPhoto, I wanted this to be as integrated as possible. So I figured out [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous post I talked about <a href="http://einaregilsson.com/2007/08/06/integrating-zenphoto-into-wordpress/">how to integrate ZenPhoto into WordPress</a>. After I had done that for my own site I still wasn&#8217;t happy. I didn&#8217;t like the fact that I had to use seperate logins for WordPress and ZenPhoto, I wanted this to be as integrated as possible. So I figured out a way to make ZenPhoto ask WordPress for authentication credentials. In other words, if you&#8217;re logged into WordPress, you&#8217;re also logged into ZenPhoto. This makes the user/password in the ZenPhoto config file meaningless. Here&#8217;s what you have to do to get this working:<span id="more-39"></span></p>
<p>1. Edit the file auth_zp.php under the zen folder in your ZenPhoto installation, throw away everything in the file, and replace it with this:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
require_once(&quot;functions-db.php&quot;);

$wp_include = &quot;../wp-config.php&quot;;
$i = 0;
while (!file_exists($wp_include) &amp;&amp; $i++ &lt; 10) {
  $wp_include = &quot;../$wp_include&quot;;
}
require_once($wp_include);

function zp_loggedin() {
  //Only considered logged in if it's someone with more rights
  //than a Subscriber
  return is_user_logged_in() &amp;&amp; wp_get_current_user()-&gt;user_level &gt;= 2;
}

if (isset($_GET[&quot;logout&quot;]) || isset($_POST[&quot;logout&quot;])) {
  header(&quot;Location: &quot; . get_option(&quot;siteurl&quot;)
       . &quot;/wp-login.php?action=logout&quot;);
  exit();
}

?&gt;;
</pre>
<p>This technique assumes that your Zenphoto folder is a subfolder of your WordPress folder. Like here, my WordPress install is at http://einaregilsson.com/ and my Zenphoto install is at http://einaregilsson.com/photos/. It can be at most 10 levels deep in the folder hierarchy under WordPress, but it MUST be under the WP folder. </p>
<p>2. Edit the admin-function.php file thats also under the zen folder in your ZenPhoto installation. Find the function printLoginForm and replace it with this:</p>
<pre class="brush: php; title: ; notranslate">
function printLoginForm($redirect=&quot;/zen/admin.php&quot;) {
  if (is_user_logged_in() &amp;&amp; wp_get_current_user()-&gt;user_level == 0) {
    //User is logged in as Subscriber

    $logoutUrl = get_option('siteurl') . &quot;/wp-login.php?action=logout&quot;;
    echo &quot;&lt;p&gt;&lt;img src=\&quot;../zen/images/zen-logo.gif\&quot; title=\&quot;Zen Photo\&quot; /&gt;&lt;/p&gt;&quot;;

    echo &quot;\\n  &lt;div id=\&quot;loginform\&quot;&gt;&quot;;
    echo &quot;&lt;div class=\&quot;errorbox\&quot; id=\&quot;message\&quot;&gt;&quot;
       . &quot;&lt;h2&gt;Error: Insufficient privileges.&lt;/h2&gt;&quot;
       . &quot;You are currently logged into WordPress as a &lt;strong&gt;Subscriber&lt;/strong&gt;. &quot;
       . &quot;Subscribers can't access ZenPhoto Administration. In order to do &quot;
       . &quot;so you must &lt;a href=\&quot;$logoutUrl\&quot;&gt;log out of WordPress&lt;/a&gt; and &quot;
       . &quot;then log in again with an account that has more rights.&quot;
       . &quot;&lt;/div&gt;&quot;;
    echo &quot;\\n&lt;/body&gt;&quot;;
    echo &quot;\\n&lt;/html&gt;&quot;;
  } else {
    $redirect = WEBPATH . $redirect;
    header(&quot;Location: &quot;.get_option('siteurl').&quot;/wp-login.php?redirect_to=$redirect&quot;);
    exit();
  }
}
</pre>
<p>The only tricky thing here was dealing with WordPress users that only have Subscriber rights. Subscribers shouldn&#8217;t be able to administer ZenPhoto of course, but I didn&#8217;t want to log them out automatically or anything. So I added a special case for them, if a Subscriber tries to access ZenPhoto Administration he will get an error message saying he needs to log in with higher privileges and link to log out of WordPress. If you already have the basic <a href="http://einaregilsson.com/2007/08/06/integrating-zenphoto-into-wordpress/">ZenPhoto integration</a> working then you&#8217;ll have the ZenPhoto link in your WordPress admin pages. Subscribers however won&#8217;t see this link, it will only be shown to users with a role of Contributor or higher.</p>
<p>And that&#8217;s it. Now I have my photos using my WordPress theme, I can edit them in my WordPress admin, I have a link to the ZenPhoto admin and I can use WordPress authentication. The integration is complete <img src='http://einaregilsson.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  .</p>
]]></content:encoded>
			<wfw:commentRss>http://einaregilsson.com/using-wordpress-authentication-in-zenphoto/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Integrating ZenPhoto into WordPress</title>
		<link>http://einaregilsson.com/integrating-zenphoto-into-wordpress/</link>
		<comments>http://einaregilsson.com/integrating-zenphoto-into-wordpress/#comments</comments>
		<pubDate>Mon, 06 Aug 2007 00:28:46 +0000</pubDate>
		<dc:creator>einar</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[ZenPhoto]]></category>

		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/08/06/integrating-zenphoto-into-wordpress/</guid>
		<description><![CDATA[ZenPhoto is a great image gallery written in php that I use on another page I have. It has a great admin interface and themes that are simple to use. I wanted to integrate it into a WordPress blog so I looked around on the net and found a great article about it by a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://zenphoto.org">ZenPhoto</a> is a great image gallery written in php that I use on another page I have. It has a great admin interface and themes that are simple to use. I wanted to integrate it into a WordPress blog so I looked around on the net and found a great article about it by a guy named <a href="http://ruzee.com">Steffen Rusitschka</a>. It explains how you can get your ZenPhoto gallery to look like your blog by including some WordPress pages in your ZenPhoto theme. The article is at <a href="http://www.ruzee.com/blog/2006/06/integrating-zenphoto-into-wordpress/">http://www.ruzee.com/blog/2006/06/integrating-zenphoto-into-wordpress/</a>.</p>
<p>His method works great but there were a few things that bugged me about it. <span id="more-42"></span>First, my ZenPhoto javascript didn&#8217;t work with it, so the inline editing of album descriptions didn&#8217;t work. Also I wanted to be able to edit my ZenPhoto theme files in the WordPress theme editor. I tweak my theme all the time and I thought it would be much more convenient to be able to do it all in one place. So I figured out a way to make it work. Steffen gets full credit for coming up with the method, my contribution is simply making the javascript and theme editor work correctly, creating a link to the ZenPhoto admin interface from the WordPress admin interface and packing it all up in a zip file with easy installation instructions. I won&#8217;t explain all the code here, it&#8217;s done quite nicely in Steffens article but for those interested in the implementation it&#8217;s basically this:</p>
<ol>
<li>Make the files in the ZenPhoto theme basically do nothing but include zp-index, zp-image and zp-album from the current WordPress theme folder. This allows us to edit the theme using the WordPress theme editor.</li>
<li>Add hooks in WordPress so the ZenPhoto stylesheet will be included in the &lt;head&gt; element of the page.</li>
<li>Add hooks in WordPress so the zenJavascript function from ZenPhoto is called on the pages, so the inline editing will work (see head.php for this).</li>
<li>Create a small WordPress plugin that creates a link to ZenPhoto from the WordPress admin interface, and gives the zp files pretty names in the WordPress theme editor (&#8216;ZenPhoto Index&#8217; for zp-index.php, &#8216;ZenPhoto Image&#8217; for zp-image.php etc.).</li>
</ol>
<p>For those that just want to get it working, here are the installation instructions:</p>
<ol>
<li>Download the zip file and unzip.</li>
<li>Copy the wordpress-integration-zp-theme folder into your zenphoto/themes folder.</li>
<li>Go to your ZenPhoto admin web, choose Options and activate the theme called &#8216;WordPress Integration Theme&#8217;.</li>
<li>Copy the files (zp-index.php, zp-image.php, zp-album.php, zp-style.css) from the wordpress-theme-files folder into your current WordPress theme folder, /wp-content/themes/yourthemename.</li>
<li>Copy the zen-integration.php file into your WordPress plugin folder, /wp-content/plugins .</li>
<li>Goto your WordPress admin interface, choose Plugins, and activate the &#8216;Zen Integration&#8217; plugin. Note that the plugin assumes that your zenphoto folder is directly below your WordPress folder and is called &#8216;zenphoto&#8217;, &#8216;photos&#8217; or &#8216;gallery&#8217;. If it&#8217;s not, and you want to get the ZenPhoto link from the WordPress admin interface working you&#8217;ll need to edit the zen-integration.php file, find this line:
<pre class="brush: php; title: ; notranslate">$zp_admin_url = ''</pre>
<p>And change it to the full url of your ZenPhoto admin page, e.g.</p>
<pre class="brush: php; title: ; notranslate">$zp_admin_url = 'http://example.com/foo/bar/zenphoto/zen/admin.php'</pre>
<li>There is no step 7, you&#8217;re done!</li>
</ol>
<p>Now you should be able to go to your WordPress theme editor and see the files &#8216;ZenPhoto Index&#8217;, &#8216;ZenPhoto Album&#8217;, &#8216;ZenPhoto Image&#8217; and &#8216;ZenPhoto Stylesheet&#8217; and you can edit them right there. The files included in the zipfile are meant to be used with the default WordPress theme, Kubrick, and will probably not look very good on any other theme. It&#8217;s the simplest thing I could come up with, I mostly just changed the default ZenPhoto theme a bit. You should change it to fit your current WordPress theme. In the files, the ZenPhoto part is always wrapped in a &lt;div id=&#8221;zenphoto&#8221;&gt;, and the ZenPhoto stylesheet prefixes everything with #zenphoto, this is so your ZenPhoto stylesheet won&#8217;t start affecting other parts of your blog.</p>
<p>So, that&#8217;s it I think <img src='http://einaregilsson.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  . You can <a href="/download/zen-integration.zip">download the zip file with all the needed file here</a>, let me know if you have any problems with it. You can view it in action at <a href="/photos">http://einaregilsson.com/photos</a>  (Yes, I know it&#8217;s the same picture over and over, it&#8217;s just for demonstration purposes <img src='http://einaregilsson.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ).</p>
<p><strong>UPDATE 01.09.2007:</strong> Fixed bug where error message didn&#8217;t appear when comment was invalid on an image page.<br />
<strong>UPDATE 02.09.2007:</strong> &#8230;and now I fixed the fix, because it was displaying the error message even if there was no error!</p>
]]></content:encoded>
			<wfw:commentRss>http://einaregilsson.com/integrating-zenphoto-into-wordpress/feed/</wfw:commentRss>
		<slash:comments>71</slash:comments>
		</item>
		<item>
		<title>Yet Another Random Quote, with editing</title>
		<link>http://einaregilsson.com/yarq-with-editing/</link>
		<comments>http://einaregilsson.com/yarq-with-editing/#comments</comments>
		<pubDate>Mon, 30 Jul 2007 12:30:04 +0000</pubDate>
		<dc:creator>einar</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/07/30/yarq-with-editing/</guid>
		<description><![CDATA[On my old site I used to have a random quote feature. When I moved to WordPress I missed it so I found a plugin that displayed random quotes. It was called Yet Another Random Quote (yarq for short) and lives at http://openmonday.org/2006/07/31/yet-another-random-quote/. It&#8217;s a good plugin and works well, but it could only add [...]]]></description>
			<content:encoded><![CDATA[<p>On my old site I used to have a random quote feature. When I moved to WordPress I missed it so I found a plugin that displayed random quotes. It was called Yet Another Random Quote (yarq for short) and lives at <a href="http://openmonday.org/2006/07/31/yet-another-random-quote/">http://openmonday.org/2006/07/31/yet-another-random-quote/</a>. It&#8217;s a good plugin and works well, but it could only add and delete quotes, not edit existing ones. So I changed it a bit, added editing functionality and moved the quote text fields above the quote list, which I thought was better when you had a lot of quotes. After I&#8217;d changed it I emailed the author twice to ask him if he wanted to use my changes in his next version but never heard back from him. So I´m gonna distribute my version here:</p>
<p><a href="/download/yarq.php.txt">Download</a></p>
<p>You can use Options-&gt;YARQ to change the display format, and Manage-&gt;Quotes to add, edit and delete the quotes. If my changes ever make it to the trunk I&#8217;ll stop distributing it here and just link to the main version. If <a href="http://openmonday.org">Frank van der Brink</a> ever reads this, get in contact with me at tech [at] einaregilsson.com and I&#8217;ll send you the patch for my changes.</p>
]]></content:encoded>
			<wfw:commentRss>http://einaregilsson.com/yarq-with-editing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pretty WordPress Permalinks on IIS</title>
		<link>http://einaregilsson.com/pretty-wordpress-permalinks-on-iis/</link>
		<comments>http://einaregilsson.com/pretty-wordpress-permalinks-on-iis/#comments</comments>
		<pubDate>Mon, 30 Jul 2007 11:36:52 +0000</pubDate>
		<dc:creator>einar</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Meta]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/07/30/pretty-wordpress-permalinks-on-iis/</guid>
		<description><![CDATA[UPDATE 16.09.2009: I don&#8217;t update this script anymore, it might not work on newer versions of WordPress. An updated, more robust solution can be found at http://www.ikailo.com/94/url-modrewrite-workaround-iis-60/, go there if the solution below causes problems for your site. I&#8217;ve been searching the web a bit for a way to make pretty permalinks work correctly on [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE 16.09.2009: </strong>I don&#8217;t update this script anymore, it might not work on newer versions of WordPress. An updated, more robust solution can be found at <a href="http://www.ikailo.com/94/url-modrewrite-workaround-iis-60/">http://www.ikailo.com/94/url-modrewrite-workaround-iis-60/</a>, go there if the solution below causes problems for your site.
</p>
<p>I&#8217;ve been searching the web a bit for a way to make pretty permalinks work correctly on this site. The site is hosted on IIS so using mod_rewrite won&#8217;t work, and it&#8217;s on a shared server so the option of installing a mod_rewrite alternative for IIS won&#8217;t work either. I could get away with having almost pretty urls, with a index.php in them, like this: <a href="http://einaregilsson.com/index.php/2007/07/30/pretty-wordpress-permalinks-on-iis/">http://einaregilsson.com/index.php/2007/07/30/pretty-wordpress-permalinks-on-iis/</a> but I didn&#8217;t like it. </p>
<p>The <a href="http://codex.wordpress.org/Using_Permalinks">Using Permalinks</a> section on the WordPress page has a lot of info on this and it links to one <a href="http://www.keyboardface.com/iis-permalinks/">solution that uses custom 404 pages</a> to make this work but unfortunately I don&#8217;t think it&#8217;s a very good solution at all. What it does is parse the url from the 404 string, then re-implement all the rewrite url matching itself, make its own http request to the correct url, then write the data from that request into the response. It&#8217;s a good effort but it&#8217;s duplicating functionality already in WordPress and making a new http request for every page hit which I don&#8217;t like. After searching around some more I found <a href="http://wordpress.org/support/topic/36214">another 404 page solution</a> that is very simple and elegant. All you have to do is create a 404 page and put the following 4 lines in it:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$qs = $_SERVER['QUERY_STRING'];
$pos = strrpos($qs, '://');
$pos = strpos($qs, '/', $pos + 4);
$_SERVER['REQUEST_URI'] = substr($qs, $pos);
$_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'];
include('index.php');
?&gt;
</pre>
<p>All this does is fix the REQUEST_URI and PATH_INFO variables and then include index.php, so WordPress will do the rest. It&#8217;s simple, it doesn&#8217;t duplicate functionality already in WordPress and it doesn&#8217;t have the overhead of another http request for every page hit. The installation steps are:</p>
<ol>
<li>Create the file wp-404-handler.php in your base WordPress folder. (you can also <a href="/download/wp-404-handler.php.txt">download it here</a>).</li>
<li>Set your sites 404 page to point to the wp-404-handler.php url. Most control panels at web hosts allow you to do this. If you&#8217;ve got the option to select between FILE and URL then choose URL.</li>
<li>Go to Options -&gt; Permalinks in your WordPress admin page, and choose an appropriate structure for your links. I chose Custom with this pattern:
<pre><code>/%year%/%monthnum%/%day%/%postname%/ </code></pre>
</li>
<li>Enjoy!</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://einaregilsson.com/pretty-wordpress-permalinks-on-iis/feed/</wfw:commentRss>
		<slash:comments>326</slash:comments>
		</item>
		<item>
		<title>Icelandic letters in WordPress permalinks</title>
		<link>http://einaregilsson.com/icelandic-letters-in-wordpress-permalinks/</link>
		<comments>http://einaregilsson.com/icelandic-letters-in-wordpress-permalinks/#comments</comments>
		<pubDate>Fri, 27 Jul 2007 11:36:48 +0000</pubDate>
		<dc:creator>einar</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/07/27/icelandic-letters-in-wordpress-permalinks/</guid>
		<description><![CDATA[I use WordPress for this site as well as my personal blog. It works very well with icelandic letters for the most part but there was one problem. When you create a new post and give it a title, the post slug is generated from the title. For example, the title of this post is [...]]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://wordpress.org">WordPress</a> for this site as well as my personal blog.  It works very well with icelandic letters for the most part but there was one problem. When you create a new post and give it a title, the post slug is generated from the title. For example, the title of this post is &#8216;Icelandic letters in WordPress permalinks&#8217; and it&#8217;s automatically changed to &#8216;icelandic-letters-in-wordpress-permalinks&#8217; in the url. When you have a post with special characters in the title they are either removed or changed to some ASCII equivalent. For instance, Á becomes A, Í becomes I, ö becomes o and so on. This worked well for all icelandic letters except three, they are þ, æ, ð. When I made a post with the title &#8216;Þátturinn&#8217; the post-slug would become &#8216;þatturinn&#8217; and when I tried to enter that address in my address bar it changed to &#8216;%c3%beatturinn&#8217; and I got a &#8216;page not found&#8217; error from WordPress.</p>
<p>Now, you can manually enter the post-slug when you write a post, but I don&#8217;t wanna have to do that every time I post, so I dug around the WordPress code and found the replacement function. It&#8217;s called remove_accents and is in the file wp-includes/formatting.php. There, right before the line &#8216;// Decompositions for Latin Extended-A&#8217; I added the following code:</p>
<pre class="brush: php; title: ; notranslate">
    chr(195).chr(144) =&gt; 'D', chr(195).chr(176) =&gt; 'd',
    chr(195).chr(158) =&gt; 'TH',chr(195).chr(190) =&gt; 'th',
    chr(195).chr(134) =&gt; 'AE',chr(195).chr(166) =&gt; 'ae',
</pre>
<p>Now the characters are replaced automatically like this: Ð =&gt; D, ð =&gt; d, Þ =&gt; TH, þ =&gt; th, Æ =&gt; AE, æ =&gt; ae. I don&#8217;t know if everyone has this problem, or if it just has to do with the character set settings on my webhost but this works great for me. No more manually fixing page slugs! I&#8217;m gonna create a bug report with WordPress and hopefully this will be accepted into the next version.</p>
<p>Few words in icelandic to help people find this post <img src='http://einaregilsson.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  : Íslenskir stafir í wordpress linkum post slug permalink permalinks</p>
<p><strong>Update 02.08.2007:</strong> Just found out that there&#8217;s already a plugin that does the same thing, and it doesn&#8217;t require you to mess with your WordPress files. You can get it at <a href="http://wordpress.is/saekja/ibaetur/iceslugs.tar">http://wordpress.is/saekja/ibaetur/iceslugs.tar</a> .</p>
<p><strong>Update 13.08.2007:</strong> I made a patch for this and submitted it to WordPress. The changes should come in WP 2.3. The patch is on <a href="http://trac.wordpress.org/ticket/4739">ticket #4739</a> .</p>
]]></content:encoded>
			<wfw:commentRss>http://einaregilsson.com/icelandic-letters-in-wordpress-permalinks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

