<?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>devness &#187; real time widgets</title>
	<atom:link href="http://devness.com/tag/real-time-widgets/feed/" rel="self" type="application/rss+xml" />
	<link>http://devness.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 01 Jul 2009 21:41:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Livegets: update any WordPress Widget in real time</title>
		<link>http://devness.com/2009/06/livegets-update-any-wordpress-widget-in-real-time/</link>
		<comments>http://devness.com/2009/06/livegets-update-any-wordpress-widget-in-real-time/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 21:43:54 +0000</pubDate>
		<dc:creator>dmoena</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Livegets]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[real time widgets]]></category>

		<guid isPermaLink="false">http://devness.com/?p=34</guid>
		<description><![CDATA[
hello world! -not too original, but I had to do it- Let me tell you about Livegets. What is it? Well, Livegets is a Worpress plugin for enabling real time updates for any Wordpress widget. Any widget? Any.
Why? Because real time widget update would be useful for visitors to know what is happening at any [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" title="wordpress-logo" src="http://devness.com/wp-content/uploads/2009/06/wordpress-logo.gif" alt="wordpress-logo" width="200" height="200" /></p>
<p>hello world! -not too original, but I had to do it- Let me tell you about Livegets. What is it? Well, Livegets is a Worpress plugin for enabling real time updates for any Wordpress widget. Any widget? Any.</p>
<p>Why? Because real time widget update would be useful for visitors to know what is happening at any time in your blog.</p>
<p>Picture this: a visitor is reading an specific post at your site and you add a new one. Without Livegets, your visitor will probably leave the site if the current post is the lastest at the time he/she arrives. Now, with Livegets he/she will know there is a new post and will probably visit it.</p>
<p>Another example? Think about a &#8220;Top 10 Something&#8221; widget. Would be great to offer real time updates, don&#8217;t you think?</p>
<p><span id="more-34"></span></p>
<h2 style="clear:both;padding-top:2px;">Installation</h2>
<p>Livegets installation is divided into two steps: plugin installation as any other plugin and an small modification of a Wordpress core file&#8230; I know it sounds painfull, but is really simple.</p>
<p>Lets start with the &#8220;core&#8221; part. For this, we need to modify just one file ir order to fully integrate Livegets to your Wordpress installation. The file we need to edit is located into wp-includes and it&#8217;s named &#8220;widgets.php&#8221;.</p>
<p>Its modification is pretty simple: just locate dynamic_sidebar function (around line 433 for Wordpress 2.7.1 and 808 for 2.8) inside of &#8220;widgets.php&#8221; and find this code (line 477 and 855 respectively)</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;"><span class="kw1">if</span> <span class="br0">&#40;</span> <a href="http://www.php.net/is_callable"><span class="kw3">is_callable</span></a><span class="br0">&#40;</span><span class="re0">$callback</span><span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/call_user_func_array"><span class="kw3">call_user_func_array</span></a><span class="br0">&#40;</span><span class="re0">$callback</span>, <span class="re0">$params</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="re0">$did_one</span> = <span class="kw2">true</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p>once you have it, change the previous code for this one</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;"><span class="re0">$widgets</span> = <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;,&quot;</span>,get_option<span class="br0">&#40;</span><span class="st0">&quot;livegets&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">if</span> <span class="br0">&#40;</span> <a href="http://www.php.net/is_callable"><span class="kw3">is_callable</span></a><span class="br0">&#40;</span><span class="re0">$callback</span><span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/in_array"><span class="kw3">in_array</span></a><span class="br0">&#40;</span><span class="re0">$id</span>,<span class="re0">$widgets</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span> <span class="kw2">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;script type=<span class="st0">&quot;text/javascript&quot;</span>&gt; widgets.push<span class="br0">&#40;</span><span class="st0">&quot;&lt;?php echo $id; ?&gt;&quot;</span><span class="br0">&#41;</span>; <span class="kw2">&lt;/script&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;script type=<span class="st0">&quot;text/javascript&quot;</span>&gt; widgets_name<span class="br0">&#91;</span><span class="st0">&quot;&lt;?php echo $id; ?&gt;&quot;</span><span class="br0">&#93;</span> = <span class="st0">&quot;&lt;?php echo get_option($id.&quot;</span>_updated_text<span class="st0">&quot;); ?&gt;&quot;</span>; <span class="kw2">&lt;/script&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;span id=<span class="st0">&quot;&lt;?php echo $id; ?&gt;&quot;</span>&gt;&lt;?php<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/call_user_func_array"><span class="kw3">call_user_func_array</span></a><span class="br0">&#40;</span><span class="re0">$callback</span>, <span class="re0">$params</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/in_array"><span class="kw3">in_array</span></a><span class="br0">&#40;</span><span class="re0">$id</span>,<span class="re0">$widgets</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span> <span class="kw2">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/span&gt;&lt;?php<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$did_one</span> = <span class="kw2">true</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p><img class="alignleft" style="margin-bottom:16px" title="livegets_config" src="http://devness.com/wp-content/uploads/2009/06/livegets_config.png" alt="Livegets Config" width="145" height="229" /></p>
<p>Plugin installation is like the usual thing: decompress livegets into the Wordpress&#8217; plugin directory. Just be sure the final plugin route is like &#8220;&#8230;/plugins/livegets/livegets.php&#8221;.</p>
<p>Once activated, you will see Livegets Configuration options as part of Wordpress&#8217; Settings, just like in the example image.</p>
<p>We are done! Now you just need to select the widgets that will be real time widegts or  Livegets and fill its updated text if you want it. After that, Livegets plugin and jQuery will do the rest.</p>
<p>Oh, one more thing! Choose only those widgets which worth to make Livegets, that means, those that reports some kind of &#8220;last activity&#8221; &#8211; last comments, last posts&#8230; &#8211; otherwise, you will be stressing out your server and bandwith for no reason.</p>
<h2 style="clear:both;padding-top:12px;">Demo</h2>
<p>You can simulate an update for the &#8220;Recent Posts&#8221; widget by clicking right <a href="#" id="livegets_demo">here</a>. What you see -or will see- is only a <a href="http://www.stanlemon.net/projects/jgrowl.html">jGrowl notification</a>, but when it happens for real, you can see the widget actually updated and you are enable to visit the new event(s) if you want to.<br />
<script type="text/javascript"> 
$(document).ready(function(){
    $('#livegets_demo').click(function(){
        $.jGrowl('<a href="#recent-posts-3">New post added</a>');
        return false;
    });
});
</script></p>
<h2 style="clear:both;padding-top:12px;">Restrictions</h2>
<p>At this time, I found problems with themes where widget&#8217;s content is manipulated after being sent. For instance, when you use JavaScript to create rounded corners. So, check this before you use it.</p>
<h2>Download</h2>
<p>You can download this plugin <a href="http://devness.com/wp-content/uploads/2009/06/livegets.rar">right here</a>.</p>
<h2>Finally</h2>
<p>If you find any kind of error, please let me know. The better way is probably by leaving a comment&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://devness.com/2009/06/livegets-update-any-wordpress-widget-in-real-time/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
