<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
<title>RSS Category: Web - davidonzo's blog :)</title>
<link>http://www.davidonzo.com/</link>
<description>RSS Category: Web - davidonzo's blog :)</description>
<language>IT-it</language>
<generator>davidonzo coding</generator>
<pubDate>Fri, 25 Jul 2008 13:11:14 +0100</pubDate>
<ttl>60</ttl>
<item>
<title>[WordPress] Plugin Inappropriate Content</title>
<link>http://www.davidonzo.com/lng/en/post/837/wordpress-plugin-inappropriate-content/</link>
<description><![CDATA[<p><a href="http://www.davidonzo.com/post/837/wordpress-plugin-inappropriate-content/"><img src="http://www.davidonzo.com/language/flag/it.gif" alt="it" /></a> <a href="http://www.davidonzo.com/lng/en/post/837/wordpress-plugin-inappropriate-content/"><img src="http://www.davidonzo.com/language/flag/en.gif" alt="en" /></a> </p><p><img align="left" alt="WordPress at davidonzo.com" src="http://www.davidonzo.com/public/image/loghi/wordpress-logo.png" />If you are using <a target="_blank" href="http://wordpress.org">WordPress</a> as CMS and you want to post something not really appropriate to childrens and young boy, you should find this plugin very usefull.</p>
<p>&nbsp;</p>
<h3>What can I do?</h3>
<p>Inappropriate Content allow you to moderate the content of specifics posts. It show a confirmation form where is asked to the client, to confirm his age and his will to read the post.</p>
<p>&nbsp;</p>
<p>Using the control panel you'll be able to:</p>
<ul>
    <li>Enable / Disable the plugin. This option is internal to the plugin and indipendent by the global activation you turn on by the wordpress's plugins control panel.</li>
    <li>Choose the input button text.</li>
    <li>Choose the relative label.</li>
    <li>Choose some text before the form.</li>
    <li>Choose some text after the form.</li>
</ul>
<p align="center"><a target="_blank" href="http://www.davidonzo.com/public/image/browser/inappropriate_content.jpg"><img title="Click to enlarge" alt="Inappropriate Content at davidonzo.com" src="http://www.davidonzo.com/public/image/browser/inappropriate_content_th.jpg" /></a></p>
<p>&nbsp;</p>
<h3>How can I moderate the content post?</h3>
<p>To apply the content moderation, just insert a new custom field to the post, using as key <strong>VM</strong>, and give it the value <strong>1</strong>.</p>
<p>&nbsp;</p>
<p align="center"><a target="_blank" href="http://www.davidonzo.com/public/image/browser/inappropriate_custom.jpg"><img title="Click to enlarge" alt="Inappropriate Content at davidonzo.com" src="http://www.davidonzo.com/public/image/browser/inappropriate_custom_th.jpg" /></a></p>
<p>&nbsp;</p>
<p>By this way any user won't read the content post if before he doesn't confirm his will to read it. After the confirmation, all moderated posts will be showed to the blog visitor for 24h.</p>
<p>&nbsp;</p>
<p>The plugin use the cookies just to identify users has confirmed the form in the last 24h. Clients that brows without cookies enabled will see the post after the confirmation submit, but they will confirm using the form any page refresh.</p>
<p>&nbsp;</p>
<h3>How To Install</h3>
<p><strong><a target="_blank" href="http://www.davidonzo.com/public/file/inappropriate_content.zip">Download the zip archive</a></strong>, decompress it and copy the file inappropriate_content.php into your wp-content/plugins folder. Join your WP control panel and activete it as any other WP plugin. Go to the options page to configure it.</p>
<p>&nbsp;</p>
<h3>License</h3>
<p><strong><a target="_blank" href="http://www.gnu.org/licenses/lgpl.html">GNU/LGPL</a></strong>.</p><script src="http://feeds.feedburner.com/~s/davidonzo?i=http://www.davidonzo.com/lng/en/post/837/wordpress-plugin-inappropriate-content/" type="text/javascript" charset="utf-8"></script>]]></description>
<pubDate>2008-06-18 18:15:32</pubDate>
<guid isPermaLink="false">http://www.davidonzo.com/lng/en/post/837/wordpress-plugin-inappropriate-content/</guid>
</item>
<item>
<title>Morfeus Fucking Scanner</title>
<link>http://www.davidonzo.com/lng/en/post/830/morfeus-fucking-scanner/</link>
<description><![CDATA[<p><a href="http://www.davidonzo.com/post/830/morfeus-fucking-scanner/"><img src="http://www.davidonzo.com/language/flag/it.gif" alt="it" /></a> <a href="http://www.davidonzo.com/lng/en/post/830/morfeus-fucking-scanner/"><img src="http://www.davidonzo.com/language/flag/en.gif" alt="en" /></a> </p><p>If you read in your server log a strange user agent: &quot;<strong>Morfeus Fucking Scanner</strong>&quot; you have to know that it's a bot who scan PHP server application to find some vulnerability.</p>
<p>&nbsp;</p>
<p>At the moment, the relative IP scanned this server is located in Spain, but reading old logs, it means many connection has been provide from USA.</p>
<p>&nbsp;</p>
<p>Here all works fine. No vulnerability have been found on this server (ATM :-) ). My blogging software has no several bugs! Or just I hope so ;-) .</p>
<p>&nbsp;</p>
<p>If you are running Apache like web server, you can easly block Morfeus by three .htaccess lines</p>
<p>&nbsp;</p>
<p><span class="Code">RewriteEngine On<br />
RewriteCond %{HTTP_USER_AGENT} ^Morfeus<br />
RewriteRule ^.*$ - [F]</span></p>
<p>&nbsp;</p>
<p>And, bye bye Morfeus ;-)</p><script src="http://feeds.feedburner.com/~s/davidonzo?i=http://www.davidonzo.com/lng/en/post/830/morfeus-fucking-scanner/" type="text/javascript" charset="utf-8"></script>]]></description>
<pubDate>2008-06-03 20:11:35</pubDate>
<guid isPermaLink="false">http://www.davidonzo.com/lng/en/post/830/morfeus-fucking-scanner/</guid>
</item>
<item>
<title>The REAL Open Source WebDev</title>
<link>http://www.davidonzo.com/lng/en/post/828/the-real-open-source-webdev/</link>
<description><![CDATA[<p><a href="http://www.davidonzo.com/post/828/the-real-open-source-webdev/"><img src="http://www.davidonzo.com/language/flag/it.gif" alt="it" /></a> <a href="http://www.davidonzo.com/lng/en/post/828/the-real-open-source-webdev/"><img src="http://www.davidonzo.com/language/flag/en.gif" alt="en" /></a> </p><p>Languages:</p>
<ul>
    <li>PHP</li>
    <li>Python</li>
    <li>ROR</li>
    <li>Perl</li>
    <li>Java</li>
    <li>JavaScript</li>
    <li>AJAX</li>
    <li>DOM</li>
    <li>HTML</li>
    <li>XHTML</li>
    <li>XML</li>
    <li>CSS</li>
    <li>MySQL</li>
</ul>
<p>Softwares:</p>
<ul>
    <li><strong><a target="_blank" href="http://www.vim.org/">VIM</a></strong></li>
</ul>
<p>And he will say you VI is too old for him...</p><script src="http://feeds.feedburner.com/~s/davidonzo?i=http://www.davidonzo.com/lng/en/post/828/the-real-open-source-webdev/" type="text/javascript" charset="utf-8"></script>]]></description>
<pubDate>2008-05-29 10:07:44</pubDate>
<guid isPermaLink="false">http://www.davidonzo.com/lng/en/post/828/the-real-open-source-webdev/</guid>
</item>
<item>
<title>Intesa Sanpaolo - Always with you, just enable JavaScript!</title>
<link>http://www.davidonzo.com/lng/en/post/827/intesa-sanpaolo-always-with-you-just-enable-javascript/</link>
<description><![CDATA[<p><a href="http://www.davidonzo.com/post/827/intesa-sanpaolo-always-with-you-just-enable-javascript/"><img src="http://www.davidonzo.com/language/flag/it.gif" alt="it" /></a> <a href="http://www.davidonzo.com/lng/en/post/827/intesa-sanpaolo-always-with-you-just-enable-javascript/"><img src="http://www.davidonzo.com/language/flag/en.gif" alt="en" /></a> </p><p><a href="http://www.intesasanpaolo.com" target="_blank"><img width="254" height="33" align="left" src="http://www.davidonzo.com/public/image/loghi/intesasanpaolo.jpg" alt="Intesa Sanpaolo at davidonzo.com" /></a>Since some time, <a href="http://www.intesasanpaolo.com" target="_blank">Intesa Sanpaolo</a> - tha main financial group in Italy and one of the most important in Europe - launch his new web site. Realased using a 2.0 styling concept. AJAX integrations and generic JavaScript to provide nice effects and modern browsing experence by the users.</p>
<p>&nbsp;</p>
<p>I thought to read the markup and others main thing to take some personal valutation in order to post my impression about the new portal.</p>
<p>&nbsp;</p>
<p>Well, I just release that too many people think &quot;2.0&quot; means only AJAX stuff like visual loader, text appearing using decreasing opacity and some nice toogle tool applied to the menus.</p>
<p>&nbsp;</p>
<p>I think web 2.0 should be &quot;<strong>more accessibility and ease in the content fruition using modern tecniques that MUST be NOT exclusive</strong>&quot;.</p>
<p>&nbsp;</p>
<p>Just one think about the Intesa Sanpaolo web site: try to disable JavaScript by the browser's options. Join the website and... DAMNS! <strong>The website is totally unsurfable!</strong></p>
<p>&nbsp;</p>
<p>I hope they don't manage our money like their supplier selection...</p><script src="http://feeds.feedburner.com/~s/davidonzo?i=http://www.davidonzo.com/lng/en/post/827/intesa-sanpaolo-always-with-you-just-enable-javascript/" type="text/javascript" charset="utf-8"></script>]]></description>
<pubDate>2008-05-28 14:07:44</pubDate>
<guid isPermaLink="false">http://www.davidonzo.com/lng/en/post/827/intesa-sanpaolo-always-with-you-just-enable-javascript/</guid>
</item>
<item>
<title>[JavaScript] A constructor make it easy</title>
<link>http://www.davidonzo.com/lng/en/post/815/javascript-a-constructor-make-it-easy/</link>
<description><![CDATA[<p><a href="http://www.davidonzo.com/post/815/javascript-a-constructor-make-it-easy/"><img src="http://www.davidonzo.com/language/flag/it.gif" alt="it" /></a> <a href="http://www.davidonzo.com/lng/en/post/815/javascript-a-constructor-make-it-easy/"><img src="http://www.davidonzo.com/language/flag/en.gif" alt="en" /></a> </p><p>JavaScript is often used to provide more contemporary routines in the same web page. This may give problem if the function, written using a regural contruction, is able to be instanced just one time.</p>
<p>&nbsp;</p>
<p>To avoid this limit - is a natural limit depending by the code style used by the coder - it's necessary to build an object. This will be able to create differents instances and to use methods for any instance without create conflict with other variables and functions called by others instances.</p>
<p>&nbsp;</p>
<p>Will go to define different functions inside an object constructor called using how many instances we need to create. Any instance will be able to use all the methods defined inside the object regardless from other instances.</p>
<p>&nbsp;</p>
<p>To have a better idea what we are talking about, let's see an easy example where use innerHTML.</p>
<p>&nbsp;</p>
<p><span class="Code">function showText('text', 'id'){<br />
&nbsp; this.text = text;<br />
&nbsp; this.id&nbsp;&nbsp; = id;<br />
&nbsp; <br />
&nbsp; this.g = function(){<br />
&nbsp;&nbsp;&nbsp; return document.getElementById(this.id);<br />
&nbsp; }<br />
&nbsp; <br />
&nbsp; this.show = function(){<br />
&nbsp;&nbsp;&nbsp; this.g.innerHTML = this.text;<br />
&nbsp; }<br />
}<br />
<br />
first = new showText('Hello World!','myId');<br />
first.show();<br />
<br />
second = new showText('Hello Web!','myOtherId');<br />
second.show();</span></p>
<p>&nbsp;</p>
<p>The example may appear poor, but using a constructor on more complex functions, your life may be better and your coding powerful ;)</p><script src="http://feeds.feedburner.com/~s/davidonzo?i=http://www.davidonzo.com/lng/en/post/815/javascript-a-constructor-make-it-easy/" type="text/javascript" charset="utf-8"></script>]]></description>
<pubDate>2008-05-09 23:41:21</pubDate>
<guid isPermaLink="false">http://www.davidonzo.com/lng/en/post/815/javascript-a-constructor-make-it-easy/</guid>
</item>
<item>
<title>How To create a WordPress Plugin</title>
<link>http://www.davidonzo.com/lng/en/post/810/how-to-create-a-wordpress-plugin/</link>
<description><![CDATA[<p><a href="http://www.davidonzo.com/post/810/how-to-create-a-wordpress-plugin/"><img src="http://www.davidonzo.com/language/flag/it.gif" alt="it" /></a> <a href="http://www.davidonzo.com/lng/en/post/810/how-to-create-a-wordpress-plugin/"><img src="http://www.davidonzo.com/language/flag/en.gif" alt="en" /></a> </p><p><img width="150" height="150" align="left" src="http://www.davidonzo.com/public/image/loghi/wordpress-logo.png" alt="wordpress at davidonzo.com" />Now let's see how to create a <a href="http://wordpress.org" target="_blank">WordPress</a> plugin. Why this post? Often WP users active a plugin and use only the 5% of its features. Is not a good choise. There are people who boasts of using 50 or more plugin. IMHO they just wrong CMS :)</p>
<p>&nbsp;</p>
<p>In any case plugins help us to make several chenges in our blogging platform without change che core code and the template used, just activating / disactivating a file by the control panel.</p>
<p>&nbsp;</p>
<p>Now, to explane how a WP plugin can be create, we'll see the needed operation to produce a simple plugin showing a fixed text before any post. Really unusefully plugin, <span onmouseout="_tipoff()" onmouseover="_tipon(this)" style="">but with clear didactic purpose.</span></p>
<p>&nbsp;</p>
<h3><span onmouseout="_tipoff()" onmouseover="_tipon(this)" style="">How To Begin</span></h3>
<p><span onmouseout="_tipoff()" onmouseover="_tipon(this)" style="">First of all, it's very important read the <a href="http://codex.wordpress.org/Main_Page" target="_blank">documentation released by the WP</a> team, to know as well as possible all the functions availables given by the wp core.</span></p>
<p><span onmouseout="_tipoff()" onmouseover="_tipon(this)" style="">After this, you have to know that wordpress use a single database field to activate a plugin. The informations concerning the actives plugins are stored in the wp_options table (where wp_ is just the table prefix) in correspondants of the </span>&quot;option_name = 'active_plugins'&quot; value.</p>
<p>All plugins file are stored in /wp-content/plugins/.</p>
<p>&nbsp;</p>
<h3>Begin Writing</h3>
<p>With our favorite text editor create a new document called myplugin.php. After the php open tag, it must be inserted some comment line that will be used by identify the plugin name, author, version and description.</p>
<p>&nbsp;</p>
<p><span class="Code">&lt;?php<br />
/*<br />
Plugin Name: Just a test plugin<br />
Plugin URI: http://www.davidonzo.com/<br />
Description: Just a simple plugin to show how wordpress plugins work and can be create.<br />
Author: davidonzo<br />
Version: 0.1<br />
Author URI: http://www.davidonzo.com/<br />
*/</span></p>
<p>&nbsp;</p>
<ul>
    <li>Plugin Name: choose a funny name for your plugin.</li>
    <li>Plugin URI: have you publishe a post or an entire web site for the plugin?</li>
    <li>Description: write a short description of the plugin. In one line. Break line will erase the content!</li>
    <li>Author: your name.</li>
    <li>Version: the versione number of the plugin.</li>
    <li>Author URI: your link.</li>
</ul>
<p>These informations will be showed in the management plugins page of wordpress's admin control panel.</p>
<p>&nbsp;</p>
<h3>The necessaries functions</h3>
<p>What do you need to make the plugin? We said we want to create a plugin tha add a fixed text, choosen by the user, before any post. So, we need an option where writing the text and another one where we'll use as a boolean value to make the visualization active or not.</p>
<p>&nbsp;</p>
<p>To make it easy, we choose to save both options in just one record. Using a text separator between the string to provide a simply explode() string that extract the needed value. In this case we will use <em>%%%</em>.</p>
<p>&nbsp;</p>
<p>Now, we need to know that the plugins options are stored in the same table used by WP for the others system options: wp_options. We che easly create new options just using a function available in the WP core: add_option($nameoption, $value). The option's $value will be stored in a longtext field.</p>
<p>&nbsp;</p>
<p>During the plugin installation a new option will be created, assigning it the default values. Let's see who to do it!</p>
<p>&nbsp;</p>
<p><span class="Code">function myplugin_install(){<br />
&nbsp; if(get_option('opt_myplugin' == '') || !get_option('opt_myplugin')){<br />
&nbsp;&nbsp;&nbsp; add_option('opt_myplugin', '0%%%Write some text');<br />
&nbsp; }<br />
}<br />
<br />
if (isset($_GET['activate']) &amp;&amp; $_GET['activate'] == 'true') {<br />
&nbsp;&nbsp;&nbsp; myplugin_install();<br />
}</span></p>
<p>&nbsp;</p>
<p>On plugin activeting, if the option named opt_myplugin doesn't exist or is empty, the option will be added to the database with the default values.</p>
<p>Note that this function will be loaded for any activating action, but the default value and the option creation will be execute just at the first activation. So, deactiving the plugin, the latest values inserted will be saved and used after the new activation.</p>
<p>&nbsp;</p>
<p>Now we need a pege inside the WP control panel, to manage the options. First of all, we add a link to the main menu of the settings page. Of couse we'll use a wp core function :)</p>
<p>&nbsp;</p>
<p><span class="Code">function myplugin_config_page(){<br />
&nbsp; if (function_exists('add_options_page')){<br />
&nbsp;&nbsp;&nbsp; add_options_page('MyPlugin Menu Title', <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'MyPlugin Option',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; basename(__FILE__),<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'myplugin_config'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );<br />
&nbsp; }<br />
}</span></p>
<p>&nbsp;</p>
<p>To work correctly, add_option_page function need some variable.</p>
<ul>
    <li>The title of the destination page.</li>
    <li>The anchor link for the title menu.</li>
    <li>The access level required to manage the settings.</li>
    <li>The file must be loaded.</li>
    <li>The callback function contained in the loaded file, that create the page.</li>
</ul>
<p>Well, let's see the callback function.</p>
<p>&nbsp;</p>
<p><span class="Code">function myplugin_config(){<br />
&nbsp; $active&nbsp;&nbsp; = (myplugin_option('active') == 1) ? 'checked' : '';<br />
&nbsp; $deactive = (myplugin_option('active') == 0) ? 'checked' : '';<br />
&nbsp; print('&lt;div class=&quot;wrap&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h2&gt;MyPlugin Options Tab&lt;/h2&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;form id=&quot;ak_sharethis&quot; name=&quot;myplugin_cnf&quot; action=&quot;'.get_bloginfo('wpurl').'/wp-admin/index.php&quot; method=&quot;post&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;p&gt;By this page it\'s possibile configure the plugin. Setup the following options to start testing how a wordpress plugin works!&lt;/p&gt; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;fieldset class=&quot;options&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;p&gt;Show some content before any post?&lt;/p&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ul&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;radio&quot; name=&quot;c_before_post&quot; value=&quot;1&quot; id=&quot;c_before_post_yes&quot; '.$active.' /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;label for=&quot;c_before_post_yes&quot;&gt;Yes&lt;/label&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;radio&quot; name=&quot;c_before_post&quot; value=&quot;0&quot; id=&quot;c_before_post_no&quot; '.$deactive.' /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;label for=&quot;c_before_post_no&quot;&gt;No&lt;/label&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/ul&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;p&gt;Type the contet text to show:&lt;/p&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;text&quot; name=&quot;c_text_myplugin&quot; value=&quot;'.myplugin_option('text').'&quot; /&gt;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/fieldset&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;p class=&quot;submit&quot;&gt;<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type=&quot;submit&quot; name=&quot;myplugin_submit_button&quot; value=&quot;Update Settings&quot; /&gt;<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &lt;/p&gt; <br />
&nbsp;&nbsp;&nbsp; &nbsp; &lt;/form&gt; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/div&gt;');<br />
}</span></p>
<p>&nbsp;</p>
<p>Just HTML containing an usefull form to manage the main plugin's options. Nothing more, nothing less :)</p>
<p>Ok, now we have a form to manage the option, but, how can we update them? Just writing another function.</p>
<p>&nbsp;</p>
<p><span class="Code">function update_myplugin_settings(){<br />
&nbsp; if($_POST['myplugin_submit_button'] == 'Update Settings'){<br />
&nbsp;&nbsp;&nbsp; $newsetting = $_POST['c_before_post'] . '%%%' . $_POST['c_text_myplugin'];<br />
&nbsp;&nbsp;&nbsp; update_option('opt_myplugin',$newsetting);<br />
&nbsp;&nbsp;&nbsp; header('Location: '.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=myplugin.php&amp;updated=true');&nbsp; <br />
&nbsp; }<br />
}</span></p>
<p>&nbsp;</p>
<p>Using update_option (another WP core function) we can easly update any option just declaring as first argument the option to update, and as second argument, the value to assign.</p>
<p>To execute it, just use add_action.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span class="Code">add_action('init', 'update_myplugin_settings', 9999);</span></p>
<p>&nbsp;</p>
<p>Using the tag init and a height priority (9999) this action will be performed any time the plugin file is requested. But read the callback function as well: the real option update process will run just when it receive a particular POST data.</p>
<p>&nbsp;</p>
<p>Now we have a page who manage the options, we can update them, we can activate the plugin as well, but, where is the function who chage my wordpress front-end?</p>
<p>&nbsp;</p>
<p><span class="Code">function add_myplugin_text_to_content($content){<br />
&nbsp; if(myplugin_option('active') == 1){<br />
&nbsp;&nbsp; $content = '&lt;p&gt;'.myplugin_option('text').'&lt;/p&gt;' . $content;<br />
&nbsp; }<br />
&nbsp; return $content;<br />
}<br />
<br />
add_action('the_content', 'add_myplugin_text_to_content');</span></p>
<p>&nbsp;</p>
<p>Just a simple function, activated when the_content() function run, that replace $content variable.</p>
<p>&nbsp;</p>
<p>Do you want to download this example wp plugin? <strong><a href="http://www.davidonzo.com/public/file/myplugin.zip" target="_blank">Just click here</a></strong> :)</p><script src="http://feeds.feedburner.com/~s/davidonzo?i=http://www.davidonzo.com/lng/en/post/810/how-to-create-a-wordpress-plugin/" type="text/javascript" charset="utf-8"></script>]]></description>
<pubDate>2008-04-27 19:59:07</pubDate>
<guid isPermaLink="false">http://www.davidonzo.com/lng/en/post/810/how-to-create-a-wordpress-plugin/</guid>
</item>
<item>
<title>[JavaScript] How to read Cookies informations</title>
<link>http://www.davidonzo.com/lng/en/post/808/javascript-how-to-read-cookies-informations/</link>
<description><![CDATA[<p><a href="http://www.davidonzo.com/post/808/javascript-how-to-read-cookies-informations/"><img src="http://www.davidonzo.com/language/flag/it.gif" alt="it" /></a> <a href="http://www.davidonzo.com/lng/en/post/808/javascript-how-to-read-cookies-informations/"><img src="http://www.davidonzo.com/language/flag/en.gif" alt="en" /></a> </p><p>A simple function to read a cookie value.</p>
<p>&nbsp;</p>
<p><span class="Code">function CookieValue (offset) {<br />
&nbsp; var stringend = document.cookie.indexOf (&quot;;&quot;, offset);<br />
&nbsp; if (stringend == -1)<br />
&nbsp;&nbsp; stringend = document.cookie.length;<br />
&nbsp; return unescape(document.cookie.substring(offset, stringend)).replace(&quot;+&quot;,&quot; &quot;);<br />
}<br />
<br />
&nbsp; function GetCookie (name) {<br />
&nbsp;&nbsp; var argu = name + &quot;=&quot;;<br />
&nbsp;&nbsp; var alen = arg.length;<br />
&nbsp;&nbsp; var clen = document.cookie.length;<br />
&nbsp;&nbsp; var none = '';<br />
&nbsp;&nbsp; var i = 0;<br />
&nbsp;&nbsp; while (i &lt; clen) {<br />
&nbsp;&nbsp;&nbsp; var a = i + alen;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (document.cookie.substring(i, a) == arg)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return CookieValue(a);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = document.cookie.indexOf(&quot; &quot;, i) + 1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (i == 0) break;<br />
&nbsp; }<br />
&nbsp;return none;<br />
}</span></p>
<p>&nbsp;</p>
<h3>How to use it?</h3>
<p>An example may be the best way to understand hot to use this code. Assum you have a cookie named &quot;MyCookie&quot; with value &quot;MyCookie+Value&quot;.</p>
<p>The function:</p>
<p>&nbsp;</p>
<p><span class="Code">GetCookie('MyCookie')</span></p>
<p>&nbsp;</p>
<p>Return: &quot;MyCookie Value&quot;.</p>
<p>&nbsp;</p>
<p>I'm working hard in this period. I hope to have more time to update the blog ASAP :)</p><script src="http://feeds.feedburner.com/~s/davidonzo?i=http://www.davidonzo.com/lng/en/post/808/javascript-how-to-read-cookies-informations/" type="text/javascript" charset="utf-8"></script>]]></description>
<pubDate>2008-04-24 14:51:10</pubDate>
<guid isPermaLink="false">http://www.davidonzo.com/lng/en/post/808/javascript-how-to-read-cookies-informations/</guid>
</item>
<item>
<title>[JavaScript] TextScroller 1.1</title>
<link>http://www.davidonzo.com/lng/en/post/803/javascript-textscroller-11/</link>
<description><![CDATA[<p><a href="http://www.davidonzo.com/post/803/javascript-textscroller-11/"><img src="http://www.davidonzo.com/language/flag/it.gif" alt="it" /></a> <a href="http://www.davidonzo.com/lng/en/post/803/javascript-textscroller-11/"><img src="http://www.davidonzo.com/language/flag/en.gif" alt="en" /></a> </p><p>TextScroller is a JavaScript library that permit to scroll the text of the target ID of the web page. It's easy to use, easy to configure and require just javascript enable on the browser's client surfing you web pages.</p>
<p>&nbsp;</p>
<h3>How to setup the script</h3>
<p>Using your favorite text editor open the file named textScroller.js and assign the values to the following variables:</p>
<p>&nbsp;</p>
<p><span class="Code">&nbsp; var orientamento = '';<br />
&nbsp; var parent = '';<br />
&nbsp; var duration = ; <br />
&nbsp; var h = ;<br />
&nbsp; var w = ;</span></p>
<p>&nbsp;</p>
<h4>var orientamento (array)</h4>
<p>Choose the prefered scrolling direction:</p>
<ul>
    <li>TD: from top to bottom;</li>
    <li>DT: from bottom to top;</li>
    <li>RL: from right to left;</li>
    <li>LR: from left to right;</li>
</ul>
<p>&nbsp;</p>
<h4>var parent (string)</h4>
<p>The ID element containing the scrolling text.</p>
<p>&nbsp;</p>
<h4>var duration (integer)</h4>
<p>Scrolling speed. Bigger means slowest and vice versa.</p>
<p>&nbsp;</p>
<h4>var h (integer)</h4>
<p>The height value of the scrolling ID. By this way you can choose the height of the scrolling text.</p>
<p>&nbsp;</p>
<h4>var w (integer)</h4>
<p>The width value of the scrolling ID. By this way you can choose the width of the scrolling text.</p>
<p>&nbsp;</p>
<h3>Impostare il codice HTML</h3>
<p>Between the &lt;head&gt; tags insert this line.</p>
<p>&nbsp;</p>
<p><span class="Code">&lt;script type=&quot;text/javascript&quot; src=&quot;textScroller.js&quot;&gt;&lt;/script&gt;</span></p>
<p>&nbsp;</p>
<p>Warning: consider the relative positione of the file. Writing the line exactly as above, the js file must be in the same folder of the html file.</p>
<p>&nbsp;</p>
<p>Inside the &lt;body&gt; tag:</p>
<p>&nbsp;</p>
<p><span class="Code">&lt;body onload=&quot;letsGo()&quot;&gt;</span></p>
<p>&nbsp;</p>
<p>Inside the page, insert an element identified by the ID you want to scroll.</p>
<p>&nbsp;</p>
<p><span class="Code"> &lt;div id=&quot;parent&quot;&gt;<br />
&nbsp;&nbsp;&nbsp; Testo da scrollare<br />
&nbsp;&nbsp;&nbsp; Testo da scrollare<br />
&nbsp;&nbsp;&nbsp; Testo da scrollare<br />
&lt;/div&gt;</span></p>
<p>&nbsp;</p>
<h3>Degradability</h3>
<p>The code is degradated. When the client has JavaScript disabled, will be loaded the CSS directives written in the stylesheet.</p>
<p>&nbsp;</p>
<h3>Extra Style</h3>
<p>You can add extra style directives by adding css information for the id named width <em>child-</em> prefix and the ID of the scrolling element.</p>
<p>&nbsp;</p>
<h3>License</h3>
<p><a target="_blank" href="http://www.gnu.org/licenses/gpl.html">GNU/GPL v.3</a>.</p>
<p>&nbsp;</p>
<h3>Demo</h3>
<p><a target="_blank" href="../../../ajaxstudy/textscroller/example.html">Click Here :)<br />
</a></p>
<p>&nbsp;</p>
<div align="center"><a href="http://www.davidonzo.com/public/file/textScroller.tar.gz" target="_blank"><img width="420" height="80" src="http://www.davidonzo.com/public/image/browser/downloadtextscroller.jpg" alt="download textScroller at davidonzo.com" /></a></div><script src="http://feeds.feedburner.com/~s/davidonzo?i=http://www.davidonzo.com/lng/en/post/803/javascript-textscroller-11/" type="text/javascript" charset="utf-8"></script>]]></description>
<pubDate>2008-04-15 09:35:48</pubDate>
<guid isPermaLink="false">http://www.davidonzo.com/lng/en/post/803/javascript-textscroller-11/</guid>
</item>
</channel>
</rss>
