<?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>Pro Blog Design</title>
	<atom:link href="https://www.problogdesign.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.problogdesign.com</link>
	<description>Better Looking Blogs Grow Faster</description>
	<lastBuildDate>Thu, 01 Mar 2018 21:41:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.3.2</generator>
	<item>
		<title>Right or Wrong, Open Source Needs Opinionated Leaders</title>
		<link>https://www.problogdesign.com/other/right-or-wrong-open-source-needs-opinionated-leaders/</link>
				<comments>https://www.problogdesign.com/other/right-or-wrong-open-source-needs-opinionated-leaders/#comments</comments>
				<pubDate>Wed, 23 Jan 2013 23:14:49 +0000</pubDate>
		<dc:creator><![CDATA[Michael Martin]]></dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Open-Source]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.problogdesign.com/?p=9031</guid>
				<description><![CDATA[There is a lot of debate going on right now in the WordPress world about the WordPress Foundation barring all ThemeForest/CodeCanyon (Envato really) authors from speaking at WordCamp events.

I don't want to rehash the argument here; the best place to get it is in the <a href="http://www.designcrumbs.com/automatically-blackballed">original post</a>, and the comments on it.

Instead, I want to make a different point: Regardless of whether he is right or not, it's good for WordPress that Matt makes these bold choices.]]></description>
								<content:encoded><![CDATA[<p>There is a lot of debate going on right now in the WordPress world about the WordPress Foundation barring all ThemeForest/CodeCanyon (Envato really) authors from speaking at WordCamp events.</p>
<p>I don&#8217;t want to rehash the argument here; the best place to get it is in the <a href="http://www.designcrumbs.com/automatically-blackballed">original post</a>, and the comments on it.</p>
<p>Instead, I want to make a different point: Regardless of whether he is right or not, it&#8217;s <strong>good for WordPress that Matt makes these bold choices</strong>.</p>
<p>Open source projects benefit hugely from having a spearhead. In their early days most of all, it takes one or two people with drive to get the project off the ground. Then as it grows, dozens of people may contribute to each iteration of the project, but it takes an even stronger leader now to martial that effort together and drive it in the right direction.</p>
<p>And that problem that grows with size. If your project has 4 or 5 contributors, it&#8217;s easy to explain to each of them what you believe is best for the project, and to help them see why you believe that. You have the time for that, and the odds are that the small group who liked your style enough to join your fledgling project probably have similar opinions to you anyway.</p>
<p>When your project is WordPress and thousands of people contribute to it, that&#8217;s no longer possible. You can&#8217;t have 1-to-1s with everyone, and the community is so diverse that you&#8217;ll never convince everyone anyway.</p>
<p>Instead, you have to draw your line in the stand and stand by it. Matt has drawn his. If he wants the WordPress community to have the GPL at its heart, then he needs to be the staunchest supporter of it. <strong>Sometimes that means going further than what might be considered reasonable</strong>. That&#8217;s just part of the deal though. If he compromised more, then the emphasis on promoting the GPL would be lessened.</p>
<p>That takes me back to the title of this post. Matt takes a very hard line on the GPL. A lot of the time, he&#8217;ll be in the right, but not every time. The project still needs someone to consistently take that stance though.</p>
<p>There are plenty of examples of this. David Heinemeier Hansson created the massively popular Ruby on Rails framework, and his strong opinions <a href="http://david.heinemeierhansson.com/2012/the-parley-letter.html">annoy people all the time</a>. Linus Torvalds is hardly one to <a href="https://plus.google.com/u/0/102150693225130002912/posts/8KBkzumMEc1">mince words either</a>. </p>
<p>Without strong leaders, who knows what will happen though? <strong>Decision by committee?</strong> One of my favorite open source projects used to be phpBB, until they took the decision that the next version should be rewritten from scratch&#8230; <a href="https://wiki.phpbb.com/PhpBB4">four years ago</a>. A good leader would never have let that happen (Unless of course he wanted it to, in which case he&#8217;d have seen it through). </p>
<p>So to sum up; what I want to say is that regardless of your stance in this particular argument, it&#8217;s worth remembering it&#8217;s good that people get this fired up and they&#8217;re willing to stand their ground. </p>
<p>If enough of the community truly believes that the leader makes too many &#8220;wrong&#8221; decisions, then all it needs is a new opinionated leader to drive a fork. That&#8217;s <a href="http://ma.tt/2003/01/the-blogging-software-dilemma/">what Matt did</a> after all (Update 26/1/13: As pointed out in the comments, Matt forked it not because he didn&#8217;t like the current leader, but because he had vanished and the project needed a new leader. Sorry if this read misleadingly!). And just because the original project is already huge is no reason that a fork <a href="http://www.ubuntu.com/project/about-ubuntu">might not surpass it one day</a>.</p>
<p><small>PS &#8211; For what it&#8217;s worth though, my opinion on this one is with the developers caught in the middle, which is best summed up <a href="http://www.designcrumbs.com/automatically-blackballed#comment-230">by Pippin&#8217;s comment</a>.</small></p>
<p><small>Most of all though, I think it&#8217;s mind boggling that one employee took it on themselves to pick out one individual developer, and hit them alone with this, right out of the blue. That&#8217;s one place where Matt really should get to the bottom of what went wrong.</small></p>
]]></content:encoded>
							<wfw:commentRss>https://www.problogdesign.com/other/right-or-wrong-open-source-needs-opinionated-leaders/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
							</item>
		<item>
		<title>Authenticate Your Twitter API Calls Before March</title>
		<link>https://www.problogdesign.com/wordpress/authenticate-your-twitter-api-calls-before-march/</link>
				<comments>https://www.problogdesign.com/wordpress/authenticate-your-twitter-api-calls-before-march/#comments</comments>
				<pubDate>Mon, 21 Jan 2013 17:00:21 +0000</pubDate>
		<dc:creator><![CDATA[Michael Martin]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[OAuth]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Transients]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.problogdesign.com/?p=9011</guid>
				<description><![CDATA[<a href="/wordpress/authenticate-your-twitter-api-calls-before-march/"><img src="/wp-content/uploads/2013/01/twitter-api-oauth.jpg" alt="Twitter API OAuth" width="629" height="180" class="alignnone size-full wp-image-9021" /></a>

On the 5th of March, Twitter is going to <a href="https://dev.twitter.com/calendar">retire version 1</a> of its API. The replacement, version 1.1 is very similar, but with one major difference; every single call must be authenticated.

This means that come March, your existing API calls will break; including simple things like displaying tweets on your site. To fix this, you need to move to the new v1.1 API, and authenticate with Twitter.]]></description>
								<content:encoded><![CDATA[<p><a href="//problogdesign.com/wordpress/authenticate-your-twitter-api-calls-before-march/"><img src="//problogdesign.com/wp-content/uploads/2013/01/twitter-api-oauth.jpg" alt="Twitter API OAuth" width="629" height="180" class="alignnone size-full wp-image-9021" srcset="https://www.problogdesign.com/wp-content/uploads/2013/01/twitter-api-oauth.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2013/01/twitter-api-oauth-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></a></p>
<p>On the 5th of March, Twitter is going to <a href="https://dev.twitter.com/calendar">retire version 1</a> of its API. The replacement, version 1.1 is very similar, but with one major difference; every single call must be authenticated.</p>
<p>This means that come March, your existing API calls will break; including simple things like displaying tweets on your site. To fix this, you need to move to the new v1.1 API, and authenticate with Twitter.</p>
<p>Let&#8217;s look at how to do this in WordPress, by embedding a list of tweets on your site (Exactly how it is done in the footer here).</p>
<p class="content-button"><a href="https://gist.github.com/4578005">Download Finished Script</a></p>
<h2>The Flow</h2>
<ol>
<li>Authenticate with TwitterOAuth.</li>
<li>Fetch the tweets (If our cache has expired).</li>
<li>Did it fail? Use the backup.</li>
<li>Did it succeed? Parse them into an array, then save to the database.</li>
<li>Display.</li>
</ol>
<p>This post will skip past most of the display and parsing logic. If you want to read up on those, check out the earlier posts: <a href="/wordpress/how-to-use-the-twitter-api-in-wordpress/">How to Use the Twitter API in WordPress</a> and <a href="/wordpress/add-a-backup-to-embedded-tweets-in-wordpress/">Add a Backup to Embedded Tweets in WordPress</a>.</p>
<h2>1 &#8211; Authenticate with TwitterOAuth</h2>
<p><a href="https://github.com/abraham/twitteroauth">TwitterOAuth</a> is a great free library from <a href="https://abrah.am/">Abraham Williams</a>. It makes the authentication a snap.</p>
<p>To get going, first download the <em>twitteroauth</em> folder <a href="https://github.com/abraham/twitteroauth">from Github</a>. Place this in your theme folder.</p>
<p>Now, create a new file called <code>tweet-list.php</code>, and paste the following:</p>
<pre lang="php" line="1">$numTweets      = 3;                // Number of tweets to display.
$name           = 'problogdesign';  // Username to display tweets from.
$excludeReplies = true;             // Leave out @replies
$transName      = 'list-tweets';    // Name of value in database.
$cacheTime      = 5;                // Time in minutes between updates.
 
$backupName = $transName . '-backup';
 
// Do we already have saved tweet data? If not, lets get it.
if(false === ($tweets = get_transient($transName) ) ) :	
 
  // Get the tweets from Twitter.
  include 'twitteroauth/twitteroauth.php';
  
  $connection = new TwitterOAuth(
    'xxxxxxxxxxxxxxxxxxxxxx',   // Consumer key
    'xxxxxxxxxxxxxxxxxxxxxx',   // Consumer secret
    'xxxxxxxxxxxxxxxxxxxxxx',   // Access token
    'xxxxxxxxxxxxxxxxxxxxxx'    // Access token secret
  );</pre>
<p>This code holds all of our configuration. The top options are fairly self-explanatory, and control the display on your site.</p>
<p>Let&#8217;s skip to the consumer and access keys section. These values are given to you by Twitter. The combination of these ensures to Twitter that you are the user you claim to be, but without giving your password.</p>
<p>This means that a Twitter app should never ask for your password. It also means that if you change your password, you won&#8217;t need to update any of your apps.</p>
<p>To find these details, go to <a href="https://dev.twitter.com/">https://dev.twitter.com/</a> and sign in.</p>
<p>Once in, hover on your name in the top right, and click &#8220;My Applications,&#8221; then &#8220;Create a New Application.&#8221;</p>
<p><img src="/wp-content/uploads/2013/01/twitter-create-app.jpg" alt="Create a New Application" width="629" height="300" class="alignnone size-full wp-image-9016" srcset="https://www.problogdesign.com/wp-content/uploads/2013/01/twitter-create-app.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2013/01/twitter-create-app-300x143.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></p>
<p>Enter a unique name, description, and your site&#8217;s URL. You can leave the Callback URL empty (It would be used if your app was authenticating each of its users, but our&#8217;s will only ever use your account, so we&#8217;re going to put the details directly into the script).</p>
<p>Once created, you will be taken to a new screen where you can copy and paste the <em>Consumer Key</em> and <em>Consumer Secret</em> into the script.</p>
<p>Next, click the &#8220;Create my Access Token&#8221; button. This is a shortcut to authenticate your own account with your application.</p>
<p><img src="/wp-content/uploads/2013/01/create-access-token.jpg" alt="Create Twitter Access Token" width="629" height="180" class="alignnone size-full wp-image-9018" srcset="https://www.problogdesign.com/wp-content/uploads/2013/01/create-access-token.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2013/01/create-access-token-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></p>
<p>Finally, copy the new <em>Access Token</em> and <em>Access Token Secret</em> into the script.</p>
<h2>Fetch the Tweets</h2>
<p>To make a Twitter API call through TwitterOAuth, you use a HTTP verb (GET, POST, or DELETE), specify the API, and then pass in the arguments as an array. You can read the full <a href="https://github.com/abraham/twitteroauth/blob/master/DOCUMENTATION">documentation here</a>.</p>
<p>The API we want to use is <a href="https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline">GET statuses/user_timeline</a>. Therefore, our code looks as follows:</p>
<pre lang="php" line="1">// If excluding replies, we need to fetch more than requested as the
// total is fetched first, and then replies removed.
$totalToFetch = ($excludeReplies) ? max(50, $numTweets * 3) : $numTweets;

$fetchedTweets = $connection->get(
  'statuses/user_timeline',
  array(
    'screen_name'     => $name,
    'count'           => $totalToFetch,
    'exclude_replies' => $excludeReplies
  )
);</pre>
<p>If you exclude replies, the total returned from the API will be less than the total your requested. The <code>$totalToFetch</code> logic ensures that we request enough tweets that even after removing the replies, we will have the number we wanted.</p>
<h2>Did The Request Fail?</h2>
<p>If the request worked, it would have returned with a HTTP status code of 200. We can simply check this, and if it is anything else, use the backed up tweets in our database (We will set this in a minute).</p>
<pre lang="php" line="1">// Did the fetch fail?
if($connection->http_code != 200) :
  $tweets = get_option($backupName); // False if there has never been data saved.</pre>
<h2>Did the Request Succeed?</h2>
<p>If it all went well, we need to pull out the number of tweets we asked for, and parse the data we need from it.</p>
<pre lang="php" line="1">else :
  // Fetch succeeded.
  // Now update the array to store just what we need.
  // (Done here instead of PHP doing this for every page load)
  $limitToDisplay = min($numTweets, count($fetchedTweets));
  
  for($i = 0; $i user->name;
    $permalink = 'http://twitter.com/'. $name .'/status/'. $tweet->id_str;

    /* Alternative image sizes method: http://dev.twitter.com/doc/get/users/profile_image/:screen_name */
    $image = $tweet->user->profile_image_url;

    // Message. Convert links to real links.
    $pattern = '/http:(\S)+/';
    $replace = '<a href="${0}" target="_blank" rel="nofollow">${0}</a>';
    $text = preg_replace($pattern, $replace, $tweet->text);

    // Need to get time in Unix format.
    $time = $tweet->created_at;
    $time = date_parse($time);
    $uTime = mktime($time['hour'], $time['minute'], $time['second'], $time['month'], $time['day'], $time['year']);

    // Now make the new array.
    $tweets[] = array(
            'text' => $text,
            'name' => $name,
            'permalink' => $permalink,
            'image' => $image,
            'time' => $uTime
            );
  endfor;</pre>
<h2>Store the Result</h2>
<p>With the data parsed, the last thing is to store it. We will make two copies:</p>
<ol>
<li>Cached version, which will expire and trigger an update (The transient value).</li>
<li>Permanent version, which will be used if a subsequent request to Twitter fails.</li>
</ol>
<pre lang="php" line="1">    // Save our new transient, and update the backup.
    set_transient($transName, $tweets, 60 * $cacheTime);
    update_option($backupName, $tweets);
  endif;
endif; </pre>
<h2>Display</h2>
<p>Now you have a <code>$tweets</code> array with the data successfully parsed into it. All that remains is to display it. We&#8217;ll make use of WordPress&#8217; <a href="http://codex.wordpress.org/Function_Reference/human_time_diff">human_time_diff</a> function to give relative times, like 5 minutes ago.</p>
<pre lang="php" line="1">// Now display the tweets.
?>
<ul id="tweets">  
  
    <li>
      <p>
        
        <span class="tweet-time"> ago</span>
      </p>
    </li>
  
</ul></pre>
<p>And that&#8217;s it. As before, you can download the complete script here:</p>
<p class="content-button"><a href="https://gist.github.com/4578005">Download Finished Script</a></p>
<p>One final tip is that <strong>to test your code</strong>, you will want to invalidate your cache (So that the fetch code is run). The easiest way to do this is to add this line right under the config data:</p>
<pre lang="php" line="1">delete_transient($transName);</pre>
<p>Feel free to comment if you have any issues! Or let me know if there are any other API examples you&#8217;d like to see.</p>
]]></content:encoded>
							<wfw:commentRss>https://www.problogdesign.com/wordpress/authenticate-your-twitter-api-calls-before-march/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
							</item>
		<item>
		<title>All About Cubic Bezier Curves &#038; Transitions</title>
		<link>https://www.problogdesign.com/coding/all-about-cubic-bezier-curves-transitions/</link>
				<comments>https://www.problogdesign.com/coding/all-about-cubic-bezier-curves-transitions/#comments</comments>
				<pubDate>Mon, 14 Jan 2013 17:00:06 +0000</pubDate>
		<dc:creator><![CDATA[Michael Martin]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://www.problogdesign.com/?p=8904</guid>
				<description><![CDATA[<a href="/coding/all-about-cubic-bezier-curves-transitions/"><img src="/wp-content/uploads/2013/01/cubic-bezier-curves.jpg" alt="Cubic Bezier Curves in CSS3" width="629" height="180" class="alignnone size-full wp-image-8946" /></a>

In the last post, we looked at the <a href="/coding/get-started-with-css3-transitions-today/">basics of CSS transitions</a>, including how to use easing to control how your animation flows. In this post, I want to look deeper at a very powerful easing feature; <strong>cubic bezier curves</strong>.

In short, they let you define exactly what path your animation will take, and thanks to some awesome community tools, they are extremely easy to use (No maths required at all). This gives you <strong>total flexibility with your transitions</strong>.

One of the best tools is the free <a href="http://cubic-bezier.com/">Cubic-Bezier.com</a> by <a href="http://lea.verou.me/2011/09/a-better-tool-for-cubic-bezier-easing/">Lea Verou</a>. It lets you make new curves and see them in action just by dragging the handles. We'll use it for all of the demos in this post, and it's well worth a bookmark!]]></description>
								<content:encoded><![CDATA[<p><a href="/coding/all-about-cubic-bezier-curves-transitions/"><img src="/wp-content/uploads/2013/01/cubic-bezier-curves.jpg" alt="Cubic Bezier Curves in CSS3" width="629" height="180" class="alignnone size-full wp-image-8946" srcset="https://www.problogdesign.com/wp-content/uploads/2013/01/cubic-bezier-curves.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2013/01/cubic-bezier-curves-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></a></p>
<p>In the last post, we looked at the <a href="/coding/get-started-with-css3-transitions-today/">basics of CSS transitions</a>, including how to use easing to control how your animation flows. In this post, I want to look deeper at a very powerful easing feature; <strong>cubic bezier curves</strong>.</p>
<p>In short, they let you define exactly what path your animation will take, and thanks to some awesome community tools, they are extremely easy to use (No maths required at all). This gives you <strong>total flexibility with your transitions</strong>.</p>
<p>One of the best tools is the free <a href="http://cubic-bezier.com/">Cubic-Bezier.com</a> by <a href="http://lea.verou.me/2011/09/a-better-tool-for-cubic-bezier-easing/">Lea Verou</a>. It lets you make new curves and see them in action just by dragging the handles. We&#8217;ll use it for all of the demos in this post, and it&#8217;s well worth a bookmark!</p>
<p>The syntax is simple too. Let&#8217;s look at an example. This simple code can be used to animate an element left or right:</p>
<pre lang="css" line="1">a.slide {
  position: relative;
  transition: left 1.5s linear;
}
 
a.slide-left {
  left: 0;
}
 
a.slide-right {
  left: 580px;
}</pre>
<p>The <code>linear</code> part is actually a shortcut though. What it really says is that you want the animation to follow a particular path on a graph, which we&#8217;ll look at more in a second.</p>
<p>For now, you could rewrite that line to use the <code>cubic-bezier</code> function and get the exact same animation:</p>
<pre lang="css" line="1">transition: left 1.5s cubic-bezier(0, 0, 1, 1);</pre>
<p>That one line can now be used in any transition, and to tweak the animation, all you need to do is change those 4 bracketed values.</p>
<h2>What Is This Graph?</h2>
<p>Let&#8217;s take a look at the <code>linear</code> graph, and see what it means.</p>
<p><img src="/wp-content/uploads/2013/01/linear-large.png" alt="Linear Animation" width="342" height="342" class="alignnone size-full wp-image-8918" srcset="https://www.problogdesign.com/wp-content/uploads/2013/01/linear-large.png 342w, https://www.problogdesign.com/wp-content/uploads/2013/01/linear-large-150x150.png 150w, https://www.problogdesign.com/wp-content/uploads/2013/01/linear-large-300x300.png 300w, https://www.problogdesign.com/wp-content/uploads/2013/01/linear-large-200x200.png 200w, https://www.problogdesign.com/wp-content/uploads/2013/01/linear-large-120x120.png 120w" sizes="(max-width: 342px) 100vw, 342px" /></p>
<p>The <strong>x-axis represents the time</strong> of your animation. The <strong>y-axis represents how far it is</strong> between its starting state, and its ending state.</p>
<p>The x-axis is easier to understand; the far left is the very start of your animation. As you go right, time progresses towards the ending time.</p>
<p>To grasp the y-axis, think of the slide-to-the-right animation. At the very bottom of the y-axis, our button hasn&#8217;t moved, it&#8217;s still on the left of the screen. Half way up the y-axis though, it&#8217;s now half way between the left and right side of the screen, and at the top of the axis, it is now at the far right.</p>
<h2>The Ease Graph</h2>
<p><code>Ease</code> is the default easing style used, and it has the following graph:</p>
<p><img src="/wp-content/uploads/2013/01/ease-large2.png" alt="Ease Animation" width="342" height="342" class="alignnone size-full wp-image-8922" srcset="https://www.problogdesign.com/wp-content/uploads/2013/01/ease-large2.png 342w, https://www.problogdesign.com/wp-content/uploads/2013/01/ease-large2-150x150.png 150w, https://www.problogdesign.com/wp-content/uploads/2013/01/ease-large2-300x300.png 300w, https://www.problogdesign.com/wp-content/uploads/2013/01/ease-large2-200x200.png 200w, https://www.problogdesign.com/wp-content/uploads/2013/01/ease-large2-120x120.png 120w" sizes="(max-width: 342px) 100vw, 342px" /></p>
<p>I&#8217;ve drawn a red line representing a linear animation on the graph, to help highlight the difference. Reading from left-to-right (start to finish) on the graph, you can see that:</p>
<ul>
<li>The <code>ease</code> animation dips under the <code>linear</code> line slightly at the beginning, so it starts off a little slower.</li>
<li>It then rises more steeply to be much well above the linear line, so the middle of the animation is quite fast.</li>
<li>Finally, the line flattens out again at the top, so the animation slows down gracefully towards the end.</li>
</ul>
<p>The values we pass to <code>cubic-bezier</code> are the <strong>co-ordinates of the pink and green circles</strong> on each graph (In the first, the green circle is hidden under the white corner at the top right of the graph). </p>
<p>The specific points used for <code>ease</code> are:</p>
<p><a href="http://cubic-bezier.com/#.25,.1,.25,1" target="_blank"><img src="/wp-content/uploads/2013/01/ease-with-points-2.png" alt="Ease Coordinates" width="342" height="368" class="alignnone size-full wp-image-8932" srcset="https://www.problogdesign.com/wp-content/uploads/2013/01/ease-with-points-2.png 342w, https://www.problogdesign.com/wp-content/uploads/2013/01/ease-with-points-2-278x300.png 278w" sizes="(max-width: 342px) 100vw, 342px" /></a></p>
<p>Therefore, the code to draw this graph is:</p>
<pre lang="css" line="1">transition: left 1.5s cubic-bezier(.25, .1, .25, 1);</pre>
<h2>Custom Animations</h2>
<p>Now that you understand what these graphs tell you, let&#8217;s make some custom animations.</p>
<p>Say you liked the ease animation, but you wanted to make it a little slower again at the start. You would take the first (pink) point, and drag it to the right. You are saying that rather than getting to this stage after 25% of the animation, I now want it to take 40% of the animation&#8217;s total time.</p>
<p><a href="http://cubic-bezier.com/#.4,.1,.25,1" target="_blank"><img src="/wp-content/uploads/2013/01/slower-ease-2.png" alt="Slower Ease" width="342" height="368" class="alignnone size-full wp-image-8931" srcset="https://www.problogdesign.com/wp-content/uploads/2013/01/slower-ease-2.png 342w, https://www.problogdesign.com/wp-content/uploads/2013/01/slower-ease-2-278x300.png 278w" sizes="(max-width: 342px) 100vw, 342px" /></a></p>
<pre lang="css" line="1">transition: left 1.5s cubic-bezier(.4, .1, .25, 1);</pre>
<p>Now let&#8217;s go more extreme. Let&#8217;s say you wanted the middle of the animation to be really, really fast, but the start and end to be more gradual.</p>
<p><a href="http://cubic-bezier.com/#1,0,0,1" target="_blank"><img src="/wp-content/uploads/2013/01/sharp-middle.png" alt="Sharp Middle" width="342" height="368" class="alignnone size-full wp-image-8933" srcset="https://www.problogdesign.com/wp-content/uploads/2013/01/sharp-middle.png 342w, https://www.problogdesign.com/wp-content/uploads/2013/01/sharp-middle-278x300.png 278w" sizes="(max-width: 342px) 100vw, 342px" /></a></p>
<pre lang="css" line="1">transition: left 1.5s cubic-bezier(1, 0, 0, 1);</pre>
<p>Or of course, you could make the start go faster and the end go slower.</p>
<p><a href="http://cubic-bezier.com/#.1,.25,.25,1" target="_blank"><img src="/wp-content/uploads/2013/01/fast-start.png" alt="Fast Start Animation" width="342" height="368" class="alignnone size-full wp-image-8935" srcset="https://www.problogdesign.com/wp-content/uploads/2013/01/fast-start.png 342w, https://www.problogdesign.com/wp-content/uploads/2013/01/fast-start-278x300.png 278w" sizes="(max-width: 342px) 100vw, 342px" /></a></p>
<pre lang="css" line="1">transition: left 1.5s cubic-bezier(0.1, 0.25, 0.25, 1);</pre>
<p>How about a really slow start with a very fast end?</p>
<p><a href="http://cubic-bezier.com/#1,0,1,1" target="_blank"><img src="/wp-content/uploads/2013/01/fast-end.png" alt="Fast Ending Animation" width="342" height="368" class="alignnone size-full wp-image-8939" srcset="https://www.problogdesign.com/wp-content/uploads/2013/01/fast-end.png 342w, https://www.problogdesign.com/wp-content/uploads/2013/01/fast-end-278x300.png 278w" sizes="(max-width: 342px) 100vw, 342px" /></a></p>
<pre lang="css" line="1">transition: left 1.5s cubic-bezier(1, 0, 1, 1);</pre>
<p>That should be plenty of regular examples for now. There are endless combinations you can set up, so let&#8217;s move on to another nifty trick; going beyond the ends of the graph.</p>
<h2>Going Past The Start and End</h2>
<p>All of our animations so far have started at 0 on the y-axis, and ended at 1. You don&#8217;t have to stick to these limits though. It is entirely possible to have your animation go past its supposed end point, and then circle back to it.</p>
<p>In this example, our button start off slow, build up speed, slide right past its goal, and then reverse back into place.</p>
<p><a href="http://cubic-bezier.com/#.4,.1,.55,1.3"><img src="/wp-content/uploads/2013/01/past-the-top.png" alt="Animate Past the End" width="342" height="457" class="alignnone size-full wp-image-8941" srcset="https://www.problogdesign.com/wp-content/uploads/2013/01/past-the-top.png 342w, https://www.problogdesign.com/wp-content/uploads/2013/01/past-the-top-224x300.png 224w" sizes="(max-width: 342px) 100vw, 342px" /></a></p>
<pre lang="css" line="1">transition: left 1.5s cubic-bezier(0.4, 0.1, 0.55, 1.3);</pre>
<p>These sorts of animations can feel much more natural. As an example, think of scrolling webpages on your phone/tablet. When you flick down to the very bottom or the very top, the page goes right past the top and bottom and then glides back into place.</p>
<p>If you really wanted, you can also do the opposite and have your animation go backwards in the beginning.</p>
<p><a href="http://cubic-bezier.com/#.4,-0.45,1,.9"><img src="/wp-content/uploads/2013/01/start-backwards.png" alt="Animate Backwards" width="342" height="497" class="alignnone size-full wp-image-8942" srcset="https://www.problogdesign.com/wp-content/uploads/2013/01/start-backwards.png 342w, https://www.problogdesign.com/wp-content/uploads/2013/01/start-backwards-206x300.png 206w" sizes="(max-width: 342px) 100vw, 342px" /></a></p>
<pre lang="css" line="1">transition: left 1.5s cubic-bezier(0.4, -0.45, 1, 0.9);</pre>
<p>There are 2 natural limitations to these techniques though:</p>
<ul>
<li>The time can&#8217;t be adjusted in this way. It will always be whatever length you specified.</li>
<li>For some CSS properties, going above/below the y-axis boundaries will have no effect, e.g. opacity. The element can&#8217;t be any less visible than invisible&#8230;</li>
</ul>
<p>The best thing to do is to experiment. The syntax is incredibly simple. Set up your animation using the cubic-bezier for the default <code>ease</code> function. Once it&#8217;s working, <strong>tweak the values to see what looks best</strong>.</p>
]]></content:encoded>
							<wfw:commentRss>https://www.problogdesign.com/coding/all-about-cubic-bezier-curves-transitions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
							</item>
		<item>
		<title>Get Started With CSS3 Transitions Today</title>
		<link>https://www.problogdesign.com/coding/get-started-with-css3-transitions-today/</link>
				<comments>https://www.problogdesign.com/coding/get-started-with-css3-transitions-today/#comments</comments>
				<pubDate>Mon, 07 Jan 2013 17:00:48 +0000</pubDate>
		<dc:creator><![CDATA[Michael Martin]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://www.problogdesign.com/?p=8869</guid>
				<description><![CDATA[<img src="/wp-content/uploads/2013/01/css3-transitions2.jpg" alt="CSS3 Transitions" width="629" height="180" class="alignnone size-full wp-image-8893" />

Transitions (basic animations) are one of the most popular additions in CSS3, and one of the easiest to implement for big gains on your site.

A transition is simply an animation from one set of CSS properties to another. So for example; whilst before you may have had links with blue text, which suddenly turned orange when you hovered on them, you would now replace that sudden jump with a more graceful animation.

In this post, we'll look at the basic syntax, step through some examples, and finally take a brief look at current browser support.]]></description>
								<content:encoded><![CDATA[<p><img src="/wp-content/uploads/2013/01/css3-transitions2.jpg" alt="CSS3 Transitions" width="629" height="180" class="alignnone size-full wp-image-8893" srcset="https://www.problogdesign.com/wp-content/uploads/2013/01/css3-transitions2.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2013/01/css3-transitions2-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></p>
<p>Transitions (basic animations) are one of the most popular additions in CSS3, and one of the easiest to implement for big gains on your site.</p>
<p>A transition is simply an animation from one set of CSS properties to another. So for example; whilst before you may have had links with blue text, which suddenly turned orange when you hovered on them, you would now replace that sudden jump with a more graceful animation.</p>
<p>In this post, we&#8217;ll look at the basic syntax, step through some examples, and finally take a brief look at current browser support.</p>
<h2>Syntax</h2>
<p>The process is very simple. Let&#8217;s say you wanted to set up the blue-&gt;orange link example:</p>
<ol>
<li>Setup CSS for the link to be blue.</li>
<li>Setup CSS for the link to be orange.</li>
<li>Add a transition.</li>
</ol>
<p>The end result would be something like this (Don&#8217;t worry about the transition syntax right now. I just want to show you how little code this really is):</p>
<pre lang="css" line="1">a:link, a:visited {
  color: blue;
  
  -webkit-transition:  color 0.5s;
  -moz-transition:     color 0.5s;
  -o-transition:       color 0.5s;
  transition:          color 0.5s;
}

a:hover, a:active {
  color: orange;
}</pre>
<p>Now, let&#8217;s look at the syntax. The first thing to point out is that as in the example above, you will need to use browser prefixes (<code>-o-</code> for Opera, <code>-moz-</code> for Firefox etc.). This is a nuisance, but a minor one as the actual values you give to each one are identical at least.</p>
<p>The <code>transition</code> property takes up to 4 arguments:</p>
<ul>
<li>Property to animate &#8211; You can see a list of all <a href="http://www.w3.org/TR/css3-transitions/#properties-from-css-">supported properties here</a>.</li>
<li>Length of transition.</li>
<li>Delay before starting.</li>
<li>Easing. We&#8217;ll look at this more in a minute, but think of it as the &#8220;style&#8221; of animation.</li>
</ul>
<p>So now looking back at the first example, you can see that I specified to animate the <code>color</code> property for 0.5 seconds. The browser then defaulted the delay to 0 (i.e. start immediately), and used its default easing.</p>
<p>Now let&#8217;s look at a few more examples of this in use. For each one, I&#8217;ll put the code here, and you can see the <a href="/uploads/css3-animations/1/examples.html">demo on this page</a>. </p>
<h4>1 &#8211; A Simple Fade</h4>
<p class="content-button"><a href="/uploads/css3-animations/1/examples.html#ex1" rel="nofollow">View Demo</a></p>
<pre lang="css" line="1">a.fade {
  background: #0068b8;

  -webkit-transition:  background-color 0.8s;
  -moz-transition:     background-color 0.8s;
  -o-transition:       background-color 0.8s;
  transition:          background-color 0.8s;
}

a.fade:hover, a.fade:active {
  background-color: #05406d;
}</pre>
<h4>2 &#8211; Slide Left and Right</h4>
<p class="content-button"><a href="/uploads/css3-animations/1/examples.html#ex2" rel="nofollow">View Demo</a></p>
<p>I use some JavaScript first in this example, to add/remove slide-left and slide-right classes to the link.<a href="#f1">[1]</a></p>
<pre lang="javascript" line="1">$('.slide').on('click', function() {
  slideLeftRight($(this));
});

function slideLeftRight(ele) {
  if(ele.hasClass('slide-left')) {
    ele.removeClass('slide-left').addClass('slide-right');
  } else {
    ele.removeClass('slide-right').addClass('slide-left');
  }
}</pre>
<p>The CSS is just as simple as before though:</p>
<pre lang="css" line="1">a.slide {
  position: relative;
  -webkit-transition:  left 1.5s;
  -moz-transition:     left 1.5s;
  -o-transition:       left 1.5s;
  transition:          left 1.5s;
}

a.slide-left {
  left: 0;
}

a.slide-right {
  left: 580px;
}</pre>
<h4>3 &#8211; Multiple Properties at Once (Zooming)</h4>
<p class="content-button"><a href="/uploads/css3-animations/1/examples.html#ex3" rel="nofollow">View Demo</a></p>
<p>In the previous examples, we have always specified a particular property to animate. You don&#8217;t have to do it this way though. Instead, you can specify a comma-separated list of properties, or better yet, type <code>all</code>, and the browser will animate anything it can.</p>
<p>In this example, we use the <code>all</code> keyword to animate the width, height and line-height all at once.</p>
<pre lang="css" line="1">a.zoom {
  -webkit-transition:  all 0.8s;
  -moz-transition:     all 0.8s;
  -o-transition:       all 0.8s;
  transition:          all 0.8s;
}

a.zoom:hover, a.zoom:active {
  width: 200px;
  height: 50px;
  line-height: 50px;
}</pre>
<h4>4 &#8211; Stretch Search Box on Focus</h4>
<p class="content-button"><a href="/uploads/css3-animations/1/examples.html#ex4" rel="nofollow">View Demo</a></p>
<p>The last example is to enlarge the search box for typing when a user clicks into it. This effect has become increasingly popular since being included in the TwentyEleven default theme.</p>
<pre lang="css" line="1">.search-field {
  width: 108px;
  border: 1px solid #ccc;
  background: #f5f5f5;
  padding: 5px;
  
  -webkit-transition:  width 0.8s;
  -moz-transition:     width 0.8s;
  -o-transition:       width 0.8s;
  transition:          width 0.8s;
}

.search-field:focus {
  width: 200px;
}</pre>
<h2>Easing</h2>
<p>Now, let&#8217;s return to the easing property, as it can be very powerful. Earlier, I said it is like the style of the animation, which is true. More specifically though, it controls your rate of animating.</p>
<p>Consider an animation which moves an object from left to right. It could make the entire animation at the same pace (e.g. it moves 100px every 0.2 seconds, whether it&#8217;s the first 0.2 or the last), or it could accelerate rapidly at the start and slow towards the end, or start off slow and pick up speed as it goes.</p>
<p>There are a lot of possibilities, but the easiest way to understand them is to see them in action. The last example I&#8217;ve put together uses the slide left/right animation again, but with a different easing option on each button.</p>
<p class="content-button"><a href="/uploads/css3-animations/1/examples.html#ex5" rel="nofollow">View Demo</a></p>
<p>Click the &#8220;click here&#8221; link under section 5 of the examples, and you will see the 5 buttons animate. All of them use the same animation, for the same length of time, but with the easing function labelled on their button.</p>
<p>You can specify this with your other properties, e.g.</p>
<pre lang="css" line="1">transition:          left 1.5s ease-out;</pre>
<p>A more flexible approach however can be to use extra CSS classes, e.g.</p>
<pre lang="css" line="1">a.ease-in {
  -webkit-transition-timing-function:  ease-in;
  -moz-transition-timing-function:     ease-in;
  -o-transition-timing-function:       ease-in;
  transition-timing-function:          ease-in;
}

a.ease-out {
  -webkit-transition-timing-function:  ease-out;
  -moz-transition-timing-function:     ease-out;
  -o-transition-timing-function:       ease-out;
  transition-timing-function:          ease-out;
}</pre>
<p>Now to change any animated elements easing, I simply give it the <code>ease-in</code> or <code>ease-out</code> CSS classes.</p>
<h2>Browser Support</h2>
<p>Browser support for CSS transitions these days is great! Chrome has supported it from version 1.0, Firefox from version 4.0, Safari from 3.2, and Opera from 10.5.<a href="#f2" rel="nofollow">[2]</a></p>
<p>As you would expect though, Internet Explorer is lagging behind. They are fully supported in IE10 (And without any vendor prefix, which is a nice touch), but not in any previous version. Given that IE10 currently only runs on Windows 8, this means it will be a long time before the majority of IE users see your transitions.</p>
<p>Still, don&#8217;t let that stop you. The other browsers have great support for these, they&#8217;re an extremely simple upgrade to make to your site, and it all degrades gracefully for IE users anyway, so there&#8217;s no real loss!</p>
<div class="footnotes">
<p><span id="f1">[1]</span> &#8211; If you were to replace all of your jQuery animations with CSS ones, you may find that you can rewrite the functions here in plain old JavaScript and not load that library at all.</p>
<p><span id="f2">[2]</span> &#8211; Stats from <a href="https://developer.mozilla.org/en-US/docs/CSS/Tutorials/Using_CSS_transitions#Browser_compatibility">Mozilla Developer Network</a>.</p>
</div>
]]></content:encoded>
							<wfw:commentRss>https://www.problogdesign.com/coding/get-started-with-css3-transitions-today/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
							</item>
		<item>
		<title>How to Add a &#8220;Reading Mode&#8221; to Your Posts</title>
		<link>https://www.problogdesign.com/wordpress/how-to-add-a-reading-mode-to-your-posts/</link>
				<comments>https://www.problogdesign.com/wordpress/how-to-add-a-reading-mode-to-your-posts/#comments</comments>
				<pubDate>Wed, 25 Jul 2012 16:00:20 +0000</pubDate>
		<dc:creator><![CDATA[Michael Martin]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Clutter]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://www.problogdesign.com/?p=8830</guid>
				<description><![CDATA[<img src="/wp-content/uploads/2012/07/reading-mode.jpg" alt="Reading Mode Preview" title="Reading Mode Preview" width="629" height="180" class="alignnone size-full wp-image-8841" />

In this post, I will show you a simple way to add a distraction-free "Reading Mode" to your blog.

The purpose of adding a feature like this is to enable a visitor to remove all the clutter of your site, and focus solely on the post itself.

In an ideal world; there would never be a need for such a feature. In reality though, sites have numerous other goals to achieve, such as brand building, serving ads, promoting other content etc. In this way, you can compromise between the two. Do what you need when the user first arrives, but <strong>get out of the way when they decide what to read</strong>.]]></description>
								<content:encoded><![CDATA[<p><img src="/wp-content/uploads/2012/07/reading-mode.jpg" alt="Reading Mode Preview" title="Reading Mode Preview" width="629" height="180" class="alignnone size-full wp-image-8841" srcset="https://www.problogdesign.com/wp-content/uploads/2012/07/reading-mode.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/07/reading-mode-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></p>
<p>In this post, I will show you a simple way to add a distraction-free &#8220;Reading Mode&#8221; to your blog.</p>
<p><strong>Update (1st March 2018)</strong>: I&#8217;ve taken the demo site offline now, but added screenshots of the end result. The link itself looks as follows:</p>
<p><img src="/wp-content/uploads/2012/07/reading-mode-link.jpg" alt="Reading mode link" width="629" height="227" class="alignnone size-full wp-image-9074" srcset="https://www.problogdesign.com/wp-content/uploads/2012/07/reading-mode-link.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/07/reading-mode-link-300x108.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></p>
<p>When clicked, that then loads a modal like so:</p>
<p><img src="/wp-content/uploads/2012/07/reading-mode-popup.jpg" alt="Reading Mode Modal" width="629" height="386" class="alignnone size-full wp-image-9076" srcset="https://www.problogdesign.com/wp-content/uploads/2012/07/reading-mode-popup.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/07/reading-mode-popup-300x184.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></p>
<p>The purpose of adding a feature like this is to enable a visitor to remove all the clutter of your site, and focus solely on the post itself.</p>
<p>In an ideal world; there would never be a need for such a feature. In reality though, sites have numerous other goals to achieve, such as brand building, serving ads, promoting other content etc. In this way, you can compromise between the two. Do what you need when the user first arrives, but <strong>get out of the way when they decide what to read</strong>.</p>
<p class="notice">This script is also available as a free plugin on <a href="https://github.com/michael-martin/PBD-Reading-Mode">Github</a> (<a href="https://github.com/michael-martin/PBD-Reading-Mode/zipball/master">Direct download link</a>). No configuration needed, just upload and hit activate. Or feel free to fork and improve it.</p>
<h2>The Method</h2>
<p>The trick is simple. We will use Jack Moore&#8217;s awesome <a href="http://www.jacklmoore.com/colorbox">Colorbox plugin</a> for jQuery to &#8220;pop out&#8221; the post and fade out the rest of the page when needed.</p>
<p>All we need to do is set some options for the plugin, and insert our link. We will create the link with JavaScript so that it won&#8217;t appear to search engines or RSS readers as part of your post&#8217;s content.<span id="more-8830"></span></p>
<h2>1 &#8211; Get the Files</h2>
<p>The first step is to download the latest Colorbox files from <a href="http://www.jacklmoore.com/colorbox">here</a>. When you open up the zip folder, you will get a folder structure like this:</p>
<p><img src="/wp-content/uploads/2012/07/cbox-files.jpg" alt="" title="cbox-files" width="555" height="223" class="alignnone size-full wp-image-8833" srcset="https://www.problogdesign.com/wp-content/uploads/2012/07/cbox-files.jpg 555w, https://www.problogdesign.com/wp-content/uploads/2012/07/cbox-files-300x120.jpg 300w" sizes="(max-width: 555px) 100vw, 555px" /></p>
<p>The 5 example folders contain different styles that you can use for your Colorbox popup. Load up the index.html file in each folder and click a link to see how it looks.</p>
<ul>
<li>Copy the <em>jquery.colorbox-min.js</em> file from the &#8216;<em>colorbox</em>&#8216; folder into your theme&#8217;s <em>/js/</em> folder (Create one if it doesn&#8217;t exist).</li>
<li>Choose one of the example styles, and copy the <em>colorbox.css</em> file into your theme&#8217;s directory.</li>
<li>In the same example folder, copy all of the <em>/images/</em> files into your theme&#8217;s images directory.</li>
</ul>
<p>As a sidenote; you may prefer to create a &#8216;colorbox&#8217; directory in your theme&#8217;s directory instead, and put all of these files there. That&#8217;s what I would do personally, but for this tutorial, I&#8217;m following how the default TwentyEleven theme organizes itself.</p>
<h2>2 &#8211; Queue the Files</h2>
<p>Now, you have all the files you need for the script. The next step is to load them into your page. To do this, open your theme&#8217;s <em>functions.php</em> file (Create a file with that name if none exists) and paste the following before the closing ?> tag:</p>
<pre lang="php" line="1">/**
 * Queue Reading Mode scripts and styles.
 */
function pbd_rm_scripts() {
	if(is_single() ) :
		wp_enqueue_script(
			'colorbox',
			get_bloginfo('template_directory') . '/js/jquery.colorbox-min.js',
			array('jquery'),
			'1.3.19',
			true
		);
		
		wp_enqueue_script(
			'pbd-reading-mode',
			get_bloginfo('template_directory') . '/js/pbd-reading-mode.js',
			array('jquery', 'colorbox'),
			'0.1',
			true
		);
		
		wp_enqueue_style(
			'colorbox',
			get_bloginfo('template_directory') . '/colorbox.css',
			array(),
			'1.3.19'
		);
	endif;
}
add_action('wp_enqueue_scripts', 'pbd_rm_scripts');</pre>
<p>This simply tells the theme about each of your files; the two Colorbox files and the reading-mode JavaScript file we&#8217;re going to create next. They will all be loaded in the site now, but only on single-post pages.</p>
<h2>3 &#8211; Wrap Your Post Content in a Div</h2>
<p>For Colorbox to know what counts as your post content, we need to have one element that contains that post, and nothing else. Some themes will already have this, but the class names vary from theme to theme. To make things simpler, we&#8217;re going to use a WordPress filter to add our own div around the_content.</p>
<p>Carrying on in <em>functions.php</em>, paste the following:</p>
<pre lang="php" line="1">/**
 * On single posts, it wraps the content in div.
 */
function pbd_rm_content_filter($content) {
	if(is_single() ) {
		$content = '<div class="rm-content">'. $content .'</div>';
	}
	
	return $content;
}
add_filter('the_content', 'pbd_rm_content_filter');</pre>
<p>This filter runs every time your theme displays a post&#8217;s content. If the user is on a single post page, then our code will wrap a div with class <em>.rm-content</em> around it.</p>
<h2>4 &#8211; Create the Link</h2>
<p>With everything in place, you&#8217;re ready to set up your &#8220;Reading Mode&#8221; link. In your theme&#8217;s <em>/js/</em> directory, create a new file named &#8216;pbd-reading-mode.js&#8217;, and paste the following into it:</p>
<pre lang="javascript" line="1">jQuery(document).ready(function($) {
	// Set this to the CSS selector of the element that wraps your post content.
	// e.g. .entry or .entry-content
	var selector = '.rm-content';
	
	// The HTML for your "View This in Reading Mode" link.
	var html = '<p class="rm-button">View this post in <a href="#" class="reading-mode" rel="nofollow">Reading Mode</a>.</p>';
	
	$(selector)
		.prepend(html)
		.find('.reading-mode')
		.colorbox({
			innerHeight: "80%",
			innerWidth: 700,
			inline: true,
			href: selector
		});
});</pre>
<p>On line 4, you can set the selector for the element that wraps the post (No need if you&#8217;ve used the filter from step 3), and on line 7, you can customize the HTML for the &#8220;Reading Mode&#8221; link.</p>
<p>Line 10 adds that HTML to our content wrapping element (i.e. it creates the link). On line 12, we initiate Colorbox with options for its size, and specify its content as the wrapping element. You can read more about the possible options here on Colorbox&#8217;s site.</p>
<h2>5 &#8211; Style It</h2>
<p>At this point, you can save your work and try it out. The &#8220;View in Reading Mode&#8221; link should appear at the top of your posts, and clicking it should load the post content in a popup.</p>
<p>The last step is to add a little CSS to make that popup as legible as possible. Feel free to experiment with this, but here is what I have used:</p>
<pre lang="css" line="1">/**
 * Reading Mode
 */
#cboxLoadedContent > div {
	text-align: left;
	padding: 20px;
	font: 16px/24px Georgia, serif;
	width: 90%;
}

#cboxLoadedContent > div .rm-button {
	display: none;
}

#cboxLoadedContent > div p {
	margin-bottom: 24px;
}

#cboxLoadedContent > div h2 {
	font-size: 22px;
	margin-bottom: 24px;
}

#cboxLoadedContent > div h3 {
	font-size: 18px;
	margin-bottom: 24px;
}

#cboxLoadedContent > div h4 {
	font-size: 16px;
	margin-bottom: 24px;
}</pre>
<p>Some notes on the CSS:</p>
<ul>
<li>I use <em>#cboxLoadedContent > div</em> to match the content wrapping element. This should make it a little more flexible than specifying a CSS classname.</li>
<li>Line 11 is used to stop the &#8220;Reading Mode&#8221; link from appearing inside the popup.</li>
<li>If you want to use your theme&#8217;s existing post styles, you can skip the filter and instead specify an element like .entry-content in the JavaScript. The element itself is moved into the popup, so all of its styles will then apply to the popup as well.</li>
</ul>
<p>And that&#8217;s all there is to it. Not a lot of code, for a useful little feature. Let me know what you think. Is this sort of thing a good idea, or better avoided? </p>
]]></content:encoded>
							<wfw:commentRss>https://www.problogdesign.com/wordpress/how-to-add-a-reading-mode-to-your-posts/feed/</wfw:commentRss>
		<slash:comments>57</slash:comments>
							</item>
		<item>
		<title>7 Plugins to Save Time With the Dashboard</title>
		<link>https://www.problogdesign.com/wordpress/7-plugins-to-save-time-with-the-dashboard/</link>
				<comments>https://www.problogdesign.com/wordpress/7-plugins-to-save-time-with-the-dashboard/#comments</comments>
				<pubDate>Mon, 14 May 2012 16:00:56 +0000</pubDate>
		<dc:creator><![CDATA[Claudia Somerfield]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[AdSense]]></category>
		<category><![CDATA[Analytics]]></category>
		<category><![CDATA[Comments]]></category>
		<category><![CDATA[Dashboard]]></category>
		<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://www.problogdesign.com/?p=8801</guid>
				<description><![CDATA[<img class="alignnone size-full wp-image-8815" title="dashboard-plugins" src="/wp-content/uploads/2012/05/dashboard-plugins.jpg" alt="" width="629" height="180" />

As bloggers, we spend a lot of time working on a range of different tasks. This includes things like checking stats, monitoring ad revenue, and interacting on social media.

That leaves us with a lot of sites to log into. But by adding a few WordPress plugins, you can pull some of this data back into the WordPress dashboard, which saves you time by giving a quick snapshot overview of everything.]]></description>
								<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-8815" title="dashboard-plugins" src="/wp-content/uploads/2012/05/dashboard-plugins.jpg" alt="" width="629" height="180" srcset="https://www.problogdesign.com/wp-content/uploads/2012/05/dashboard-plugins.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/05/dashboard-plugins-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></p>
<p>As bloggers, we spend a lot of time working on a range of different tasks. This includes things like checking stats, monitoring ad revenue, and interacting on social media.</p>
<p>That leaves us with a lot of sites to log into. But by adding a few WordPress plugins, you can pull some of this data back into the WordPress dashboard, which saves you time by giving a quick snapshot overview of everything.</p>
<h3>Analytics 360</h3>
<p><img class="alignnone size-full wp-image-8813" title="analytics-360" src="/wp-content/uploads/2012/05/analytics-360.jpg" alt="" width="629" height="180" srcset="https://www.problogdesign.com/wp-content/uploads/2012/05/analytics-360.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/05/analytics-360-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></p>
<p>Analytics 360 brings Google Analytics and Mailchimp (Newsletter service) data together, and displays them on a subpage under the WordPress dashboard. This helps in accessing analytics tools like visualizing site traffic and managing mailing lists easier even without leaving WordPress.</p>
<p>A Google Analytics account is required, but you do not need to be a Mailchimp user.</p>
<p><a href="http://wordpress.org/extend/plugins/analytics360/">Analytics 360 Download</a>.</p>
<h3>My Gmail</h3>
<p>My Gmail is another simple dashboard plugin which displays all the unread mails from your Gmail account without any need to load Gmail.</p>
<p>However, this plugin works only over HTTPS, so you will need to have purchased an SSL certificate.</p>
<p><a href="http://wordpress.org/extend/plugins/my-gmail/">My Gmail Download</a>.</p>
<h3>Full Comments on Dashboard</h3>
<p><img class="alignnone size-full wp-image-8808" title="full-comments" src="/wp-content/uploads/2012/05/full-comments.jpg" alt="" width="629" height="180" srcset="https://www.problogdesign.com/wp-content/uploads/2012/05/full-comments.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/05/full-comments-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></p>
<p>The Recent Comments Box in WordPress facilitates managing and replying to comments easily, but it just shows the comment excerpt and the user has to load another page to view the full comment.</p>
<p>This limitation can be overcome with the Full Comments on Dashboard plugin. It extends the default widget to show the full comment, allowing you to reply properly.</p>
<p><a href="http://wordpress.org/extend/plugins/full-comments-on-dashboard/">Full Comments on Dashboard Download</a>.</p>
<h3>Google Adsense Summary</h3>
<p>This is another important plugin which lets the user to check Adsense earnings for a stipulated time. After the successful installation of the plugin, the user should enter his username and password in the settings page and the earnings from his/her account are displayed anytime.</p>
<p><a href="http://wordpress.org/extend/plugins/google-adsense-summary/">Google Adsense Summary Download</a>.</p>
<h3>Feedburner Stats</h3>
<p><img class="alignnone size-full wp-image-8809" title="feedburner" src="/wp-content/uploads/2012/05/feedburner.jpg" alt="" width="629" height="180" srcset="https://www.problogdesign.com/wp-content/uploads/2012/05/feedburner.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/05/feedburner-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></p>
<p>Feed Stats is a simple statistical tool for viewing and managing FeedBurner statistics. Under the Dashboard, you will find a &#8220;Feed Stats&#8221; link with graphs based on your recent FeedBurner data.</p>
<p>The plugin displays your FeedBurner statistics for things like subscribers on your blog, which the feed readers are being used, and which of the posts are most popular with subscribers.</p>
<p><a href="http://wordpress.org/extend/plugins/feed-stats-plugin-for-wordpress-reworked/">Feedburner Stats Download</a>.</p>
<h3>Twitter Tools</h3>
<p>The Twitter Tools plugin makes it easy for the WordPress user to manage his Twitter posts. This plugin helps to Tweet directly from the dashboard itself without opening another browser tab.</p>
<p>Using this plugin, the user can automatically Tweet about new posts, create a collection of his Tweets and publish on the users blogs, Tweet from any page on the blog, etc.</p>
<p><a href="http://wordpress.org/extend/plugins/twitter-tools/">Twitter Tools Download</a>.</p>
<h3>Plugin Central</h3>
<p><img class="alignnone size-full wp-image-8811" title="plugin-central" src="/wp-content/uploads/2012/05/plugin-central.jpg" alt="" width="629" height="180" srcset="https://www.problogdesign.com/wp-content/uploads/2012/05/plugin-central.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/05/plugin-central-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></p>
<p>Finally, Plugin Central is a plugin for managing all other plugins for WordPress. This lets you easily install plugins by naming them, or linking to a zip folder, as well as adding multiple plugins at once, and updating all of your existing plugins directly from the dashboard.</p>
<p><a href="http://wordpress.org/extend/plugins/plugin-central/">Plugin Central Download</a>.</p>
<p>And that concludes our list. Not all of these plugins will be for you, but if you spend a lot of time on some of the services above, then give it a go and see if it saves you some time!</p>
<p>If you need more ideas, check out the <a href="http://wordpress.org/extend/plugins/tags/dashboard">dashboard tag</a> on the WP.org Plugin Directory.</p>
<p>If you have any other suggestions for great dashboard plugins, let me know in the comments!</p>
]]></content:encoded>
							<wfw:commentRss>https://www.problogdesign.com/wordpress/7-plugins-to-save-time-with-the-dashboard/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
							</item>
		<item>
		<title>CSS &#038; JS Auto-Refreshing with Live.js</title>
		<link>https://www.problogdesign.com/tools/css-js-auto-refreshing-with-live-js/</link>
				<comments>https://www.problogdesign.com/tools/css-js-auto-refreshing-with-live-js/#comments</comments>
				<pubDate>Thu, 03 May 2012 16:00:40 +0000</pubDate>
		<dc:creator><![CDATA[Michael Martin]]></dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Live.js]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.problogdesign.com/?p=8789</guid>
				<description><![CDATA[<img src="/wp-content/uploads/2012/05/livejs-wp.jpg" alt="Live.js and WordPress" title="Live.js and WordPress" width="629" height="180" class="alignnone size-full wp-image-8795" />

I want to share a fantastic little tool that I've only recently come across; <a href="http://livejs.com/">Live.js</a>, written by <a href="http://twitter.com/mrtnkl">Martin Kool</a>. 

This JavaScript file <strong>automatically checks for changes</strong> to your CSS and JavaScript files, and refreshes them.

That means you can have your text editor in one half of the screen, and a web browser in the other. When you save changes in the editor, the <strong>updates are reflected immediately in your browser</strong>. It really helps to speed up your development time.]]></description>
								<content:encoded><![CDATA[<p><img src="/wp-content/uploads/2012/05/livejs-wp.jpg" alt="Live.js and WordPress" title="Live.js and WordPress" width="629" height="180" class="alignnone size-full wp-image-8795" srcset="https://www.problogdesign.com/wp-content/uploads/2012/05/livejs-wp.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/05/livejs-wp-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></p>
<p>I want to share a fantastic little tool that I&#8217;ve only recently come across; <a href="http://livejs.com/">Live.js</a>, written by <a href="http://twitter.com/mrtnkl">Martin Kool</a>. </p>
<p>This JavaScript file <strong>automatically checks for changes</strong> to your CSS and JavaScript files, and refreshes them.</p>
<p>That means you can have your text editor in one half of the screen, and a web browser in the other. When you save changes in the editor, the <strong>updates are reflected immediately in your browser</strong>. It really helps to speed up your development time.</p>
<p>A lot of text editors offer HTML previews and such, but they only work for plain .html pages. The great thing about Live.js is that it works <strong>on any webpage</strong>, including a working WordPress theme.</p>
<h2>Live.js for WordPress Plugin</h2>
<p>I have put together a (very!) simple plugin for WordPress to make things that little bit easier. You can <a href="https://github.com/michael-martin/PBD-Live.js-for-WordPress/zipball/master">download it here</a> (<strong>Rename the folder</strong> to &#8220;pbd-livejs&#8221; once you unzip it), or view it on <a href="https://github.com/michael-martin/PBD-Live.js-for-WordPress">Github</a>.</p>
<p>It automatically <strong>adds Live.js</strong> to your theme, but only when you are <strong>logged in and working locally</strong>. You should never use this script on a live site, and the plugin ensures you won&#8217;t.</p>
<p>It also keeps the script out of your theme code, which is good because it&#8217;s purely for development. There is no need for it to be present in the files on your server.</p>
<p>One final note is that although Live.js also supports sensing HTML changes, I have disabled this. With it enabled, your webpage essentially &#8220;flashes&#8221; as it loads every second or two.</p>
<p>Let me know if you try it out, or if you&#8217;ve used Live.js before already!</p>
]]></content:encoded>
							<wfw:commentRss>https://www.problogdesign.com/tools/css-js-auto-refreshing-with-live-js/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
							</item>
		<item>
		<title>WordPress Development: Bypassing the Settings API</title>
		<link>https://www.problogdesign.com/wordpress/wordpress-development-bypassing-the-settings-api/</link>
				<comments>https://www.problogdesign.com/wordpress/wordpress-development-bypassing-the-settings-api/#comments</comments>
				<pubDate>Mon, 23 Apr 2012 16:00:58 +0000</pubDate>
		<dc:creator><![CDATA[Andy Walpole]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Settings]]></category>

		<guid isPermaLink="false">http://www.problogdesign.com/?p=8751</guid>
				<description><![CDATA[<img src="/wp-content/uploads/2012/04/bypassing-settings-api.png" alt="Bypass the Settings API" title="Bypass the Settings API" width="629" height="180" class="alignnone size-full wp-image-8773" />

<em>The following is a guest post by <a href="http://andywalpole.me/">Andy Walpole</a>.</em><a href="https://gist.github.com/1996412"></a>

There are many parts of the Wordpress API which are fantastic but there are also other parts which, I would argue, are lacking.

The Settings API was introduced in version 2.7 to allow the semi-automation of form creation. All credible Content Management Systems and frameworks have their own set of functions or classes for the same purpose. Drupal has a <a href="http://api.drupal.org/api/drupal/includes!form.inc/group/form_api/7">multitude of hooks which can be leveraged</a>, while CodeIgniter uses a combination of the <a href="http://codeigniter.com/user_guide/libraries/form_validation.html">Form Validation Class</a> and the Form Helper .

When creating a Wordpress plugin recently I wanted to create a dynamic form to insert data into a field in the option database table. I decided to create a class for this purpose with the intention of creating reusable code for future projects.]]></description>
								<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-8773" title="Bypass the Settings API" src="/wp-content/uploads/2012/04/bypassing-settings-api.png" alt="Bypass the Settings API" width="629" height="180" srcset="https://www.problogdesign.com/wp-content/uploads/2012/04/bypassing-settings-api.png 629w, https://www.problogdesign.com/wp-content/uploads/2012/04/bypassing-settings-api-300x85.png 300w" sizes="(max-width: 629px) 100vw, 629px" /></p>
<p><em>The following is a guest post by <a href="http://andywalpole.me/">Andy Walpole</a>.</em></p>
<p>There are many parts of the WordPress API which are fantastic but there are also other parts which, I would argue, are lacking.</p>
<p>The Settings API was introduced in version 2.7 to allow the semi-automation of form creation. All credible Content Management Systems and frameworks have their own set of functions or classes for the same purpose. Drupal has a <a href="http://api.drupal.org/api/drupal/includes!form.inc/group/form_api/7">multitude of hooks which can be leveraged</a>, while CodeIgniter uses a combination of the <a href="http://codeigniter.com/user_guide/libraries/form_validation.html">Form Validation Class</a> and the Form Helper .</p>
<p>When creating a WordPress plugin recently I wanted to create a dynamic form to insert data into a field in the option database table. I decided to create a class for this purpose with the intention of creating reusable code for future projects. For ideas, I closely followed previous tutorials written by <a href="http://alisothegeek.com/2011/01/wordpress-settings-api-tutorial-1/">Alison Kleinschmidt</a> and <a href="http://wp.tutsplus.com/tutorials/using-the-settings-api-part-1-create-a-theme-options-page/">Sarah Neuber </a>.</p>
<p>I quickly ran into a brickwall. My main issue that I have with the Settings API is that it’s unintuitive and too basic. It is such an abstraction away from the meat and bones of PHP / HTML form creation and validation that it confuses the professional coder rather than assists them.</p>
<p>As a coding exercise I decided to take a different approach to WordPress form creation using OOP and one that had a more familiar user interface. The code I have written so far can be examined on a <a href="https://gist.github.com/1996412">Git Gist that I have created</a>. There are some excellent features of the Settings API, such as inserting new form fields into existing core admin pages; and this code doesn&#8217;t attempt to replicate that.</p>
<p>This purpose of this article is to provide some feedback on the successes and difficulties of my endeavourer.</p>
<p>There are some key aspects in understanding the option API access class. Firstly, I placed it into three files reflecting an MVC architecture. Admittedly, the script itself doesn&#8217;t tightly fit this segregation but it is a commonly used and understood way of organising code. In the view file there are key WordPress hooks such as add_action() and add_options_page(); in the controller class are the purpose built form field creation methods and in the model class are validation, sanitisation, security and database functions.</p>
<p>Another aspect is that I have used namespaces and late static bindings that arrived with PHP 5.3. It is a convention amongst WordPress developers to cater for servers that have versions of PHP lower than 5.3. I don&#8217;t follow that convention. If your hosting company is running versions of PHP which are three years behind or more then take you custom elsewhere because they are not providing to you a satisfactory service.</p>
<h2>Completed Code</h2>
<p>This is a lengthy tutorial, and walks you through exactly how the script works. Instead of manually copying and pasting all of the code chunks to assemble the file though, it will be simpler just to copy the <a href="https://gist.github.com/1996412">finished code</a> from here.</p>
<h2>1 &#8211; Instantiate the Class</h2>
<pre lang="php">

$aForm = array(
    'option_name' => 'a_url_here', // has to be alphanumeric and underscores only
    'page_title' => 'A page title here', // Main page title
    'page_url' => 'a-url-here', // URL
    'dynamic_output' => FALSE); // Should the form be generated on more input

new \OptionView\Form_View($aForm);

</pre>
<p>The above should be reasonably self-explanatory. In the $aform array are placed four different key values: the name of the option database field, the page title, the page URL and a boolean value &#8211; I&#8217;ll explain this in detail later but for now it&#8217;s set to false.</p>
<p>The create_html_cov() method is called by WordPress add_options_hook(). In here is the code that envelopes the form:</p>
<pre lang="php">

extract(self::$form);

$form = '<div class="wrap">';
$form .= screen_icon();
$form .= "<h2>{$page_title}</h2>";
$form .= '<div id="result">';
echo $form;

if (isset($_POST['submit'])) {

    $error = array();

    // validation here

    if (empty($error)) {

        $this->update_option($form);

    } else {

        echo $this->failure_message($error);

    } // end if error

} // end if isset submit

echo '</div>';
echo '</div>';
</pre>
<p>Anybody who codes PHP will be familiar with the above. After form submission any error messages are added to an array and then displayed. At the top is a div with a class of wrap. This is essential so that the admin CSS is used. Note as well that the page title originally made in the $aForm array is now been called from the static $form attribute. How? The values were used in the method below which in turn was called in the view constructor. The values within config_settings() are used throughout the script.</p>
<pre lang="php">
/**
 * Form_Controller::config_settings()
 * Main array for important values throughout the class
 * @param string $option_name
 * @param string $page_title
 * @param string $page_url
 * @param boolean $dynamic_output
 * @return array
 */

protected function config_settings($option_name, $page_title, $page_url, $dynamic_output = FALSE) {

    // put together the output array
    $output['option_name'] = $option_name; // name of option database field
    $output['page_title'] = $page_title; // name of page
    $output['page_url'] = $page_url; // url of page
    $output['dynamic_output'] = $dynamic_output;
    return $output;

}</pre>
<h2>2 &#8211; Creating the Form Fields</h2>
<p>It is first necessary to create a form array:</p>
<pre lang="php">
$form = array(
    'method' => 'post',
    'action' => '#result',
    'enctype' => FALSE,
    'description' => 'Add a description here');
</pre>
<p>The description will go inbetween the legend form tags at the top of the form. The rest are basic attribute form values.</p>
<p>When invoking the create_form() method the form array has to be the first value:</p>
<pre lang="php">$this->create_form($form);</pre>
<p>From here more arrays have to be created for individual form fields. Note how closely the PHP fits the HTML form attributes – something that the user interface of the Settings API is distant from.</p>
<pre lang="php">

$textOne = array(
    "input" => "text", // input type
    "name" => "textOne", // name attribute
    "desc" => "This is a text field", // for use in input label
    "maxlength" => "200", // max attribute
    "value" => "YES", // value attribute
    "select" => FALSE // array only for the select input
        );

$textTwo = array(
    "input" => "text",
    "name" => "textTwo",
    "desc" => "This is another text field:",
    "maxlength" => "250",
    "value" => "YES",
    "select" => FALSE);

</pre>
<p>The input can be text, textfield, radio, select or checkbox. The desc key is used in the form field label. Values for text or textfields should be “YES” only and by doing so instructs the class to create a sticky form field. Select is only used for drop-down fields, radio buttons and checkboxes (more of which later). Even if an option is not used there stills needs to be “false” or “null” stated.</p>
<p>Now the two arrays are placed in create_form():</p>
<pre lang="php">$this->create_form($form, $textOne, $textTwo);</pre>
<p>The form has now been created.</p>
<p><a href="/wp-content/uploads/2012/04/screenshot-one1.jpg"><img class="alignnone size-full wp-image-8753" title="screenshot-one" src="/wp-content/uploads/2012/04/screenshot-one1.jpg" alt="" width="683" height="648" srcset="https://www.problogdesign.com/wp-content/uploads/2012/04/screenshot-one1.jpg 683w, https://www.problogdesign.com/wp-content/uploads/2012/04/screenshot-one1-300x284.jpg 300w" sizes="(max-width: 683px) 100vw, 683px" /></a></p>
<h2>3 &#8211; Validation and Sanitisation</h2>
<p>The following method is used for sanitizing data. If, for instance, it is desirable to remove backslashes or trim white space from the ends of strings, then it is possible to do so like this:</p>
<pre lang="php">

$this->sanitize($form, 'trim_post');

$this->sanitize($form, 'stripslashes');

</pre>
<p>That&#8217;s straight forward enough. Lets take a look at the code behind this in the model class:</p>
<pre lang="php">

/**
 * Form_Model::sanitize()
 * 
 * @param string $handle
 * @param array $form_output
 * @return array
 */
protected function sanitize(&$form_output, $handle) {

    switch ($handle) {

        case 'sanitize_post':
            array_walk_recursive($form_output, array($this, 'sanitize_post'));
            break;
        case 'trim_post':
            array_walk_recursive($form_output, array($this, 'trim_post'));
            break;
        case 'strip_tags_post':
            array_walk_recursive($form_output, array($this, 'strip_tags_post'));
            break;
        case 'empty_value':
            array_walk_recursive($form_output, array($this, 'empty_value'));
            break;
        case 'stripslashes':
            array_walk_recursive($form_output, array($this, 'stripslashes'));
            break;
        default:
            die("The value you ended into the sanitize() method is not recognised: $handle");
            break;

    } // end switch

}


/**
 * Form_Model::trim_post()
 * 
 * @param string $att
 * @param string $single
 * @param array $form_output
 * @return array
 */

function trim_post(&$form_output, $att = NULL, $single = NULL) {

    if ($single == NULL) {

        if (is_array($form_output)) {
            array_walk_recursive($form_output, 'trim');
        } else {
            $form_output = trim($form_output);
        }

    } else {

        extract(static::$form);

        foreach ($form_output[$option_name] as $thisKey => $result) {

            if (preg_match("/$att/i", $thisKey)) {

                if (is_string($thisKey)) {
                    $form_output[$option_name][$thisKey] = trim($result);
                }

            }

        }

        return $form_output;
    }

}

</pre>
<p>As demonstrated by the trim_post() method it is easy to widen the sanitisation features of the code. Just copy and paste the method, change the name and change trim to another function such as strip_tags() or htmlspecialchars(). Then add a new section to the switch statement in sanitize().</p>
<p>Notice that $this-&gt;sanitize($form, &#8216;trim_post&#8217;) trims all input data. It is possible to just sanitise one field by bypassing sanitize() and call its child method directly:</p>
<pre lang="php">

$this->strip_tags_post($form, 'feedName', true);
$this->trim_post($form, 'feedName', true);
$this->stripslashes($form, 'feedName', true);

</pre>
<p>Necessary parameters above are the form array, the name of the attribute and a boolean value of true.</p>
<p>Validation is similar to sanitization. Here are two examples of using validation methods:</p>
<pre lang="php">

/**
 * Form_Model::validate_email()
 * 
 * @param string $att
 * @return boolean
 */

protected function validate_email($form_output, $att) {

    extract(static::$form);

    if (is_array($form_output) && is_string($att)) {

        foreach ($form_output[$option_name] as $thisKey => $result) {

            if (preg_match("/$att/i", $thisKey)) {

                if ($result !== "") {

                    if (!filter_var($result, FILTER_VALIDATE_EMAIL)) {
                        return false;
                    }

                } // end if

            } // end if

        } // end foreach

    } else {
        die("Make sure that the inputs for validate_url() is an array and a string");
    }


}

</pre>
<p>To extend the different types of validation it is, like sanitization, a straightforward process of copying the code, renaming it and changing the filter_var().</p>
<p>One other useful validation method is duplicate_entries():</p>
<pre lang="php">

if ($this->duplicate_entries($form) == false) {
    $error[] = "Please make sure that all input values are unique";
}

</pre>
<p>This will ensure that no one inputted value is identical.</p>
<h2>4 &#8211; Select Drop-Down Lists, Radio Buttons &amp; Checkboxes.</h2>
<p>The creating and validating of these form fields is slightly different.</p>
<p>Firstly, when you create radio buttons or checkboxes you must do so by specifying the total number of each in the select value of the field creation array:</p>
<pre lang="php">

$aRadioButton = array(
    "input" => "radio",
    "name" => "radioButtonName",
    "desc" => "A radio button",
    "maxlength" => FALSE,
    "value" => "mac",
    "select" => 3);

$aCheckBox = array(
    "input" => "radio",
    "name" => "aCheckBoxName",
    "desc" => "First checkbox",
    "maxlength" => FALSE,
    "value" => "mushrooms",
    "select" => 3);

</pre>
<p>The above would specify that there are three checkboxes in the form and three radio buttons (obviously, it is necessary to create separate arrays for all individual fields).</p>
<p>As is standard in HTML, the radio buttons must have the same name attribute. In this script checkboxes must have individual name attributes. I&#8217;m working on a solution to creating checkboxes with the same name attributes! Notice as well that, unlike for text or textareas, the value is no longer “YES” but a value unique to all fields.</p>
<p>Previously, checking for empty submitted values was done so through the empty_value() method</p>
<pre lang="php">

// Check whether there are any empty form values:
if ($this->empty_value($form) === FALSE) {
    $error[] = "Please don't leave any input values empty";
}

</pre>
<p>Radio buttons and checkboxes have their own methods:</p>
<pre lang="php">

if ($this->empty_checkboxes($form, 2) === FALSE) {
    $error[] = "Please check at least two checkboxes";
}

if ($this->empty_radio_butts($form) === FALSE) {
    $error[] = "Please make sure that you check one of the radio buttons";
}

</pre>
<p>In empty_checkboxes() the second digit is the minimum number of checkboxes that the user needs to click. If none is specified then the default is one.</p>
<p>When creating a drop-down list it is necessary to add any array of values to the select key:</p>
<pre lang="php">

$cities = array(
    'Shanghai',
    'Karachi',
    'Mumbai',
    'Beijing',
    'Moscow',
    'Sao Paulo',
    'Tianjin',
    'Guangzhou',
    'Delhi',
    'Seoul',
    'Shenzhen',
    'Jakarta',
    'Tokyo',
    'Mexico City',
    'Istanbul');

$select = array(
    "input" => "select",
    "name" => "selectName",
    "desc" => "Select here select here",
    "maxlength" => FALSE,
    "value" => TRUE,
    "select" => $cities);

</pre>
<p>Putting together the above examples, the code for a form with multiple different types of input would look like this:</p>
<pre lang="php">

function create_html_cov() {

    // essential.
    extract(self::$form);

    $form = '<div class="wrap">';
    $form .= screen_icon();
    $form .= "<h2>{$page_title}</h2>";
    $form .= '<p>This is the admin section for Affiliate Hoover plugin</p>';
    $form .= '<div id="result">';
    echo $form;

    if (isset($_POST['submit'])) {

        $error = array();

        // ESSENTIAL! Do not leave this out. Needs to come first
        $form = $this->security_check($_POST);

        // Sanitization

        $this->sanitize($form, 'trim_post');

        $this->sanitize($form, 'stripslashes');

        // Validation

        if ($this->validate_email($form, 'feedName') === FALSE) {
            $error[] = "Please make sure that the email addresses are correct";
        }

        if ($this->validate_url($form, 'urlName') === FALSE) {
            $error[] = "URL is not right";
        }

        // Check whether there are any empty form values for text or textarea fields:
        if ($this->empty_value($form) === FALSE) {
            $error[] = "Please don't leave any input values empty";
        }

        // don't allow empty checkboxes
        if ($this->empty_checkboxes($form, 2) === FALSE) {
            $error[] = "Please check at least two checkboxes";
        }

        // don't allow empty radio buttons
        if ($this->empty_radio_butts($form) === FALSE) {
            $error[] = "Please make sure that you check one of the radio buttons";
        }

        // Make sure that none of the form values are duplicates
        if ($this->duplicate_entries($form) === FALSE) {
            $error[] = "Please make sure that all input values are unique";
        }

        if (empty($error)) {

            $this->update_option($form);

        } else {

            echo $this->failure_message($error);
        } // end if error

    } // end if isset submitForm

    echo '</div>';

    // Create the form here:

    $aTextField = array(
        "input" => "text", // input type
        "name" => "textOne", // name attribute
        "desc" => "This is a text field", // for use in input label
        "maxlength" => "200", // max attribute
        "value" => "YES", // value attribute
        "select" => FALSE // array only for the select input
            );

    $aTextArea = array(
        "input" => "textarea",
        "name" => "aTextArea",
        "desc" => "This is a textarea:",
        "maxlength" => FALSE,
        "value" => "YES",
        "select" => FALSE);

    $aRadioButtonOne = array(
        "input" => "radio",
        "name" => "radioButtonName",
        "desc" => "A radio button one",
        "maxlength" => FALSE,
        "value" => "mac",
        "select" => 3);

    $aRadioButtonTwo = array(
        "input" => "radio",
        "name" => "radioButtonName",
        "desc" => "A radio button two",
        "maxlength" => FALSE,
        "value" => "linux",
        "select" => 3);

    $aRadioButtonThree = array(
        "input" => "radio",
        "name" => "radioButtonName",
        "desc" => "A radio button three",
        "maxlength" => FALSE,
        "value" => "pc",
        "select" => 3);

    $aCheckBoxOne = array(
        "input" => "checkbox",
        "name" => "aCheckBoxOne",
        "desc" => "A radio button one",
        "maxlength" => FALSE,
        "value" => "mushrooms",
        "select" => 3);

    $aCheckBoxTwo = array(
        "input" => "checkbox",
        "name" => "aCheckBoxTwo",
        "desc" => "First checkbox",
        "maxlength" => FALSE,
        "value" => "pizza",
        "select" => 3);

    $aCheckBoxThree = array(
        "input" => "checkbox",
        "name" => "aCheckBoxThree",
        "desc" => "First checkbox",
        "maxlength" => FALSE,
        "value" => "chicken",
        "select" => 3);

    $form = array(
        'method' => 'post',
        'action' => '#result',
        'enctype' => 'multipart/form-data',
        'description' => 'Add a new form underneath');
    $this->create_form($form, $aTextField, $aTextArea, $aRadioButtonOne, $aRadioButtonTwo, $aRadioButtonThree,
        $aCheckBoxOne, $aCheckBoxTwo, $aCheckBoxThree);

    echo '</div><!-- end of wrap div -->';

}

</pre>
<p>The above will create a form that looks like this:</p>
<p><a href="/wp-content/uploads/2012/04/screenshot-two.jpg"><img class="alignnone size-full wp-image-8754" title="screenshot-two" src="/wp-content/uploads/2012/04/screenshot-two.jpg" alt="screenshot two" width="684" height="637" srcset="https://www.problogdesign.com/wp-content/uploads/2012/04/screenshot-two.jpg 684w, https://www.problogdesign.com/wp-content/uploads/2012/04/screenshot-two-300x279.jpg 300w, https://www.problogdesign.com/wp-content/uploads/2012/04/screenshot-two-82x76.jpg 82w" sizes="(max-width: 684px) 100vw, 684px" /></a></p>
<h2>5 &#8211; Dynamic Forms</h2>
<p>Creating a form layout that enables the easy adding, deleting or editing of multiple form blocks with one submit button is almost impossible with PHP alone. The best solution would be AJAX but this is primarily intended as a server-side coding exercise.</p>
<p>To create a dynamic form with my Option API access class then the only value to change is the dynamic output booleanwhen instantiating the class.</p>
<p>It is now possible to create a form with different sections that can be independently deleted or edited.</p>
<p>An example being:</p>
<p><a href="/wp-content/uploads/2012/04/screenshot-three.jpg"><img class="alignnone size-full wp-image-8755" title="screenshot-three" src="/wp-content/uploads/2012/04/screenshot-three.jpg" alt="screenshot three" width="683" height="684" srcset="https://www.problogdesign.com/wp-content/uploads/2012/04/screenshot-three.jpg 683w, https://www.problogdesign.com/wp-content/uploads/2012/04/screenshot-three-150x150.jpg 150w, https://www.problogdesign.com/wp-content/uploads/2012/04/screenshot-three-300x300.jpg 300w" sizes="(max-width: 683px) 100vw, 683px" /></a></p>
<h2>Conclusion</h2>
<p>The code I linked to in the Git Gist is still in its development stage. There are a number of issues. Firstly, it is not possible to create checkboxes with the same name attribute – they have to be separate. Secondly, it is only possible to create one set of radio buttons per form section.</p>
<p>Attempting to create a dynamic form like I have done so in this Option API access class create an entire new level of code complexity. Because a server-side script like PHP has only limited use of the DOM, it is necessary to find solutions based on loops of the form arrays and a lot of maths. This is an aspect of the code that I will continue working on.</p>
<p>But, positive parts of the Option API access class are that it takes care of all tables HTML and CSS peculiar to the WordPress admin section; it is relatively easy to create and validate new forms with a multitude of fields, and all security aspects of the WordPress backend like wp_verify_nonce() are incorporated into the form submission process.</p>
]]></content:encoded>
							<wfw:commentRss>https://www.problogdesign.com/wordpress/wordpress-development-bypassing-the-settings-api/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
							</item>
		<item>
		<title>How to Install and Customize Varnish for WordPress</title>
		<link>https://www.problogdesign.com/wordpress/how-to-install-and-customize-varnish-for-wordpress/</link>
				<comments>https://www.problogdesign.com/wordpress/how-to-install-and-customize-varnish-for-wordpress/#comments</comments>
				<pubDate>Thu, 12 Apr 2012 16:00:13 +0000</pubDate>
		<dc:creator><![CDATA[Austin Gunter]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[Varnish]]></category>

		<guid isPermaLink="false">http://www.problogdesign.com/?p=8726</guid>
				<description><![CDATA[<img src="/wp-content/uploads/2012/04/varnish.png" alt="Varnish and WordPress" title="Varnish and WordPress" width="629" height="180" class="alignnone size-full wp-image-8737" />

<em>The following is a guest post by Austin Gunter of <a href="http://wpengine.com/">WPEngine.com</a>.</em>

If you’re looking to boost performance for a content-heavy WordPress installation, adding a cache like <a href="https://www.varnish-cache.org/">Varnish</a> is a great way to boost your site’s performance.

NB - This is an advanced topic, and only relevant if <strong>you have full control over your server</strong> (e.g. you're on a VPS). It does not apply to regular webhosting.]]></description>
								<content:encoded><![CDATA[<p><img src="/wp-content/uploads/2012/04/varnish.png" alt="Varnish and WordPress" title="Varnish and WordPress" width="629" height="180" class="alignnone size-full wp-image-8737" srcset="https://www.problogdesign.com/wp-content/uploads/2012/04/varnish.png 629w, https://www.problogdesign.com/wp-content/uploads/2012/04/varnish-300x85.png 300w" sizes="(max-width: 629px) 100vw, 629px" /></p>
<p><em>The following is a guest post by Austin Gunter of <a href="http://wpengine.com/">WPEngine.com</a>.</em></p>
<p>If you’re looking to boost performance for a content-heavy WordPress installation, adding a cache like <a href="https://www.varnish-cache.org/">Varnish</a> is a great way to boost your site’s performance.</p>
<p>NB &#8211; This is an advanced topic, and only relevant if <strong>you have full control over your server</strong> (e.g. you&#8217;re on a VPS). It does not apply to regular webhosting.</p>
<h2>What is Varnish?</h2>
<p>Varnish Cache is a <strong>web app accelerator</strong>, or a caching HTTP <a href="http://en.wikipedia.org/wiki/Reverse_proxy">reverse proxy</a>. Install it in front of any server that speaks HTTP and configure it to cache the contents, and the Varnish community claims that it speeds up delivery by a factor of 300 &#8211; 1000x.<strong> </strong></p>
<p>In a nutshell, caching a webpage means storing a copy of that website’s content for future visitors to see. Varnish can cache pages of your WordPress site so that your server <strong>doesn’t need to call the database</strong> each time a visitor visits your site. This reduces server load because the stored copy means the webserver doesn’t have to go find the same images and content for each visitor.</p>
<p>Varnish caches page data in virtual memory, so your site will load much faster, providing a killer SEO boost. Google found that every additional <strong>0.5s load time meant 20% fewer site visitors</strong> (<a href="http://news.cnet.com/8301-10784_3-9954972-7.html">Source</a>). Reducing the page load time can dramatically increase your visitors and boost your search rankings at the same time.</p>
<p>Varnish themselves have put together a great video for explaining what it does, as simply as possible:</p>
<p><iframe src="http://www.youtube.com/embed/x7t2Sp174eI" frameborder="0" width="560" height="315"></iframe></p>
<h2>Installing Varnish</h2>
<p>Varnish is free software that you can install this afternoon. It runs on Linux, and primarily FreeBSD, but can work on other platforms as well. Once installed, you can customize <strong>how incoming requests will be handled</strong> with the Varnish Configuration Language (VCL).</p>
<p>This flexibility means that each Varnish install can and should be designed with a <strong>particular site in mind</strong>.</p>
<p>You’ll want to begin with a basic configuration of Varnish, <strong>and then begin testing small changes</strong> as you get the hang of how it works with your particular site, and how the functions work. There are several different subroutines that tell Varnish how to respond to requests going in and out, to errors, and so on.</p>
<p>I’ll start with a basic set up, and then cover basic VCL functions that you’ll be tweaking as you go.</p>
<h2>Step by Step</h2>
<p>Setting up Varnish is pretty simple. I’m going to assume you’re using Apache on a Debian-based system. It does work <strong>on other systems too</strong> though.</p>
<p>Start in the command line with this:</p>
<pre lang="bash">apt-get install varnish</pre>
<p>First, you want to configure Apache to listen on port 8080 of the localhost interface. Varnish can then listen on port 80 (Where your visitors connect). In /etc/apache2/ports.conf, edit the following settings:</p>
<pre lang="bash">NameVirtualHost 127.0.0.1:8080
Listen 127.0.0.1:8080</pre>
<p>To get Varnish to start (it won’t by default), edit the following in /etc/default/varnish</p>
<pre lang="bash">START=yes
DAEMON_OPTS=”-a EXTERNAL_IP_ADDRESS:80 \
	-T localhost:6082 \
	-f /etc/varnish/default.vcl \
	-S /etc/varnish/secret \
	-s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G”</pre>
<p>Replace EXTERNAL_IP_ADDRESS with the IP of your external IP address. It can also be an internal address if your server is setup behind a load balancer, or something like NGINX. This setting controls what IP address and port you want Varnish to bind to and listen on.</p>
<p>Now edit /etc/varnish/default.vcl, which should already exist with lots of it commented out. Start by changing the default backend.</p>
<pre lang="bash">backend default {
	.host = “127.0.0.1”;</p>
	.port = “8080”;</p>
}</pre>
<p>Now Varnish knows that Apache is listening on port 8080 of the localhost interface, and you can start using the functions. The majority of the work will be <strong>with vcl_recv and vcl_fetch</strong>, and if you don’t call an action in this subroutine and Varnish reaches the end, it will execute the built-in code from <em>default.vcl.</p>
<p>Note: you <em>never</em> want to cache wp_admin, wp_login, or similar pages.</p>
<p>Here’s how it works &#8211; the 4 basic subroutines in your Varnish config which you need to handle requests are:</p>
<pre lang="bash">sub vcl_recv</pre>
<p>This is called at the beginning of a request and tells varnish what to do with that particular request: whether or not to serve it, how to serve it, and which backend to use. </p>
<p>Varnish receives a request from your browser, <em>vcl_recv</em> and chooses to do one of 3 things with it: <em>vcl_hash, vcl_pass, and vcl_pipe</em> (More details on those in a minute!). You can change the request if you like, altering cookies or removing the request header.</p>
<pre lang="bash">sub vcl_fetch</pre>
<p>vcl_fetch is called after a document has been successfully retrieved from the backend. Use this to alter the response headers, trigger ESI processing, or try alternate backend servers if the request failed.</p>
<p>The request object, <em>req</em>, is still available, and there is also a backend response, <em>beresp</em>, which contains the HTTP headers from the backend.</p>
<pre lang="bash">sub vcl_hash</pre>
<p>You can call hash_data on the data you want to add to the hash. This subroutine may terminate with calling return() with one of the keywords, <em>hash</em> or <em>proceed</em>.</p>
<pre lang="bash">sub vcl_deliver</pre>
<p>Call this before a cached object is delivered to the client. This may terminate with <em>deliver, error code, or restart.</em> Deliver, delivers the object to the client. Error will return the specified error code to the client and abandon the request. Restart will restart the transaction and increase the restart counter. If the number of restarts exceed the <em>max_restarts</em>, varnish emits a guru meditation error.</p>
<h2>Actions</h2>
<p>There are a number of actions you can take inside each subroutine as you customize Varnish:</p>
<p style="padding-left: 30px;"><em>pass</em></p>
<p style="padding-left: 60px;">Pass the request and subsequent response to and from the backend server, not cached. pass can be called in both <em>vcl_recv</em> and <em>vcl_fetch.</em></p>
<p style="padding-left: 30px;"><em>lookup</em></p>
<p style="padding-left: 60px;">Called from vcl_recv to deliver content from cache even if the request indicates that the request should be passed. You can’t call lookup from <em>vcl_fetch.</em></p>
<p style="padding-left: 30px;"><em>pipe</em></p>
<p style="padding-left: 60px;"><em></em>From <em>vcl_recv</em>, pipe short-circuits client and backend connections and Varnish will just sits there passing the data back and forth, logging the data, so logs will be incomplete. Beware that with HTTP 1.1 a client can send several requests on the same connection and so you should instruct Varnish to add a “Connection: close” header before actually calling pipe.</p>
<p style="padding-left: 30px;"><em>deliver</em></p>
<p style="padding-left: 60px;"><em></em>Deliver the cached object to the client. Usually called in vcl_fetch.</p>
<p style="padding-left: 30px;"><em>esi</em></p>
<p style="padding-left: 60px;"><em></em>ESI-process the fetched document.</p>
<p>The Varnish community has a very <a href="https://www.varnish-cache.org/docs/2.1/tutorial/index.html">detailed tutorial on using VCL</a>, and the functions that you can perform on your site, which I won’t go into here. </p>
<h2>Example Configurations</h2>
<p>Hopefully this post has given you a good introduction to Varnish, but the best way to truly start playing with it is to see some sample configuration files.</p>
<p>The Varnish website has a great collection <a href="https://www.varnish-cache.org/trac/wiki/VCLExamples">sample configurations</a>, which can make a perfect starting point for building your own.</p>
<p>More specifically, Mattias Geniar has put up sample <a href="https://github.com/mattiasgeniar/varnish-3.0-configuration-templates/blob/master/conf.d/fetch/wordpress.vcl">fetch</a> and <a href="https://github.com/mattiasgeniar/varnish-3.0-configuration-templates/blob/master/conf.d/receive/wordpress.vcl">receive</a> configs for WordPress on Github.</p>
<p>Suffice to say that Varnish is very customizable and can do wonders for WordPress. A great example would be a Membership site. You can customize Varnish to <strong>cache content based on a user’s permissions</strong>, on their membership level, or even if they’re just visiting your site. </p>
<p>Facebook uses Varnish to great avail, and no doubt they have customized it to hell and back, but it goes to show you how efficient and flexible Varnish is.</p>
<h2>Plugins</h2>
<p><strong>Update (13 Apr 2012):</strong> Thanks to <a href="http://blog.tenya.me/">Alexander</a> and <a href="http://tinywp.in/">Pothi</a> for letting us know about an <a href="https://github.com/pkhamre/wp-varnish">updated Varnish plugin</a> for WP 3.0+ and one on WP.org also for <a href="http://wordpress.org/extend/plugins/varnish-http-purge/">purging your cache</a> (Also, check out both of these guy&#8217;s blogs for more Varnish and WP performance tips!)</p>
<p>The <a href="http://wordpress.org/extend/plugins/wordpress-varnish/">varnish plugin</a> will purge the cache when content is added or edited, and it works for multisite. The plugin does include a sample config file for your Varnish backend, however, keep in mind that when you’ve customized it for one particular site, those customizations may or may not play nicely with a different site.</p>
<p>Have you had any luck installing Varnish for your WordPress? What works and doesn&#8217;t? Feel free to share some of your ideas in the comments!</p>
<p><strong>Update (24 Jul 2012):</strong> Jason Ormand has put together a cool Bash script to make configuring an <a href="http://jasonormand.com/2012/07/20/introducing-lempress-super-easy-wordpress-server-setup/">NGINX server with Varnish</a> and WordPress even faster.</p>
]]></content:encoded>
							<wfw:commentRss>https://www.problogdesign.com/wordpress/how-to-install-and-customize-varnish-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
							</item>
		<item>
		<title>6 Ways to Power Up WordPress Comments</title>
		<link>https://www.problogdesign.com/wordpress/6-ways-to-power-up-wordpress-comments/</link>
				<comments>https://www.problogdesign.com/wordpress/6-ways-to-power-up-wordpress-comments/#comments</comments>
				<pubDate>Wed, 28 Mar 2012 16:00:49 +0000</pubDate>
		<dc:creator><![CDATA[Michael Martin]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Comments]]></category>
		<category><![CDATA[Disqus]]></category>
		<category><![CDATA[Jetpack]]></category>
		<category><![CDATA[Livefyre]]></category>
		<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://www.problogdesign.com/?p=8709</guid>
				<description><![CDATA[<img class="alignnone size-full wp-image-8721" title="Extend WordPress Comments" src="/wp-content/uploads/2012/03/comments.jpg" alt="Extend WordPress Comments" width="629" height="180" />

It's a relatively simple process to add some flair to your blog comments these days. I want to look at 6 of the best free tools and give you a quick overview of the benefits of each.

Let's start with one you've likely heard of before...]]></description>
								<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-8721" title="Extend WordPress Comments" src="/wp-content/uploads/2012/03/comments.jpg" alt="Extend WordPress Comments" width="629" height="180" srcset="https://www.problogdesign.com/wp-content/uploads/2012/03/comments.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/03/comments-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></p>
<p>It&#8217;s a relatively simple process to add some flair to your blog comments these days. I want to look at 6 of the best free tools and give you a quick overview of the benefits of each.</p>
<p>Let&#8217;s start with one you&#8217;ve likely heard of before&#8230;</p>
<h2>Disqus</h2>
<p><a href="http://disqus.com/"><img class="alignnone size-full wp-image-8711" title="Disqus" src="/wp-content/uploads/2012/03/disqus.jpg" alt="Disqus" width="629" height="180" srcset="https://www.problogdesign.com/wp-content/uploads/2012/03/disqus.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/03/disqus-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></a></p>
<p>Disqus uses JavaScript to replace your WordPress comments with their own system. You lose the total design flexibility that vanilla WordPress comments offer, but you gain a large feature set, including:</p>
<ul>
<li><strong>Real-time Comments</strong> &#8211; New comments appear on the page without needing to refresh. Not a major benefit for smaller sites, but very good if your posts tend to get a flurry of comments in the first few hours of publishing.</li>
<li><strong>Social Media Integration</strong> &#8211; Users can comment via Facebook or Twitter, and share to those sites as well if they choose.</li>
<li><strong>Global Profiles</strong> &#8211; A user&#8217;s Disqus profile shows their comments across all Disqus sites. The idea is that a Disqus user will be more likely to comment on a Disqus blog because of this, and it makes for a fast way to find out more about a commenter.</li>
<li>Plenty of other features, like inline comment replies or &#8220;<strong>subscribe to updates</strong>.&#8221;</li>
</ul>
<p>Another good thing to bear in mind with Disqus is that they are very active. Disqus has been around for several years now, and it still innovates and updates regularly. They even have a mystery <a href="http://blog.disqus.com/post/19693554817/disqus-labs">Disqus 2012</a> project to be released soon.</p>
<p>And incase you&#8217;re wondering, your comments can all be imported to Disqus, and <strong>exported back to WordPress if you choose</strong> to leave Disqus. You won&#8217;t be hostage to their system.</p>
<p><a href="http://disqus.com/admin/wordpress/">WordPress Install Instructions for Disqus</a></p>
<h2>Livefyre</h2>
<p><a href="http://www.livefyre.com/"><img class="alignnone size-full wp-image-8712" title="Livefyre" src="/wp-content/uploads/2012/03/livefyre.jpg" alt="Livefyre" width="629" height="180" srcset="https://www.problogdesign.com/wp-content/uploads/2012/03/livefyre.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/03/livefyre-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></a></p>
<p>Livefyre is very similar to Disqus, and as far as I can tell, they offer almost exactly the same <a href="http://www.livefyre.com/features/">feature set</a>. <strong>Real-time comments, social media, user profiles, subscription</strong> etc. are all included as standard.</p>
<p>Livefyre is a newer contender in this market though, but personally I think they have an edge over Disqus in 2 ways:</p>
<ul>
<li><strong>Simpler Installation</strong> &#8211; Disqus isn&#8217;t hard to install, but it does have JavaScript issues often enough (For anyone who has ever used it, hands up if your comment counts vanished?). I haven&#8217;t used Livefyre on as many sites yet, but it hasn&#8217;t given me any hassle.</li>
<li><strong>Sleeker Design</strong> &#8211; This is just a matter of taste, but I like the softer design of Livefyre&#8217;s comments more. It&#8217;s not a big difference, but every little helps, and even their website has a better design.</li>
</ul>
<p><a href="http://support.livefyre.com/customer/portal/articles/163187-how-do-i-install-livefyre-on-my-wordpress-blog-">WordPress Install Instructions for Livefyre</a></p>
<h2>IntenseDebate</h2>
<p><a href="http://www.intensedebate.com/"><img class="alignnone size-full wp-image-8713" title="Intense Debate" src="/wp-content/uploads/2012/03/intense-debate.jpg" alt="Intense Debate" width="629" height="180" srcset="https://www.problogdesign.com/wp-content/uploads/2012/03/intense-debate.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/03/intense-debate-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></a></p>
<p>IntenseDebate is similar again to the 2 above (The last tool in this style, I promise!). The reason I mention it is because it has one very big draw for WordPress users; <strong>it&#8217;s owned by Automattic</strong>, the creators of WordPress.</p>
<p>The <a href="http://www.intensedebate.com/features">feature-set</a> is generally quite similar to the others (Though real-time commenting is noticeably absent), and their design is very similar as well.</p>
<p>Whilst there is nothing that I can say is &#8220;wrong&#8221; with IntenseDebate, it&#8217;s hard to recommend them overly either. Their site and script don&#8217;t feel as sleek as Livefyre, and their community no longer seems as vibrant as Disqus&#8217;.</p>
<p>Oh, and the bright green &#8220;180p&#8221; badges look awful&#8230; (Look down the sidebar of <a href="http://blog.intensedebate.com/">their blog</a> to see what I mean).</p>
<p><a href="http://intensedebate.com/install">Begin IntenseDebate Install Process</a></p>
<h2>Facebook Comments</h2>
<p><a href="https://developers.facebook.com/docs/reference/plugins/comments/"><img class="alignnone size-full wp-image-8715" title="Facebook Comments" src="/wp-content/uploads/2012/03/facebook.jpg" alt="Facebook Comments" width="629" height="180" srcset="https://www.problogdesign.com/wp-content/uploads/2012/03/facebook.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/03/facebook-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></a></p>
<p>The Facebook Comments script is exactly what you would expect; it replaces your own comments with a Facebook wall. Users must be signed in to their Facebook accounts, and then what they see is <strong>identical to Facebook.com</strong>.</p>
<p>There are two big advantages to this approach:</p>
<ul>
<li><strong>Publicity</strong> &#8211; Users are commenting with their Facebook profiles, so with a little luck, their friends will see the comment and look at your article as well.</li>
<li><strong>Anti-spam</strong> &#8211; Every commenter must use their Facebook account, so spammers have a much harder time bulk-spamming blogs.</li>
</ul>
<p>The strongest feature is also the strongest drawback. Some people (like me) keep their accounts completely separate to their work or online profiles, and so, you will <strong>miss out on those people&#8217;s contributions</strong>.</p>
<p>There is a <a href="http://wordpress.org/extend/plugins/facebook-comments-for-wordpress/">plugin</a> for adding these comments to WordPress, but it seems to be broken with WordPress 3.3. For a developer though, the installation is similar to any other Facebook script. You can <a href="https://developers.facebook.com/docs/reference/plugins/comments/">get the code here</a>.</p>
<p>(If you have trouble with the install or can&#8217;t find a reliable guide online, <strong>let me know and I&#8217;ll put together a walkthrough</strong>).</p>
<h2>Jetpack</h2>
<p><a href="http://jetpack.me/"><img class="alignnone size-full wp-image-8718" title="Jetpack" src="/wp-content/uploads/2012/03/jetpack.jpg" alt="Jetpack" width="629" height="180" srcset="https://www.problogdesign.com/wp-content/uploads/2012/03/jetpack.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/03/jetpack-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></a></p>
<p>Jetpack is essentially a set of WordPress plugins, which is a topic I&#8217;m about to cover in the final section. What sets Jetpack apart is its ease of use. You install one package, and <strong>cherry pick the features for you want</strong>.</p>
<p>In the case of commenting, that means 3 things:</p>
<ul>
<li><strong>Subscriptions</strong> &#8211; Users can be emailed when follow-up comments are left after their reply. This is a great way to keep conversations going.</li>
<li><strong>Gravatar Hovercards</strong> &#8211; When you mouse over a commenter&#8217;s name, this will pull up a little bubble with their image and a quick bio with a link to their full profile on <a href="http://en.gravatar.com/">Gravatar</a>.</li>
<li><strong>Sharing</strong> &#8211; Jetpack makes it easy to add social media sharing links anywhere on your page, including around the comments area.</li>
</ul>
<div>One tool is then enough to take your existing theme&#8217;s comments, and upgrade them with some of the most popular commenting functions.</div>
<p><a href="http://wordpress.org/extend/plugins/jetpack/installation/">Install Guide for WordPress Jetpack</a></p>
<h2>Other WordPress Plugins</h2>
<p><a href="http://wordpress.org/extend/plugins/tags/comments"><img class="alignnone size-full wp-image-8719" title="WordPress Comment Plugins" src="/wp-content/uploads/2012/03/wordpress-plugins.jpg" alt="WordPress Comment Plugins" width="629" height="180" srcset="https://www.problogdesign.com/wp-content/uploads/2012/03/wordpress-plugins.jpg 629w, https://www.problogdesign.com/wp-content/uploads/2012/03/wordpress-plugins-300x85.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></a></p>
<p>There are hundreds out there, but I want to focus on just 4 of them:</p>
<ul>
<li><a href="http://wordpress.org/extend/plugins/wp-ajax-edit-comments/">AJAX Edit Comments </a>&#8211; This allows users to edit their comments for up to 15 minutes after submitting them. It is a good way to enable users to fix typos, and avoid &#8220;double-posting&#8221; if they want to add another line. It is particularly popular on coding blogs, where awesome commenters might contribute code snippets of their own but find they get messed up when displayed.</li>
<li><a href="http://wordpress.org/extend/plugins/commentluv/">CommentLuv</a> &#8211; CommentLuv gets the latest blog post from a commenter&#8217;s RSS feed, and automatically adds a link to it after their comment. This is a great way to thank visitors for taking the time to post a comment.</li>
<li><a href="http://www.gdstarrating.com/">GD Star Rating</a> &#8211; Not the simplest of plugins to configure, but GD Star Rating has a wealth of options that can enable star ratings (Or thumbs) on WordPress comments (And posts).</li>
<li><a href="http://wordpress.org/extend/plugins/wp-recaptcha/">WordPress reCAPTCHA</a> &#8211; Spam can be a nightmare on WordPress blogs, but this plugin makes it simple to add Google&#8217;s captcha (&#8220;Type the letters&#8230;&#8221;) tool to your blog.</li>
</ul>
<h2>Which Do You Use?</h2>
<p>I&#8217;ve always used regular WordPress comments with some plugins here on Pro Blog Design, because I like the <strong>flexibility of creating your own comments design</strong>. The topic of this blog is another reason; it&#8217;s good for us to show something unique.</p>
<p>More and more though, I&#8217;m working with clients who are choosing the scripts above (Particularly Disqus and Livefyre). These scripts are very impressive, and can even be a good way to <strong>speed up the development time</strong> of a new site.</p>
<p>I think the Facebook widget is only a great bet if you specifically try to encourage users to interact with you via Facebook (e.g. your site takes signups via Facebook Connect, or you need as much social sharing of your app as possible etc.).</p>
<p>I&#8217;d love to hear what approach you&#8217;ve taken on your site, <strong>and why you went down that road!</strong></p>
<p>&nbsp;</p>
]]></content:encoded>
							<wfw:commentRss>https://www.problogdesign.com/wordpress/6-ways-to-power-up-wordpress-comments/feed/</wfw:commentRss>
		<slash:comments>125</slash:comments>
							</item>
	</channel>
</rss>
