<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Themocracy WordPress Themes</title>
	
	<link>http://themocracy.com</link>
	<description>WordPress Theme Design</description>
	<lastBuildDate>Sat, 08 Dec 2012 15:59:25 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/themocracy" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="themocracy" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">themocracy</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>U-Design Theme</title>
		<link>http://themocracy.com/2012/12/u-design-theme/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=u-design-theme</link>
		<comments>http://themocracy.com/2012/12/u-design-theme/#comments</comments>
		<pubDate>Wed, 05 Dec 2012 14:02:05 +0000</pubDate>
		<dc:creator>Barrie</dc:creator>
				<category><![CDATA[Themes]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=307</guid>
		<description><![CDATA[Tags: seo, sortable portfolio U-design is a very powerful theme which suits both users with no programming background as well as advanced developers. It empowers you to change the color of almost any element, such as backgrounds, links, text, menu links, etc. in seconds. You can also choose from over 500 fonts, including Google Font [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="external nofollow" href="http://themocracy.com/go/u-design/" title="u-design"><img src="http://themocracy.com/wp-content/uploads/2012/12/env0001.jpg" alt="" title="env0001" width="590" height="300" class="aligncenter size-full wp-image-308" /></a></p>
<p><strong>Tags: seo, sortable portfolio</strong></p>
<p><strong>U-design is a very powerful theme which suits both users with no programming background as well as advanced developers.</strong></p>
<p>It empowers you to change the color of almost any element, such as backgrounds, links, text, menu links, etc. in seconds.<br />
You can also choose from over 500 fonts, including Google Font Directory and Cufón fonts. This number will grow with time since many new fonts are being added to the Google fonts library. The theme also features 6 Home page sliders for you to choose from.</p>
<p><a rel="external nofollow" href="http://themocracy.com/go/u-design/" title="u-design">View U-Design theme &raquo;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2012/12/u-design-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Flickr Badge using WordPress Shortcodes</title>
		<link>http://themocracy.com/2010/03/a-flickr-badge-using-wordpress-shortcodes/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=a-flickr-badge-using-wordpress-shortcodes</link>
		<comments>http://themocracy.com/2010/03/a-flickr-badge-using-wordpress-shortcodes/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 11:22:30 +0000</pubDate>
		<dc:creator>Barrie</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=271</guid>
		<description><![CDATA[Flickr provides a neat little snippet of javaScript to supply various image galleries direct to your site - a so-named Flickr badge. Here's a good way using WordPress shortcodes to grab a gallery...]]></description>
			<content:encoded><![CDATA[<p><img src="http://themocracy.com/wp-content/uploads/2010/03/flickr-wordpress.jpg" alt="Flickr" title="flickr-wordpress" width="160" height="148" class="alignright size-full wp-image-272" /><strong>Flickr provides a neat little snippet of javaScript to supply various image galleries direct to your site &#8211; a so-named Flickr badge.</strong></p>
<p>So if your gallery is on Flickr &#8211; rather in your WordPress, which has its own gallery shortcode &#8211; a shortcode in the blog post content can be used to embed a gallery of thumbnail images, which is also a good way to demonstrate the various usages of WordPress shortcodes.</p>
<p>The HTML for a flickr badge looks something like this:-</p>
<pre class="brush: html">

&lt;div class=&quot;flickr_badge&quot;&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.flickr.com/badge_code_v2.gne?count=5&amp;display=latest&amp;size=m&amp;layout=h&amp;source=all_tag&amp;tag=fish&quot;&gt;&lt;/script&gt;&lt;/div&gt;

</pre>
<p>And the parameters work like this:-</p>
<p><strong>count</strong> <em> integer</em> 1-10. Default is 10.</p>
<p><strong>display</strong> <em>string</em> &#8216;latest&#8217; or &#8216;random&#8217;  Default is latest. </p>
<p><strong>layout</strong> <em>string</em> h, v, x - Photos are listed horizontally, vertically, or no style. Default is horizontal.  </p>
<p><strong>source</strong> <em>string</em> user, user_tag, user_set, group, group_tag, all, all_tag </p>
<p>Source implies which &#8216;account&#8217; the photos come from:- a specified user, a user set, a group, or all users, then filtered by tag if required.  Further parameters may then be required, user(ID string)  tag (string), group (integer), and set (integer,  the url …/sets/1234567/).  </p>
<p><strong>size</strong> <em>string</em> s, t, m   s stands for square (cropped, not small&#8230;), t for thumbnail, and m for medium.  t = thumbnail is the default.</p>
<p>(<a href="http://idgettr.com/">idgettr</a> is very useful for figuring out user IDs and the IDs for photosets, groups etc.)</p>
<p><strong>WordPress Shortcodes</strong></p>
<p>A shortcode has a &#8220;handler function&#8221; &#8211; which is integrated into the code by calling the function <strong>add_shortcode()</strong>. The purpose here is to supply the various parameters for our Flickr badge as parameters of the function &#8211; the query string for the Flickr call is then constructed and the javascript code output to the page.</p>
<p>In <strong>functions.php</strong></p>
<pre class="brush: php">

function flickr_badge_shortcode($atts){

//Here&#039;s our defaults 
$query_atts = shortcode_atts(array(&#039;count&#039; =&gt; &#039;6&#039;, &#039;display&#039; =&gt; &#039;latest&#039;, &#039;source&#039; =&gt; &#039;user&#039;, &#039;size&#039; =&gt; &#039;t&#039;, &#039;user&#039; =&gt; &#039;&#039;, &#039;layout&#039; =&gt; &#039;x&#039;, &#039;tag&#039; =&gt; &#039;&#039;, &#039;group&#039; =&gt; &#039;&#039;, &#039;set&#039; =&gt; &#039;&#039;), $atts); 

 	return sprintf(&#039;&lt;div class=&quot;flickr_badge&quot;&gt;&lt;script src=&quot;http://www.flickr.com/badge_code_v2.gne?%s&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;/div&gt;
&#039;, http_build_query($query_atts));
}

add_shortcode(&#039;flickrbadge&#039;, &#039;flickr_badge_shortcode&#039;);

</pre>
<p>Provided you have PHP5 on the server, <strong>http_build_query()</strong> is the quick and easy way of building a query string from an array &#8211; and it&#8217;s urlencoded&#8230;.</p>
<p>Note that the empty parameters group, set etc. are required in the defaults &#8211; otherwise nothing gets passed to the constructed url via shortcode_atts().</p>
<p>So now, in a post content you can apply the shortcode tag:</p>
<p><strong>[flickrbadge count="4" layout="h" display="latest" size="t" source="all_tag" tag="fish"]</strong></p>
<p>And you should get a nice gallery of Flickr images for users to check out &#8211; once you&#8217;ve added some CSS to style the images (note the possible uses of the layout parameter here).</p>
<p>This example was of the selfclosing shortcode tag &#8211; but you can elaborate a bit, to inject more content into the shortcode function. The simplest example would be to give the gallery a custom title.</p>
<p>Again in functions.php</p>
<pre class="brush: php">

function flickr_badge_shortcode($atts, $content=NULL){

//Here&#039;s our defaults
$query_atts = shortcode_atts(array(&#039;count&#039; =&gt; &#039;6&#039;, &#039;display&#039; =&gt; &#039;latest&#039;, &#039;source&#039; =&gt; &#039;user&#039;, &#039;size&#039; =&gt; &#039;t&#039;, &#039;user&#039; =&gt; &#039;&#039;, &#039;layout&#039; =&gt; &#039;x&#039;, &#039;tag&#039; =&gt; &#039;&#039;, &#039;group&#039; =&gt; &#039;&#039;, &#039;set&#039; =&gt; &#039;&#039;), $atts);

return sprintf(&#039;&lt;div class=&quot;flickr_badge&quot;&gt;&lt;h3&gt;%s&lt;/h3&gt;&lt;script src=&quot;http://www.flickr.com/badge_code_v2.gne?%s&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;/div&gt;&#039;, $content, http_build_query($query_atts));
}

add_shortcode(&#039;flickrbadge&#039;, &#039;flickr_badge_shortcode&#039;);

</pre>
<p>And would be called from the post content with opening and closing shortcode tags:</p>
<p><strong>[flickrbadge count="4" layout="h" display="latest" size="t" source="all_tag" tag="fish"]Here&#8217;s the latest fish[/flickrbadge]</strong></p>
<p><strong>Caution!</strong><br />
Best to avoid camelCase notation in the attributes &#8211; the regex that the content is passed through to locate shortcodes  is case-insensitive.<br />
Always remember to use <strong>return</strong> in the handler function and not <strong>echo</strong>  (in this example sprintf, not printf). It&#8217;ll appear on the page &#8211; but not in the right place&#8230;</p>
<p>WordPress shortcodes are relatively simple in concept, but can be a bit fiddly in practice, keeping track of the default parameters and the use of  shortcode_atts() just needs a bit of thinking about sometimes&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/03/a-flickr-badge-using-wordpress-shortcodes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Calendar Functions</title>
		<link>http://themocracy.com/2010/02/php-calendar-functions/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=php-calendar-functions</link>
		<comments>http://themocracy.com/2010/02/php-calendar-functions/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 14:24:22 +0000</pubDate>
		<dc:creator>Barrie</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=264</guid>
		<description><![CDATA[It's really easy to get really mixed up when trying to program with date functions - lots to keep track of, calendars, timezones, daylight saving, weird months that have different numbers of days in them...]]></description>
			<content:encoded><![CDATA[<p><img src="http://themocracy.com/wp-content/uploads/2010/02/wordpress-calendar.gif" alt="" title="wordpress-calendar" width="128" height="128" class="alignright size-full wp-image-265" />It&#8217;s really easy to get really mixed up when trying to program with date functions &#8211; lots to keep track of, calendars, timezones, daylight saving, weird months that have different numbers of days in them&#8230;</p>
<p><strong>Here&#8217;s a quick rundown on the main PHP functions involved.</strong> </p>
<h3>1. checkdate()</h3>
<blockquote><p>
bool <strong>checkdate </strong> ( int $month  , int $day  , int $year  )
</p></blockquote>
<p>Does just what it says, for the Gregorian calendar, and it&#8217;s been around since PHP4 &#8211; a very quick way to ensure that the programming isn&#8217;t coming up with any silly results. Always useful!</p>
<h3>2.. date() and gmdate()</h3>
<p>From a given UNIX timestamp, <strong>date()</strong> tells you what time would be in your server timezone and <strong>gmdate()</strong> tells you what GMT it would be (or UTC, the same thing&#8230;). It is important to get the hang of the consequences of this and one way of figuring it out is to bear in mind the date() format character &#8220;Z&#8221; &#8211; the timezone offset in seconds, positive or negative. </p>
<p>No matter what the timezone is set to, these 2 expressions will produce the same result&#8230;</p>
<pre class="brush: php">
&lt;?php
	date_default_timezone_set(&#039;America/Montreal&#039;);

	echo date(&quot;Y/m/d H:i:s&quot;,(time()));
	echo gmdate(&quot;Y/m/d H:i:s&quot;,(time()+ date(&quot;Z&quot;)));

?&gt;
</pre>
<h3>3. strtotime()</h3>
<p>Takes a string and should return a Unix timestamp.</p>
<p>It does say string in &#8220;US English date format&#8221; &#8211; which means that for strtotime (&#8220;04/06/2010&#8243;) is April 6th, and not the 4th of June. (Probably no need to get into a discussion about the relative logic of the two systems here).</p>
<p><strong>strtotime</strong> has a pretty decent understanding of language &#8211; so you can do relative times:</p>
<pre class="brush: php">
strtotime(&#039;next Monday&#039;);
strtotime(&#039;+1 years&#039;);
strtotime(&#039;first day next month&#039;);
strtotime(&#039;2010-02 last day&#039;);
</pre>
<p>All return what you&#8217;d expect, based on the datetime the function&#8217;s run&#8230;</p>
<h3>4. mktime()</h3>
<p>Good for catching &#8220;overflows&#8221;. </p>
<pre class="brush: php">
echo date(&quot;M-d-Y&quot;, mktime(0, 0, 0, 12, 32, 2009)) // =&gt; Jan-01-2010 
echo date(&quot;M-d-Y&quot;, mktime(0, 0, 0, 15, 31, 2009)) // =&gt; Mar-31-2010 
</pre>
<p>Like strtotime, mktime doesn&#8217;t go in unit magnitude order &#8211; it&#8217;s hours, minutes, seconds, months, days, years&#8230;. why? because that&#8217;s the decision that was made&#8230;</p>
<p><strong>Find a birth day with mktime:-</strong></p>
<pre class="brush: php">
	$my_birthdate = mktime(0,0,0,5,12,72);
	print date(&quot;l&quot;, $my_birthdate);
	//gives:   Friday
</pre>
<h3>A Few  More Calendar Tricks</h3>
<p><strong>Current age</strong></p>
<pre class="brush: php">
&lt;?php  echo floor(abs(strtotime(&#039;Y&#039;) - strtotime(&#039;02/22/1968&#039;))/31536000);  ?&gt;
</pre>
<p><strong>Easter date</strong></p>
<pre class="brush: php">
&lt;?php echo date(&quot;M-d-Y&quot;, easter_date(2010));   ?&gt;     // Apr-04-2010
</pre>
<p><strong>Datetime constants</strong><br />
PHP 5.1 and later, via the DateTime class, offers a few shorthand formatting strings.</p>
<pre class="brush: php">
&lt;?php echo date(DATE_RSS); ?&gt;
//gives something like: Thu, 21 Feb 2010 09:35:44 -0800
</pre>
<p>The defined strings are <a href="http://us.php.net/manual/en/class.datetime.php#datetime.constants.types">here</a> &#8211; also good for cookies.</p>
<p><strong>Daylight Saving Problems</strong><br />
One way of cutting out possible problems with daylight saving time differences across timezones is to work in UTC, using expressions like these (and then revert back to a local timezone at the end if necessary).</p>
<pre class="brush: php">
date_default_timezone_set(&#039;UTC&#039;);
 
$date_utc = strtotime($date. &quot; UTC&quot;); 
</pre>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/php-calendar-functions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Expressivo (Center) Free WordPress Theme</title>
		<link>http://themocracy.com/2010/02/expressivo-center-free-wordpress-theme/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=expressivo-center-free-wordpress-theme</link>
		<comments>http://themocracy.com/2010/02/expressivo-center-free-wordpress-theme/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 10:09:45 +0000</pubDate>
		<dc:creator>Barrie</dc:creator>
				<category><![CDATA[Free]]></category>
		<category><![CDATA[Themes]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=267</guid>
		<description><![CDATA[Expressivo (Center) is a free WordPress theme - based on Expressivo - a three-column layout, but with the blog post content centered. It's got the same feature list - a jQuery dropdown pages menu, Cufon embedded fonts for post titles, a custom header image and threaded and paged comments.]]></description>
			<content:encoded><![CDATA[<p><img src="http://themocracy.com/wp-content/uploads/2010/02/expressivo_center_wp_theme.jpg" alt="Expressivo (center) wordpress theme" title="expressivo_center_wp_theme" width="253" height="171" class="alignright size-full wp-image-268" /><strong>Expressivo (Center)</strong> is a free WordPress theme &#8211; based on Expressivo &#8211; a three-column layout, but with the blog post content centered. It&#8217;s got the same feature list &#8211; a jQuery dropdown pages menu, Cufon embedded fonts for post titles, a custom header image and threaded and paged comments.<br />
<span id="more-267"></span><br />
Version 1.1 has been tested on Firefox 3, Google Chrome, Internet Explorer 6 &amp; 7 and Opera 9.</p>
<p><strong>Features</strong></p>
<ul>
<li>Add your own header image or logo</li>
<li>jQuery dropdown menu  for pages &#8211; exclude and configure the item order</li>
<li>Cufon Embedded fonts</li>
<li>Custom link and hover colors</li>
</ul>
<p><img style="vertical-align:-5px;" class="alignnone size-full wp-image-234" title="theme download" src="http://themocracy.com/wp-content/uploads/2010/02/download_small.gif" alt="theme download" width="25" height="24" /> <strong>Download</strong>: Expressivo (Center) WordPress Theme v1.1 &#8211; <a href="http://themocracy.com/extra/themes/expressivo-center.zip">expressivo-center.zip</a> Compatible with WP > version <b>2.8</b></p>
<p>This theme is released under the terms of the GPL licence v2.</p>
<p>Our free themes are supplied &#8220;as is&#8221; &#8211; <em>sorry, but we don&#8217;t have the resources to offer support for email enquiries or comments about individual installation/customisation</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/expressivo-center-free-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mistral Free WordPress Theme</title>
		<link>http://themocracy.com/2010/02/mistral-free-wordpress-theme/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mistral-free-wordpress-theme</link>
		<comments>http://themocracy.com/2010/02/mistral-free-wordpress-theme/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 10:09:26 +0000</pubDate>
		<dc:creator>Barrie</dc:creator>
				<category><![CDATA[Free]]></category>
		<category><![CDATA[Themes]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=269</guid>
		<description><![CDATA[Mistral is a free WordPress theme – a two-column layout, with a righthand sidebar. Plus a static pages menu, Cufon embedded fonts for widget headings, a replaceable logo area and paged- and threaded- comments.]]></description>
			<content:encoded><![CDATA[<p><a href="http://themocracy.com/demo/?t=10"><img src="http://themocracy.com/wp-content/uploads/2010/02/mistral-free-wordress-theme.jpg" alt="Mistral WordPress Theme" title="mistral free wordress theme" width="260" height="186" class="alignright size-full wp-image-270" /></a><strong>Mistral</strong> is a free WordPress theme &#8211; a two-column layout, with a righthand sidebar. Plus a static pages menu, Cufon embedded fonts for widget headings, a replaceable logo area and paged- and threaded- comments.<br />
<span id="more-269"></span><br />
Version 1.1 has been tested on Firefox 3,  Internet Explorer 6 &amp; 7, Google Chrome and Opera 9.</p>
<p><strong>Features</strong></p>
<ul>
<li>Replace blog info header with your own logo / design</li>
<li>Cufon embedded fonts for widget headings</li>
<li>Customized link and hover colors</li>
</ul>
<p><strong>Demo:</strong> <a href="http://themocracy.com/demo/?t=10">Mistral demonstration</a></p>
<p><img style="vertical-align:-5px;" class="alignnone size-full wp-image-234" title="theme download" src="http://themocracy.com/wp-content/uploads/2010/02/download_small.gif" alt="theme download" width="25" height="24" /> <strong>Download</strong>: Mistral WordPress Theme v1.1 &#8211; <a href="http://themocracy.com/extra/themes/mistral.zip">mistral.zip</a> Compatible with WP > version <b>2.9</b></p>
<p>This theme is released under the terms of the GPL licence, v2.</p>
<p>Our free themes are supplied &#8220;as is&#8221; &#8211; <em>sorry, but we don&#8217;t have the resources to offer support for email enquiries or comments about individual installation/customisation</em>. </p>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/mistral-free-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WP-Cron – automating and scheduling</title>
		<link>http://themocracy.com/2010/02/wp-cron-automating-scheduling/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=wp-cron-automating-scheduling</link>
		<comments>http://themocracy.com/2010/02/wp-cron-automating-scheduling/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 06:51:03 +0000</pubDate>
		<dc:creator>Barrie</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=260</guid>
		<description><![CDATA[You need a cron job in your WordPress blog - something run to a schedule, hourly, daily...  Instead of fixing up a crontab and using wget or lynx, you can use WordPress's internal version of the cron job.]]></description>
			<content:encoded><![CDATA[<p><strong>You need a cron job in your WordPress blog</strong> &#8211; something run to a schedule, hourly, daily&#8230;  Instead of fixing up a crontab and using wget or lynx, you can use WordPress&#8217;s internal version of the cron job.</p>
<p>This isn&#8217;t a true cron job, with a crontab text file sitting on the server &#8211; it&#8217;s known as a pseudo-cron. Since a script can&#8217;t launch itself, it makes use of a visitor, human or maybe robot, launching it by requesting a page. So the job actually runs at the first launch <em>after</em> the scheduled time, not necessarily at the scheduled time to the exact second.</p>
<h3>wp_schedule_event()</h3>
<p>The most convenient way of using WP-Cron is to wrap it all up in a plugin &#8211; so that the scheduling can be done just the once by including it in the plugin activation function.</p>
<pre class="brush: php">
register_activation_hook(__FILE__, &#039;my_activation&#039;);
add_action(&#039;my_hourly_event&#039;, &#039;do_this_hourly&#039;);
register_deactivation_hook(__FILE__, &#039;my_deactivation&#039;); 

function my_activation() {
wp_schedule_event(time(), &#039;hourly&#039;, &#039;my_hourly_event&#039;);
}

function my_deactivation() {
	wp_clear_scheduled_hook(&#039;my_hourly_event&#039;);
}
	 
function do_this_hourly() {
	// do something here every hour
}
</pre>
<p>The PHP time() used as an argument indicates &#8220;as of now&#8221; &#8211; so if the plugin is activated at 11:23, an hourly event is going to run at xx:23 from now onwards.</p>
<p>If your code is in for example <strong>functions.php</strong> and is executed every time the script is executed, you don&#8217;t want to keep scheduling the same event. Something like this prevents the problem:-</p>
<pre class="brush: php">
if (empty(wp_next_scheduled(&#039;my_event&#039;))) 
		wp_schedule_event(time(), &#039;daily&#039;, &#039;my_event&#039;);
</pre>
<h3> WP-Cron Hourly, Recurrence Intervals</h3>
<p>Only <strong>hourly</strong>, <strong>daily</strong> and <strong>twicedaily</strong> are available immediately &#8211;  but there&#8217;s a trick to getting more and that&#8217;s to tap into the cron_schedules filter and add a key to the schedules array.</p>
<pre class="brush: php">
add_filter(&#039;cron_schedules&#039;, &#039;my_add_weekly&#039;);
 
function my_add_weekly( $schedules ) {
	$schedules[&#039;weekly&#039;] = array(
		&#039;interval&#039; =&gt; 604800, //that&#039;s how many seconds in a week, for the unix timestamp
		&#039;display&#039; =&gt; __(&#039;Once Weekly&#039;)
	);
	return $schedules;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/wp-cron-automating-scheduling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using JSON with WordPress</title>
		<link>http://themocracy.com/2010/02/json-wordpress/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=json-wordpress</link>
		<comments>http://themocracy.com/2010/02/json-wordpress/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 13:16:33 +0000</pubDate>
		<dc:creator>Lisa</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=258</guid>
		<description><![CDATA[With the popularity of jQuery, AJAX, and client-side programming operations in general, there's more use made of JSON as a format for getting data backwards and forwards. 

For example, the Twitter API offers data as JSON  - and more manageably than accessing their RSS XML feeds for user timelines.]]></description>
			<content:encoded><![CDATA[<p><img src="http://themocracy.com/wp-content/uploads/2010/02/json.gif" alt="json with wordpress" title="json-wordpress" width="128" height="128" class="alignright size-full wp-image-259" />With the popularity of jQuery, AJAX, and client-side programming operations in general, there&#8217;s more use made of JSON as a format for getting data backwards and forwards. </p>
<p>For example, the Twitter API offers data as JSON  &#8211; and more manageably than accessing their RSS XML feeds for user timelines etc.</p>
<pre>http://twitter.com/status/user_timeline/USERNAME.json?count=10 </pre>
<p>The issue is how to make use of JSON-encoded information in the WordPress environment &#8211; much of what is available is only recently available, so some care has to be taken about how it&#8217;s used.</p>
<h3>1. Native PHP functions</h3>
<p><strong>json_encode()</strong> and <strong>json_decode()</strong> make life very simple &#8211; but these functions are only available in PHP >= 5.2.0 and WordPress is still designed to run on significantly older versions of PHP than this. Alternatives would have to be supplied if you were thinking about releasing a plugin. There are custom-written functions to reproduce these in PHP4, see for example user contributions to <a href="http://php.net/manual/en/function.json-encode.php">json_encode</a>. These are often not 100% perfect, but one may well do all that you require&#8230;</p>
<h3>2. JSON2</h3>
<p>If you&#8217;re happy to do the work in jQuery/javaScript, WordPress 2.9 comes with JSON2 bundled, registered and ready to go&#8230;</p>
<pre class="brush: php">
add_action(&#039;wp_print_scripts&#039;,&#039;load_json_parser&#039;);

function load_json_parser(){

	if (is_admin()) return; // probably don&#039;t want this on admin pages
	
	wp_enqueue_script(&#039;json2&#039;);

}
</pre>
<p>No need any more to play around with eval in the javaScript, but again, this is a WordPress >= 2.9 thing&#8230;. </p>
<h3>3. Borrowing the Text Editor</h3>
<p>Lastly, there is one more, slightly unofficial, dodge that can be used. WordPress makes use of TinyMCE as its rich text editor and this comes with the its own JSON parser. Results may not be completely predictable. </p>
<pre class="brush: php">
require_once(ABSPATH.&quot;/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php&quot;);

$jsObj = new Moxiecode_JSON();

// encodes the supplied array to JSON format 
$json = $jsObj-&gt;encode(array(&quot;key1&quot;=&gt;&quot;value1&quot;,&quot;key2&quot;=&gt;&quot;value2&quot;));

//decodes supplied JSON to a PHP array
$json_array = $jsObj-&gt;decode($json);

</pre>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/json-wordpress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Separate Pingbacks from User Comments</title>
		<link>http://themocracy.com/2010/02/separate-pingbacks-user-comments/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=separate-pingbacks-user-comments</link>
		<comments>http://themocracy.com/2010/02/separate-pingbacks-user-comments/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 07:29:21 +0000</pubDate>
		<dc:creator>Lisa</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=256</guid>
		<description><![CDATA[People have predicted their death for a long time, but pingbacks/trackbacks (and displaying them) are still firmly with us - there is a certain vanity involved...

They do give an indication of related content, other sites in your niche (and just how many automated spam sites there are out there ) etc. At the same time, they break up the flow of user comments and even with threaded comments can make it difficult for visitors to follow the discussion. ]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-240" title="wordpress comments" src="http://themocracy.com/wp-content/uploads/2010/02/comments.gif" alt="wordpress comments" width="128" height="128" />People have predicted their death for a long time, but pingbacks/trackbacks (and displaying them) are still firmly with us &#8211; there is a certain vanity involved&#8230;</p>
<p>They do give an indication of related content, other sites in your niche (and just how many automated spam sites there are out there ) etc. At the same time, they break up the flow of user comments and even with threaded comments can make it difficult for visitors to follow the discussion.<br />
<span id="more-256"></span><br />
So it&#8217;s reasonable to separate out pingbacks and perhaps not include their digest content, just the title and a link. The method has changed for WordPress 2.7 upwards, with the arrival of threaded comments and their integration into the core code.</p>
<p>The frist step is to adjust the call to the comments template in <strong>single.php</strong> or where ever you&#8217;re hoping to display the comments&#8230; Replace:</p>
<pre class="brush: php">
&lt;?php comments_template(); ?&gt;
</pre>
<p>with</p>
<pre class="brush: php">
&lt;?php comments_template(&#039;&#039;, true); ?&gt;
</pre>
<p>The &#8220;true&#8221; flag gives access to an array $comments_by_type &#8211; as the name might even suggest, a record of the numbers of each type of comment for that post.</p>
<p>Your theme will (should) have something like this code in it &#8211; most likely in <strong>comments.php</strong> but possibly as a separate comments template function in <strong>functions.php</strong> or elsewhere &#8211; the important thing is to locate <strong>comments_number()</strong> and <strong>wp_list_comments()</strong></p>
<pre class="brush: php">
&lt;h3 id=&quot;comments&quot;&gt;&lt;?php comments_number(&#039;No Responses&#039;, &#039;One Response&#039;, &#039;% Responses&#039; );?&gt; to &amp;#8220;&lt;?php the_title(); ?&gt;&amp;#8221;&lt;/h3&gt;

&lt;ol class=&quot;commentlist&quot;&gt;
&lt;?php wp_list_comments(); ?&gt;
&lt;/ol&gt;
</pre>
<p>Replace it with this:</p>
<pre class="brush: php">

&lt;?php if ( !empty($comments_by_type[&#039;comment&#039;]) ) : ?&gt;

&lt;h3 id=&quot;comments&quot;&gt;&lt;?php comments_number(&#039;No Responses&#039;, &#039;One Response&#039;, &#039;% Responses&#039; );?&gt; to &amp;#8220;&lt;?php the_title(); ?&gt;&amp;#8221;&lt;/h3&gt;

&lt;ol class=&quot;commentlist&quot;&gt;
&lt;?php wp_list_comments(&#039;type=comment&#039;); ?&gt;
&lt;/ol&gt;

&lt;?php endif; ?&gt;

&lt;?php if ( ! empty($comments_by_type[&#039;pings&#039;]) ) : ?&gt;

&lt;h3 id=&quot;pings&quot;&gt;Trackbacks/Pingbacks&lt;/h3&gt;
&lt;ol class=&quot;commentlist&quot;&gt;
&lt;?php wp_list_comments(&#039;type=pings&#039;); ?&gt;
&lt;/ol&gt;

&lt;?php endif; ?&gt;
</pre>
<p>We have 2 lists now, created by wp_list_comments</p>
<p>The other (optional) issue is to recalculate the headline figure of comments &#8211; which is still showing the total of user comments + pings. This is done with the use of the <strong>get_comments_number</strong> filter. Add, in functions.php</p>
<pre class="brush: php">
&lt;?php

add_filter(&#039;get_comments_number&#039;, &#039;comment_count&#039;, 0);
function comment_count( $count ) {
if ( ! is_admin() ) {
global $id;
$comments_by_type = &amp;separate_comments(get_comments(&#039;status=approve&amp;post_id=&#039; . $id));
return count($comments_by_type[&#039;comment&#039;]);
} else {
return $count;
}
}
?&gt;
</pre>
<p>And that should be that &#8211; next step would be to restyle the two lists, with a customized callback function for <strong>wp_list_comments()</strong> &#8211; but that will have to be for another post&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/separate-pingbacks-user-comments/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Expressivo Free WordPress Theme</title>
		<link>http://themocracy.com/2010/02/expressivo-free-wordpress-theme/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=expressivo-free-wordpress-theme</link>
		<comments>http://themocracy.com/2010/02/expressivo-free-wordpress-theme/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 13:06:53 +0000</pubDate>
		<dc:creator>Lisa</dc:creator>
				<category><![CDATA[Free]]></category>
		<category><![CDATA[Themes]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=253</guid>
		<description><![CDATA[Expressivo is a free WordPress theme, three-column with two righthand sidebars - going to a single sidebar on single posts and pages. With Cufon embedded fonts for post titles, threaded and paged comments - you can also replace the header completely with your own image.]]></description>
			<content:encoded><![CDATA[<p><a href="http://themocracy.com/demo/?t=8"><img src="http://themocracy.com/wp-content/uploads/2010/02/expressivo-wordpress-theme.jpg" alt="expressivo wordpress themes" title="expressivo wordpress theme" width="226" height="181" class="alignright size-full wp-image-254" /></a><strong>Expressivo</strong> is a free WordPress theme, three-column with two righthand sidebars &#8211; going to a single sidebar on single posts and pages. With Cufon embedded fonts for post titles, threaded and paged comments &#8211; you can also replace the header completely with your own image.<br />
<span id="more-253"></span><br />
Version 1.1 has been tested on Firefox 3, Internet Explorer 6 &amp; 7, Google Chrome, Opera 9.</p>
<p><strong>Features</strong><br />
<img src="http://themocracy.com/wp-content/uploads/2010/02/jcolor.jpg" alt="" title="custom link color" width="391" height="169" class="alignright size-full wp-image-255" /></p>
<ul>
<li>Custom link and hover colors</li>
<li>jQuery dropdown menu  for static pages &#8211; exclude pages and configure item order</li>
<li>Add your own header image / logo</li>
<li>Embedded fonts</li>
<li>Translation ready</li>
</ul>
<p><strong>Demo:</strong> <a href="http://themocracy.com/demo/?t=8">Expressivo demo</a></p>
<p><img style="vertical-align:-5px;" class="alignnone size-full wp-image-234" title="theme download" src="http://themocracy.com/wp-content/uploads/2010/02/download_small.gif" alt="theme download" width="25" height="24" /> <strong>Download</strong>: Expressivo WordPress Theme v1.1 &#8211; <a href="http://themocracy.com/extra/themes/expressivo.zip">expressivo.zip</a> Compatible with WP > version2.8</p>
<p>This theme is released under the terms of the GPL licence.</p>
<p>Our free themes are supplied “as is” &#8211; <em>sorry, but we don’t have the resources to offer support for email enquiries or comments about individual installation/customisation</em>. You’re free to use and modify them as you wish, but we would ask you to retain the credit link in the footer.</p>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/expressivo-free-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A jQuery Slideshow for WordPress 2.9</title>
		<link>http://themocracy.com/2010/02/jquery-slideshow-wordpress/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=jquery-slideshow-wordpress</link>
		<comments>http://themocracy.com/2010/02/jquery-slideshow-wordpress/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 11:03:46 +0000</pubDate>
		<dc:creator>Lisa</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[thumbnails]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=248</guid>
		<description><![CDATA[You want a jQuery slideshow for your WordPress blog? - on the front page, or maybe in the sidebar? No real problem, all the javascript is taken of with the help of a jQuery plugin, all we have to do is figure out how to get the post data. 

And to keep things really simple, this is going to use the thumbnail functions in WP 2.9 - no need to mess around with custom fields any more. ]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-medium wp-image-249" title="jquery-slideshow" src="http://themocracy.com/wp-content/uploads/2010/02/jquery-slideshow-300x206.gif" alt="jquery slideshow" width="245" height="168" /><strong>You want a jQuery slideshow for your WordPress blog? </strong>- on the front page, or maybe in the sidebar? No real problem, all the javascript is taken of with the help of a jQuery plugin, all we have to do is figure out how to get the post data.</p>
<p>And to keep things really simple, this is going to use the thumbnail functions in WP 2.9 &#8211; no need to mess around with custom fields any more.<br />
<span id="more-248"></span><br />
Firstly, you do have to explicitly declare the new thumbnail system in <strong>functions.php</strong> &#8211; and best to wrap it up in an &#8220;if function exists&#8221; to avoid problems for older WP installs.</p>
<pre class="brush: php">
if (function_exists(&#039;add_theme_support&#039;)) {
add_theme_support( &#039;post-thumbnails&#039; );
add_image_size(&#039;slideshow-image&#039;, 300, 160); // for front page slideshow
}
</pre>
<p>The smart move is to define a &#8220;Featured&#8221; category &#8211; any post in that category will be available for the slideshow, and that&#8217;s the selection taken care of. Create a category &#8211; call it featured, or anything, but make a note of the cat_ID &#8211; mouseover a category on the admin categories page and it&#8217;ll be in the url, something like:</p>
<blockquote><p>http://testblog.com/wp-admin/categories.php?action=edit&#038;<strong>cat_ID=3</strong></p></blockquote>
<p>The ordering will be by date, newest first. (Don&#8217;t forget you can tweak the timestamp of a post if you really want to just to get the order exactly as you want it).</p>
<p>So create a couple of posts in this category and add some thumbnails to them &#8211; since our slideshow is going to be 300px by 160px, make sure they&#8217;re bigger than that. Then, in <strong>home.php</strong>, or <strong>index.php</strong>, where ever you want the slideshow to appear, add:</p>
<pre class="brush: php">
&lt;?php

$featured_category_id = 3;
$number_of_posts = 4;

$args = array(&#039;showposts&#039;=&gt;$number_of_posts, &#039;cat&#039;=&gt;$featured_category_id);

$slideshow_query = new WP_Query($args);

?&gt;
&lt;div id=&quot;slideshow&quot;&gt;
&lt;?php
// let&#039;s keep a record of the post IDs as we go, in case we want to omit these from other post loops/lists on the same page
$duplicates = array();

while ($slideshow_query-&gt;have_posts()) : $slideshow_query-&gt;the_post();

//add the ID to the duplicates array for future reference
$duplicates[] = $id;

//test to see whether there&#039;s a thumbnail associated with the post
if (has_post_thumbnail()) {
?&gt;
&lt;div class=&quot;post-thumbnail&quot;&gt;
&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;
&lt;?php	the_post_thumbnail(&#039;slideshow-image&#039;); ?&gt;
&lt;/a&gt;
&lt;/div&gt;
&lt;?php	}
endwhile;
?&gt;
&lt;/div&gt;  &lt;!-- end of #slideshow --&gt;
</pre>
<p>Next, some javascript. We can use the excellent <a href="http://malsup.com/jquery/cycle/">jQuery Cycle Plugin</a> &#8211; as the package stands currently, we&#8217;ll use <strong>jquery.cycle.all.min.js</strong> &#8211; which allows all the possible transition effects etc. &#8211; in practice, you may well want to use the lighter versions&#8230;</p>
<p>* For a standard production site, always use <strong>min</strong> = minified,  rather than <strong>pack</strong> = packed &#8211; pack may be a smaller filesize, but it doesn&#8217;t run quicker&#8230;.</p>
<p>We need a very quick script to configure and activate the plugin &#8211; so create a new file, <strong>slideshow-activate.js</strong></p>
<pre class="brush: js">
jQuery(document).ready(function($){
$(&#039;#slideshow&#039;).cycle({
fx: &#039;fade&#039; // choose your transition type, ex: fade, scrollUp, shuffle, etc...
});
});
</pre>
<p>Later, there are lots of options here, transition speed, pausing etc. &#8211; consult the <a href="http://malsup.com/jquery/cycle/browser.html">plugin pages</a> for ideas.</p>
<p>We need to get our scripts on the WordPress page, and indicate that they depend on jQuery being loaded &#8211; making use of the WordPress functions <strong>wp_register_script</strong> and <strong>wp_enqueue_script</strong> &#8211; so in <strong>functions.php</strong></p>
<pre class="brush: php">

add_action(&#039;wp&#039;, &#039;js_head_load&#039;);

function js_head_load(){

if(is_admin()) return;  //so that we&#039;re not loading unecessary scripts in the admin

wp_register_script(&#039;cycle&#039;, get_bloginfo(&#039;template_directory&#039;)  . &#039;/scripts/jquery.cycle.all.min.js&#039;, array(&#039;jquery&#039;), &#039;1.0&#039;);

wp_enqueue_script(&#039;slideshow-activate&#039;,  get_bloginfo(&#039;template_directory&#039;)  . &#039;/scripts/slideshow-activate.js&#039;, array(&#039;jquery&#039;, &#039;cycle&#039;), &#039;1.0&#039;);

}

</pre>
<p>And then, don&#8217;t forget to put the 2 files into /scripts in your theme folder&#8230;</p>
<p>That should give you a working slideshow &#8211; ready to be styled with some CSS. Note that the way the Cycle plugin works is that it looks to rotate the immediate children of the div being called &#8211; here, they&#8217;re images, they could be eg. divs &#8211; so if you add a wrapper div(s) you may need to adjust slideshow-activate.js.</p>
<p>And if it&#8217;s not working, check first that the right scripts (jQuery, Cycle, slideshow-activate) are actually being loaded and in the right order, by looking at the page source &#8211; and check you&#8217;ve got thumbnails attached to the relevant posts&#8230;</p>
<p>You could go on to tidy this up &#8211; avoiding the hard-coded category id by having something in the theme options admin to change the id for example. Also, as said earlier, there&#8217;s a lot of scope in playing with the plugin parameters to get exactly the slideshow you want&#8230;</p>
<p>Lastly &#8211; the record of the duplicates we kept &#8211; the method for omitting them from subsequent Loops of posts is here: <a href="http://themocracy.com/2010/01/multiple-wordpress-queries-duplicates/">Multiple WordPress query duplicates</a></p>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2010/02/jquery-slideshow-wordpress/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
