<?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>Mike Nott &#187; Wordpress</title>
	<atom:link href="http://www.nott.org/blog/category/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://www.nott.org</link>
	<description>SEO, Music, Photography &#38; Other Stuff</description>
	<lastBuildDate>Thu, 26 Jan 2012 09:18:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>ColorCode &#8211; WordPress Plugin to Highlight Code</title>
		<link>http://www.nott.org/blog/colorcode-wordpress-plugin-to-highlight-code.html</link>
		<comments>http://www.nott.org/blog/colorcode-wordpress-plugin-to-highlight-code.html#comments</comments>
		<pubDate>Mon, 02 Jan 2006 23:36:53 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.nott.org/?p=47</guid>
		<description><![CDATA[Spent a bit of time yesterday trying to get my code examples highlighted using the GeSHi class. However using the WordPress plugin code, I found that though the code was coming up fine it was removing all paragraphs and line breaks from any surrounding text. So I then wrote my own plugin still calling the [...]]]></description>
			<content:encoded><![CDATA[<p>Spent a bit of time yesterday trying to get my code examples highlighted using the <a href="http://qbnz.com/highlighter/">GeSHi</a> class. However using the <a href="http://dev.wp-plugins.org/wiki/GeshiSyntaxColorer">WordPress plugin</a> code, I found that though the code was coming up fine it was removing all paragraphs and line breaks from any surrounding text. So I then wrote my own plugin still calling the GeSHi class file, but where it displays both code and text properly.</p>
<p>It is still not perfect though, as it would be better to use pre for the code instead of all the spaces etc. Also need to switch to css instead of styles before <a href="http://www.w3.org/TR/xhtml2/">XHTML 2.0</a> arrives,  so will post an update once done.</p>
<p>Here is the plugin code:</p>
<p>[code lang="php"]</p>
<p>	/*<br />
	Plugin Name: ColorCode<br />
	Plugin URI: http://www.nott.org/colorcode.html<br />
	Description: A filter that highlights code using the GeSHi class for over 20 languages.<br />
	Version: 1.0<br />
	Author: Mike Nott<br />
	Author URI: http://www.nott.org<br />
	*/</p>
<p>	include(ABSPATH.'/wp-content/plugins/geshi.php');</p>
<p>	function cc_callback($code)<br />
	{<br />
		$geshi = new GeSHi($code[2], $code[1], ABSPATH.'/wp-content/plugins/geshi/');</p>
<p>		$geshi->set_header_type(GESHI_HEADER_DIV);</p>
<p>		$geshi->set_url_for_keyword_group(3, '');</p>
<p>		$newcode = $geshi->parse_code();</p>
<p>		return $newcode;<br />
	}</p>
<p>	function colorcode($content)<br />
	{<br />
		return preg_replace_callback("|<code lang=['\"]([a-zA-Z0-9_-]+)['\"]>(.*)< /code>|imsU", "cc_callback", $content);<br />
	}</p>
<p>	remove_filter('the_content', 'wptexturize');</p>
<p>	add_filter('the_content', 'colorcode', '1');<br />
	add_filter('the_excerpt', 'colorcode', '1');<br />
	add_filter('comment_text', 'colorcode', '1');</p>
<p>[/code]</p>
<p>[note: be sure to remove the space before the /code in the preg replace above before using]</p>
<p>Then just save this file as colorcode.php in your plugin folder, along with the <a href="http://dev.wp-plugins.org/wiki/GeshiSyntaxColorer">GeSHi files</a>.</p>
<p>Usage: </p>
<p>< code lang = " php "><br />
code goes here<br />
< / code ></p>
<p>(but again remove spaces) <img src='http://www.nott.org/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.nott.org/blog/colorcode-wordpress-plugin-to-highlight-code.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web Week in London</title>
		<link>http://www.nott.org/blog/blog-week-in-london.html</link>
		<comments>http://www.nott.org/blog/blog-week-in-london.html#comments</comments>
		<pubDate>Sat, 10 Dec 2005 10:25:04 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Web/Net]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.nott.org/?p=33</guid>
		<description><![CDATA[Yesterday there was Matt Mullenweg&#8217;s WordPress meet up in Covent Garden that unfortunately I couldn&#8217;t get to. Then tonight is Geek Dinner with Robert Scoble. Even Danny Sullivan is attending. Address: Texas Embassy Cantina 1 Cockspur Street, London SW1Y 3DQ [Google Map or Multimap] Tel: 020 7925 0077 Fax: 020 7925 0444 Email: enquiries@texasembassy.com Tube [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday there was <a href="http://photomatt.net/about/">Matt Mullenweg&#8217;s</a> <a href="http://wordpress.org">WordPress</a> <a href="http://www.tamba2.org.uk/T2/archives/2005/12/04/wp-london-next-friday/">meet up</a> in Covent Garden that unfortunately I couldn&#8217;t get to.</p>
<p>Then tonight is <a href="thehughpage.com/London_Geek_Dinner_With_Robert_Scoble">Geek Dinner</a> with <a href="http://en.wikipedia.org/wiki/Robert_Scoble">Robert Scoble</a>. Even <a href="http://searchenginewatch.com/about/article.php/2155651">Danny Sullivan</a> is <a href="http://blog.searchenginewatch.com/blog/051209-175733">attending</a>. </p>
<p>Address:</p>
<p><strong>Texas Embassy Cantina</strong><br />
1 Cockspur Street, London SW1Y 3DQ [<a href="http://maps.google.co.uk/maps?q=1+Cockspur+Street,+London+SW1Y+5DL&#038;ll=51.507800,-0.129900&#038;spn=0.011673,0.019261&#038;hl=en">Google Map</a> or <a href="http://www.multimap.com/map/browse.cgi?pc=SW1Y5DL&#038;title=Texas+Embassy&#038;cat=eat">Multimap</a>]<br />
Tel: 020 7925 0077<br />
Fax: 020 7925 0444<br />
Email: enquiries@texasembassy.com<br />
Tube stops: Charing Cross, Piccadilly, Leicester Square. </p>
<p>But unfortunately I can&#8217;t make this either, due to prior commitments <img src='http://www.nott.org/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.nott.org/blog/blog-week-in-london.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Stats</title>
		<link>http://www.nott.org/blog/wordpress-stats.html</link>
		<comments>http://www.nott.org/blog/wordpress-stats.html#comments</comments>
		<pubDate>Fri, 02 Dec 2005 12:37:18 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.nott.org/?p=25</guid>
		<description><![CDATA[I spent ages hunting for a decent stats system for WordPress, but nothing seems to fit my needs. I want to see number of views on the site as well as number of feed grabs. The closest thing I could find was Counterize which deals with page views nicely, but doesn&#8217;t track RSS views. As [...]]]></description>
			<content:encoded><![CDATA[<p>I spent ages <a href="http://www.google.com/search?q=wordpress+stats">hunting</a> for a decent stats system for <a href="http://wordpress.org">WordPress</a>, but nothing seems to fit my needs. I want to see number of views on the site as well as number of feed grabs.</p>
<p>The closest thing I could find was <a href="http://linux.linux.dk/projects/counterize/">Counterize</a> which deals with page views nicely, but doesn&#8217;t track RSS views.</p>
<p>As the feeds are served through PHP it shouldn&#8217;t be too much trouble to hopefully &#8216;adjust&#8217; counterize to also track this.</p>
<p>However if someone knows of a blog stats system that already does all this, please let me know (I don&#8217;t want to use <a href="http://www.feedburner.com/fb/a/home">Feedburner</a> etc though).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nott.org/blog/wordpress-stats.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WordPress Install</title>
		<link>http://www.nott.org/blog/wordpress-install.html</link>
		<comments>http://www.nott.org/blog/wordpress-install.html#comments</comments>
		<pubDate>Thu, 24 Nov 2005 17:28:32 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.nott.org/?p=15</guid>
		<description><![CDATA[I decided to use WordPress for this blog as it seems to be the current &#8216;standard&#8217;. It was nice to se that it works nicely out of the box after the short install. However, being as awkward as I am, I decided that that I wanted to tweak it a bit: Firstly I didn&#8217;t want [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to use <a href="http://wordpress.org">WordPress</a> for this blog as it seems to be the current &#8216;standard&#8217;. It was nice to se that it works nicely out of the box after the short install. However, being as awkward as I am, I decided that that I wanted to tweak it a bit:</p>
<p>Firstly I didn&#8217;t want to have a dynamic url system, so opted to use WP&#8217;s &#8216;permalinks&#8217; setup. But again I didn&#8217;t want to use their standard folder architecture that 1,000s of others also use e.g. blog.com/archive/2005/11/post-title.html. So I decided to use the following structure:</p>
<ul>
<li>www.nott.org
<ul>
<li>/home-page.html</li>
<li>/content-page-title.html</li>
<li>/blog/</li>
<li>/blog/post-title.html</li>
<li>/blog/category/</li>
<li>/blog/2005/11/     (archive dates)</li>
<li>/blog/feed/feed-format.xml</li>
<li>/blog/feed/category/feed-format.xml  (category feed)</li>
<li>/blog/feed/post-title.xml  (comments feed)</li>
</ul>
</li>
</ul>
<p>To do this took a few mod_rewrite lines in Apache:</p>
<p>[code lang="apache"]<br />
Options +FollowSymLinks<br />
RewriteEngine On<br />
RewriteRule ^/blog/$ / [R=301]<br />
RewriteCond %{REQUEST_URI} !^/index\.html$<br />
RewriteCond %{REQUEST_URI} !^/index\.php$<br />
RewriteRule ^/([A-Za-z0-9-_]+).html$ /index.php?pagename=$1 [QSA]<br />
RewriteRule ^/blog/([A-Za-z0-9-_]+).html$ /index.php?name=$1 [QSA]<br />
RewriteRule ^/blog/([0-9]+)/([0-9]+)/$ /index.php?m=$1$2 [QSA]<br />
RewriteRule ^/blog/feed/(rdf|rss|rss2|atom).xml$ /wp-feed.php?feed=$1 [QSA]<br />
RewriteRule ^/blog/feed/comments/([A-Za-z0-9-_]+).xml$ /wp-feed.php?feed=rss2&#038;name=$1 [QSA]<br />
RewriteRule ^/blog/([A-Za-z0-9-_]+)/$ /index.php?category_name=$1 [QSA]<br />
RewriteRule ^/blog/feed/([A-Za-z0-9-_]+)/(rdf|rss|rss2|atom).xml$ /wp-feed.php?category_name=$1&#038;feed=$2 [QSA]<br />
[/code]</p>
<p>Then some small changes to some of the wordpress php functions (i know this will make upgrades tricky, but if I know what changes I&#8217;ve made, it should be possible):</p>
<p><strong>/wp-includes/feed-functions.php</strong></p>
<p>[code lang="php"]<br />
function comments_rss($commentsrssfilename = '') {<br />
	global $id;</p>
<p>	if ('' != get_settings('permalink_structure'))<br />
		$url = str_replace(".html",".xml",str_replace("/blog/", "/blog/feed/comments/", get_permalink()));<br />
	else<br />
		$url = get_settings('home') . "/$commentsrssfilename?feed=rss2&amp;p=$id";</p>
<p>	return apply_filters('post_comments_feed_link', $url);<br />
}<br />
[/code]</p>
<p><strong>/wp-includes/template-functions-links.php</strong></p>
<p>[code lang="php"]<br />
function get_feed_link($feed='rss2') {<br />
	global $wp_rewrite;<br />
	$do_perma = 0;<br />
	$feed_url = get_settings('siteurl');<br />
	$comment_feed_url = $feed_url;</p>
<p>	$permalink = $wp_rewrite->get_feed_permastruct();<br />
	if ('' != $permalink) {<br />
		if ( false !== strpos($feed, 'comments_') ) {<br />
			$feed = str_replace('comments_', '', $feed);<br />
			$permalink = $wp_rewrite->get_comment_feed_permastruct();<br />
		}</p>
<p>		$permalink = str_replace('%feed%', $feed, $permalink);<br />
		$permalink = preg_replace('#/+#', '/', "/$permalink/");<br />
		$output = get_settings('home') . "/blog/feed/" . $feed . ".xml";<br />
	} else {<br />
		if ( false !== strpos($feed, 'comments_') )<br />
			$feed = str_replace('comments_', 'comments-', $feed);</p>
<p>		$output = get_settings('home') . "/?feed={$feed}";<br />
	}</p>
<p>	return apply_filters('feed_link', $output, $feed);<br />
}<br />
[/code]</p>
<p><strong>template-functions-post.php</strong></p>
<p>[code lang="php"]<br />
function wp_list_pages($args = '') {<br />
	parse_str($args, $r);<br />
	if ( !isset($r['depth']) ) $r['depth'] = 0;<br />
	if ( !isset($r['show_date']) ) $r['show_date'] = '';<br />
	if ( !isset($r['child_of']) ) $r['child_of'] = 0;<br />
	if ( !isset($r['title_li']) ) $r['title_li'] = __('Pages');<br />
	if ( !isset($r['echo']) ) $r['echo'] = 1;</p>
<p>	$output = '';</p>
<p>	// Query pages.<br />
	$pages = &#038; get_pages($args);<br />
	if ( $pages ) :</p>
<p>	if ( $r['title_li'] )<br />
		$output .= '
<li class="pagenav">' . $r['title_li'] . '
<ul>';<br />
	// Now loop over all pages that were selected<br />
	$page_tree = Array();<br />
	foreach($pages as $page) {<br />
		// set the title for the current page<br />
		$page_tree[$page->ID]['title'] = $page->post_title;<br />
		$page_tree[$page->ID]['name'] = $page->post_name;</p>
<p>		// set the selected date for the current page<br />
		// depending on the query arguments this is either<br />
		// the createtion date or the modification date<br />
		// as a unix timestamp. It will also always be in the<br />
		// ts field.<br />
		if (! empty($r['show_date'])) {<br />
			if ('modified' == $r['show_date'])<br />
				$page_tree[$page->ID]['ts'] = $page->post_modified;<br />
			else<br />
				$page_tree[$page->ID]['ts'] = $page->post_date;<br />
		}</p>
<p>		// The tricky bit!!<br />
		// Using the parent ID of the current page as the<br />
		// array index we set the curent page as a child of that page.<br />
		// We can now start looping over the $page_tree array<br />
		// with any ID which will output the page links from that ID downwards.<br />
		if ( $page->post_parent != $page->ID)<br />
			$page_tree[$page->post_parent]['children'][] = $page->ID;<br />
	}<br />
	// Output of the pages starting with child_of as the root ID.<br />
	// child_of defaults to 0 if not supplied in the query.<br />
	$output .= _page_level_out($r['child_of'],$page_tree, $r, 0, false);<br />
	if ( $r['title_li'] )<br />
		$output .= '</ul>
</li>
<p>';<br />
	endif;</p>
<p>	$output = apply_filters('wp_list_pages', $output);</p>
<p>	if ( $r['echo'] )<br />
		echo str_replace('/"','.html"',$output);<br />
	else<br />
		return $output;<br />
}<br />
[/code]</p>
<p>and</p>
<p>[code lang="php"]<br />
function _page_level_out($parent, $page_tree, $args, $depth = 0, $echo = true) {<br />
//	global $wp_query;</p>
<p>//	$queried_obj = $wp_query->get_queried_object();</p>
<p>	$output = '';</p>
<p>	if($depth)<br />
		$indent = str_repeat("\t", $depth);<br />
	//$indent = join('', array_fill(0,$depth,"\t"));</p>
<p>	foreach($page_tree[$parent]['children'] as $page_id) {<br />
		$cur_page = $page_tree[$page_id];<br />
		$title = $cur_page['title'];</p>
<p>		$css_class = 'page_item';<br />
		if( $page_id == $queried_obj->ID) {<br />
			$css_class .= ' current_page_item';<br />
		}</p>
<p>		$output .= $indent . '
<li class="' . $css_class . '"><a href="' . get_page_link($page_id) . '" title="' . wp_specialchars($title) . '">' . $title . '</a>';</p>
<p>		if(isset($cur_page['ts'])) {<br />
			$format = get_settings('date_format');<br />
			if(isset($args['date_format']))<br />
				$format = $args['date_format'];<br />
			$output .= " " . mysql2date($format, $cur_page['ts']);<br />
		}<br />
		echo "\n";</p>
<p>		if(isset($cur_page['children']) &#038;&#038; is_array($cur_page['children'])) {<br />
			$new_depth = $depth + 1;</p>
<p>			if(!$args['depth'] || $depth < ($args['depth']-1)) {<br />
				$output .= "$indent
<ul>\n";<br />
				$output .= _page_level_out($page_id, $page_tree, $args, $new_depth, false);<br />
				$output .= "$indent\n";<br />
			}<br />
		}<br />
		$output .= "$indent</li>
<p>\n";<br />
	}<br />
	if ( $echo )<br />
		echo $output;<br />
	else<br />
		return $output;<br />
}<br />
[/code]</p>
<p><strong>template-functions-general.php</strong> (to put blog description in homepage title)</p>
<p>[code lang="php"]<br />
function wp_title($sep = '&raquo;', $display = true) {<br />
    global $wpdb;<br />
    global $m, $year, $monthnum, $day, $category_name, $month, $posts;</p>
<p>		$cat = get_query_var('cat');<br />
		$p = get_query_var('p');<br />
		$name = get_query_var('name');<br />
		$category_name = get_query_var('category_name');</p>
<p>    // If there's a category<br />
    if(!empty($cat)) {<br />
        if (!stristr($cat,'-')) { // category excluded<br />
            $title = get_the_category_by_ID($cat);<br />
        }<br />
    }<br />
    if (!empty($category_name)) {<br />
        if (stristr($category_name,'/')) {<br />
            $category_name = explode('/',$category_name);<br />
            if ($category_name[count($category_name)-1]) {<br />
                $category_name = $category_name[count($category_name)-1]; // no trailing slash<br />
            } else {<br />
                $category_name = $category_name[count($category_name)-2]; // there was a trailling slash<br />
            }<br />
        }<br />
        $title = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE category_nicename = '$category_name'");<br />
    }</p>
<p>    // If there's a month<br />
    if(!empty($m)) {<br />
        $my_year = substr($m, 0, 4);<br />
        $my_month = $month[substr($m, 4, 2)];<br />
        $title = "$my_year $sep $my_month";</p>
<p>    }<br />
    if (!empty($year)) {<br />
        $title = $year;<br />
        if (!empty($monthnum)) {<br />
            $title .= " $sep ".$month[zeroise($monthnum, 2)];<br />
        }<br />
        if (!empty($day)) {<br />
            $title .= " $sep ".zeroise($day, 2);<br />
        }<br />
    }</p>
<p>    // If there's a post<br />
    if (is_single() || is_page()) {<br />
        $title = strip_tags($posts[0]->post_title);<br />
        $title = apply_filters('single_post_title', $title);<br />
    }</p>
<p>    // Send it out<br />
    if ($display &#038;&#038; isset($title)) {<br />
        echo " $sep $title";<br />
    } elseif (!$display &#038;&#038; isset($title)) {<br />
        return " $sep $title";<br />
    } elseif ($display){<br />
    	echo " $sep ";<br />
    	bloginfo('description');<br />
    }<br />
}<br />
[/code]</p>
<p>I still haven&#8217;t gotten round to putting correct titles in the feeds, will post the fuctoin changes when done.</p>
<p>The excellent template I used as a base is <a href="http://www.perun.net/">Red Train 1.0</a> by <a href="http://www.vlad-design.de/">Vladimir Simovic</a> (so a big thanks to Vlad). </p>
<p>I then changed it a bit, here are my blog templates:</p>
<p><a href="http://www.nott.org/wp-content/themes/nott/style.css">style.css</a><br />
<a href="http://www.nott.org/wp-content/themes/nott/index.php.txt">index.php</a><br />
<a href="http://www.nott.org/wp-content/themes/nott/page.php.txt">page.php</a><br />
<a href="http://www.nott.org/wp-content/themes/nott/comments.php.txt">comments.php</a></p>
<p>I also used <a href="http://www.asymptomatic.net">Owen Winkler</a>&#8216;s <a href="http://redalt.com/downloads/wp/codefilter.zip">Code Filter</a> plugin to properly display code, but had to slightly change it to:</p>
<p>[code lang="php"]<br />
function cf_callback($stuff)<br />
{<br />
	return "<br />
<blockquote{$stuff[1]}>".htmlspecialchars(clean_pre($stuff[2]), ENT_NOQUOTES)."</blockquote >";<br />
}</p>
<p>function cf_encode($content)<br />
{<br />
	return preg_replace_callback('|<br />
<blockquote([^>]*)>(.*)</blockquote >|imsU', 'cf_callback', $content);<br />
}</p>
<p>add_filter('the_content', 'cf_encode', '1');<br />
[/code]</p>
<p>Hope this saves someone the couple of days it has taken me to get <a href="http://www.wordpress.org">WordPress</a> set up properly to my liking <img src='http://www.nott.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.nott.org/blog/wordpress-install.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

