<?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>Digital Ramble &#187; design</title>
	<atom:link href="http://www.digitalramble.com/tags/design/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.digitalramble.com</link>
	<description>surveyor of the foothills, valleys and occasional sheer cliff drops of the world of computer programming...</description>
	<lastBuildDate>Wed, 30 May 2007 05:37:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
  <link>http://www.digitalramble.com</link>
  <url>http://www.digitalramble.com/wordpress/favinit.gif</url>
  <title>Digital Ramble</title>
</image>
		<item>
		<title>growing a database</title>
		<link>http://www.digitalramble.com/2006/08/11/65/</link>
		<comments>http://www.digitalramble.com/2006/08/11/65/#comments</comments>
		<pubDate>Sat, 12 Aug 2006 01:42:03 +0000</pubDate>
		<dc:creator>Cindy</dc:creator>
				<category><![CDATA[databases]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[postgresql]]></category>

		<guid isPermaLink="false">http://www.digitalramble.com/2006/08/11/65/</guid>
		<description><![CDATA[I&#8217;ve been doing database driven websites for about seven years now, some of my own and some at work.   Below I list some tips that have saved me a lot of trouble.  Nothing complicated, and generally intended for small to medium sized databases&#8230;

Break up the tables
I have a database that stores information [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing database driven websites for about seven years now, some of my own and some at work.   Below I list some tips that have saved me a lot of trouble.  Nothing complicated, and generally intended for small to medium sized databases&#8230;<br />
<span id="more-65"></span></p>
<h3>Break up the tables</h3>
<p>I have a database that stores information about dogs taken into a rescue group.  Of course it started out with the basic information:  name of dog, where obtained (shelter, owner, etc), who is fostering the dog, where a picture of the dog is, a descriptive &#8220;biography&#8221; of the dog, and a comment log noting things about the dog, or other relevant information.  Something like:<br />
<pre><code>
CREATE TABLE Foster_Dogs (
&nbsp;&nbsp;id MEDIUMINT(8) NOT NULL AUTO_INCREMENT,
&nbsp;&nbsp;name CHAR(30) NOT NULL,
&nbsp;&nbsp;source ENUM (&quot;Shelter&quot;, &quot;Owner&quot;, &quot;Stray&quot;, &quot;Vet&quot;, &quot;Rescue&quot;),
&nbsp;&nbsp;intake DATE,
&nbsp;&nbsp;foster_home MEDIUMINT(8),
&nbsp;&nbsp;picture VARCHAR(60),
&nbsp;&nbsp;bio TEXT,
&nbsp;&nbsp;comments TEXT
&nbsp;&nbsp;/* and actually much, much more...sigh */
);

</code></pre><br />
Of course all kinds of situations have come up that I never thought of when first putting this together.  The group started kenneling some dogs in addition to fostering them.  Polls, vet bills, sponsorships, etc. In short, more information as time went on.  </p>
<p>The first few times, I modified the entire &#8220;Foster dog&#8221; table to add on new fields, crossing my fingers each time that I woudn&#8217;t honk the database.  Of course I always backed things up, but restoring in the case of mistakes was always a time consuming chore.</p>
<p>Then I hit on a much better solution.  I already had a unique ID for each foster dog, because I knew I could not guarantee unique names for each dog (indeed the first two years alone saw over 20 dogs named &#8220;Buddy&#8221;).  So I created a <i>new</i> table altogether.  </p>
<p>As a simple example, some of the fostered dogs are cross indexed with a free advertising group to look for more potential adoptors.  But the group wants to be able to remove such dogs from the other group when they have been adopted.  So the simplest solution is a new table, consisting of two columns: the dog&#8217;s ID, and the name of the group it is cross-listed with.  The original foster table is absolutely untouched.  And it&#8217;s a snap to add this information to the edit pages seamlessly.  The volunteers don&#8217;t know how the structure is underneath, it all comes up on the display pages, plus they can search on &#8220;which dogs are currently listed in which groups&#8221; and get the list &#8212; quickly.</p>
<h3>Quantify select fields!</h3>
<p>This bit me in the butt several times.  Not so much now with the new tables approach above, but sometimes a table really needs to be altered in some way.  In which case, a SELECT statement of the form:<br />
<pre><code>
SELECT * FROM Foster_Dogs...
</code></pre><br />
is going to <i>hurt</i> when the wrong values are shoved into the wrong fields.  No matter how painful it is to list (although yet again with the micro table method above, this is also alleviated), list them explicitly!  That way even if the columns are reordered, the results from the query are always ordered the same way.</p>
<p>No, I don&#8217;t know why I didn&#8217;t always add new fields at the ends of records <img src='http://www.digitalramble.com/wordpress/smilies/yahoo_ooooh.gif' alt='&#58;&#45;&#79;' class='wp-smiley' width='18' height='18' title='&#58;&#45;&#79;' />  Some things are best forgotten, I think&#8230;</p>
<h3>Use ID&#8217;s Everywhere</h3>
<p>When coming up with some object on which data will be stored, always set up unique ID&#8217;s for the table.  Both MySQL and Postgresql have functions for unique, autoincrementing numbers so that I never even have to try and track or generate the numbers.  With the unique ID&#8217;s I can then mix and match other items.</p>
<p>For example a table that pairs up volunteer and foster dog ID&#8217;s along with start/end timestamps might be all I need at this stage to have complete records of who has fostered which dog when (even multiple times, if I consider each element in this table to be a &#8220;Foster_Interval&#8221; and give <i>this</i> a unique ID.</p>
<p>To recap, that would be a definition something like this:<br />
<pre><code>
CREATE TABLE Foster_Intervals (
&nbsp;&nbsp;id MEDIUMINT(8) NOT NULL AUTO_INCREMENT,
&nbsp;&nbsp;dog_id MEDIUMINT(8) NOT NULL,
&nbsp;&nbsp;vol_id MEDIUMINT(8) NOT NULL,
&nbsp;&nbsp;start_time TIMESTAMP NOT NULL,
&nbsp;&nbsp;end_time TIMESTAMP
);
</code></pre><br />
The unique id guarantees that any instance of a volunteer fostering a dog will be retained.  If the same volunteer were to foster the same dog multiple times, that could overwrite the record so I only had information on the latest fostering stint, not all of them.</p>
<p>Now the query to pull out currently fostered dogs might be done this way:<br />
<code></code><br />
A simple table, but pulling together a good deal of info on top of other already constructed tables.  </p>
<h3>Record those tables</h3>
<p>Yes, a dump is generally a good way to get the structures back and both MySQL and Postgresql have ways for doing that.  But I&#8217;ve  had a few occasions where a table got deleted and then good luck with reconstructing the table.  So for convenience&#8217;s sake and for backup purposes, I maintain a file with the original table declarations in it.  In some cases, I&#8217;ve even written scripts that automatically dump table declarations and check them into a version control system.  I run these scripts before doing anything with the database and this way I have a record of the changes over time to the database.</p>
<h3>Other ideas?</h3>
<p>I find that sitting down and mapping things out helps me to form a good database structure.  Of coruse, there will be different considerations depending on the (eventual) size of the database: much larger structures may start to slow down too much with too many small tables but tables with too much aggregated information are at risk of becoming corrupted over time.</p>
<p>I&#8217;d be curious to hear of any other tips folks have acquired from their experience, too.</p>
<hr/>Copyright &copy; 2010 <strong><a href="http://www.digitalramble.com">Digital Ramble</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact legal@www.digitalramble.com so we can take legal action immediately.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.digitalramble.com/2006/08/11/65/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>detouring css through php</title>
		<link>http://www.digitalramble.com/2006/07/05/52/</link>
		<comments>http://www.digitalramble.com/2006/07/05/52/#comments</comments>
		<pubDate>Wed, 05 Jul 2006 19:11:18 +0000</pubDate>
		<dc:creator>Cindy</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.digitalramble.com/2006/07/05/52/</guid>
		<description><![CDATA[One thing that tends to drive me nuts when putting a css file together is repetition of the colours.  CSS has no mechanism to define constants or variables and it can be pretty tiresome playing around with resetting the colours and such when tweaking a web page.
So I made mine into a php file. [...]]]></description>
			<content:encoded><![CDATA[<p>One thing that tends to drive me nuts when putting a css file together is repetition of the colours.  CSS has no mechanism to define constants or variables and it can be pretty tiresome playing around with resetting the colours and such when tweaking a web page.</p>
<p>So I made mine into a <a href="http://www.k9web.com/k9web-css.php">php file</a>.  There&#8217;s a few tricks, but it&#8217;s very straightforward.   First, you call it in your main html file (or output) as with any other css file, only with it&#8217;s name:<br />
<pre><code>
&lt;link rel=&quot;stylesheet&quot; href=&quot;k9web-css.php&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;
</code></pre></p>
<p>Now here&#8217;s the fun part.  The first line in the php file must now be:<br />
<pre><code>
&lt;?php header(&quot;Content-type: text/css&quot;);
/* this tells the browser this is a css file! */
?&gt;
</code></pre></p>
<p>Otherwise the file is sent as text/html and I get unhappy junk printed out.  With that out of the way, the top of the file can contain something like this:<br />
<pre><code>
&lt;?php
/* define colours, etc here */
$darkgrey=&quot;#555&quot;;
$lightgrey=&quot;#ccc&quot;;
$offwhite=&quot;#f6f6f6&quot;;
$cream=&quot;#ffffe7&quot;;
$brightred=&quot;#ff0000&quot;;
$darkred=&quot;#aa0000&quot;;

/* change these to change color scheme */
$bgcolor=$cream;
$fontcolor=$darkgrey;
$linkcolor=$darkred;
$hoverlinkcolor=$brightred;
?&gt;
</code></pre></p>
<p>Now I proceed with the rest of the css definitions as usual, but when I want to use a defintion, I pop it in like this:<br />
<pre><code>
a:hover {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;color: &lt;?php echo $hoverlinkcolor ?&gt;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;text-decoration: underline;
}
</code></pre></p>
<p>Looks like <a target="window" href="http://www.simov.cl/rc/blog/?page_id=115">someone else</a> (actually many people; try googling on &#8220;variables in css&#8221;) was addressing the same problem.  My solution is pretty straightforward, although it does require access to php, etc.  This solution hides it but amounts to using php to parse and replace behind the scenes, so I think my solution is at least more direct&#8230;</p>
<hr/>Copyright &copy; 2010 <strong><a href="http://www.digitalramble.com">Digital Ramble</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact legal@www.digitalramble.com so we can take legal action immediately.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.digitalramble.com/2006/07/05/52/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>rethinking form/post conventions</title>
		<link>http://www.digitalramble.com/2006/07/03/51/</link>
		<comments>http://www.digitalramble.com/2006/07/03/51/#comments</comments>
		<pubDate>Mon, 03 Jul 2006 23:39:05 +0000</pubDate>
		<dc:creator>Cindy</dc:creator>
				<category><![CDATA[cgi scripts]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.digitalramble.com/2006/07/03/51/</guid>
		<description><![CDATA[Ever since I first started scripting cgi to process forms I&#8217;ve used the two file format: the first file puts up the form and such and calls the second file to process the results of the form.  
But it really doesn&#8217;t have to be like that.  At work, I have a single program [...]]]></description>
			<content:encoded><![CDATA[<p>Ever since I first started scripting cgi to process forms I&#8217;ve used the two file format: the first file puts up the form and such and calls the second file to process the results of the form.  </p>
<p>But it really doesn&#8217;t have to be like that.  At work, I have a single program that lets you search through our database and display things, setting options and so on, and paging through the results.  It only uses one executable  (well there are a few more, but each one encapsulates a certain kind of function and as long as you&#8217;re doing that, you stay within that executable).  Now admittedly I&#8217;ve torn my hair out more than once debugging this thing, so this idea can go too far in the other direction, but keep it to simple pairs of form/post and I&#8217;m liking it.</p>
<p>So I&#8217;ve started looking at my old sites and in particular the <a href="http://www.k9web.com">old one</a> of mine that was offline for six years and rethinking how I did this stuff.  And I&#8217;m thinking the single file form/post is a much better way to go.  It&#8217;s fewer files for one thing.  I&#8217;m not left having to grep through the file to see what it calls to trace down problems.  They&#8217;re all there in one spot.  </p>
<p>So for example I just redid the mail form which started out in <code>mail.php</code> that called <code>sendemail.php</code> (that&#8217;s another thing, it simplifies naming conventions &#8212; at another site of mine I&#8217;ve been trying to standardize to action_form.cgi and action_post.cgi but still it&#8217;s all a mess.</p>
<p>But this comes out nice and slick in one file.  Start up the headers, check whether it&#8217;s a submit and the form goes in the first half the if statement, the post in the second half.  Close off with the footers and it&#8217;s all set.</p>
<p>Now, let&#8217;s see, just how many more files are lurking around on this site?  Sigh&#8230;</p>
<hr/>Copyright &copy; 2010 <strong><a href="http://www.digitalramble.com">Digital Ramble</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact legal@www.digitalramble.com so we can take legal action immediately.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.digitalramble.com/2006/07/03/51/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>theme-a-thon!</title>
		<link>http://www.digitalramble.com/2006/06/16/43/</link>
		<comments>http://www.digitalramble.com/2006/06/16/43/#comments</comments>
		<pubDate>Fri, 16 Jun 2006 20:29:59 +0000</pubDate>
		<dc:creator>Cindy</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.digitalramble.com/2006/06/16/43/</guid>
		<description><![CDATA[Having MUCH too much fun with theme rotation&#8230; 
Actually though, I think every theme developer should play around with something like this.  Because I&#8217;m starting to develop some very strong preferences for basic setups, such as:

always package up your theme in a directory so when I unzip it, it keeps everything tidy in it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Having MUCH too much fun with theme rotation&#8230; <img src='http://www.digitalramble.com/wordpress/smilies/yahoo_bigsmile.gif' alt='&#58;&#45;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#45;&#68;' /></p>
<p>Actually though, I think every theme developer should play around with something like this.  Because I&#8217;m starting to develop some very strong preferences for basic setups, such as:</p>
<ol>
<li>always package up your theme in a directory so when I unzip it, it keeps everything tidy in it&#8217;s own directory, &#8216;k?
<li>don&#8217;t make your sidebars (or other .php files) so weird I can&#8217;t drop in copies of my already tweaked sidebars in! (I found one theme that closed off a div before starting the sidebar div &#8212; which meant it didn&#8217;t play well with anyone else!)
<li>make sure they use the right hooks and such&#8230;I found some that didn&#8217;t incorporate some of my auto-plugins (ones that didn&#8217;t need stuff added to files in the theme directories) &#8212; those went buh-bye though I liked them&#8230;
</ol>
<p>Note that the only mods I did to these themes was to ensure that they all had a theme handler in the side bar so that no one gets stuck in a theme with no exit.  But in the longer run, I want to set them all up with soft links to the same sidebar.php file.  I&#8217;ll also need to tweak some a bit for the category/technorati tags to come out right and such.  But this is fun&#8230;</p>
<p>Okay, enough lunch time play&#8230;back to work!</p>
<hr/>Copyright &copy; 2010 <strong><a href="http://www.digitalramble.com">Digital Ramble</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact legal@www.digitalramble.com so we can take legal action immediately.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.digitalramble.com/2006/06/16/43/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>anatomy of a new plugin</title>
		<link>http://www.digitalramble.com/2006/06/06/34/</link>
		<comments>http://www.digitalramble.com/2006/06/06/34/#comments</comments>
		<pubDate>Tue, 06 Jun 2006 23:45:22 +0000</pubDate>
		<dc:creator>Cindy</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[favicon]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.digitalramble.com/2006/06/06/34/</guid>
		<description><![CDATA[Update:
Italian translation appended 31 Oct 06
English
Overview
Well I dove deeper into the WordPress documentation since this plugin I wanted to do several things with this one:  I wanted it to have an administration panel to enter information, and I did NOT want to make anyone using the plugin have to do anything more than set [...]]]></description>
			<content:encoded><![CDATA[<p>Update:<br />
Italian translation <a href="#italian">appended</a> 31 Oct 06</p>
<h2>English</h2>
<h3>Overview</h3>
<p>Well I dove deeper into the WordPress documentation since this plugin I wanted to do several things with this one:  I wanted it to have an administration panel to enter information, and I did NOT want to make anyone using the plugin have to do anything more than set options through the panel.  In other words, no more code tweaking.  </p>
<p>Several reasons for that.  In the first place, not everyone using WordPress is a geeky hacker like myself.  In the second place, it&#8217;s annoying even for a geeky hacker like myself to move around themes or update WordPress and have to re-do all the little hacks and edits.  So I&#8217;m becoming a bigger fan of plug&#8217;n'play plugins.</p>
<p>Now to be fair, this isn&#8217;t always avoidable.  In particular, sidebar elements aren&#8217;t easily hooked in (I think this is the idea behind the sidebar widgets project, but I haven&#8217;t looked deeply enough into that to be sure).  But I&#8217;ve already seen some interesting workarounds by other plugin authors and I think it&#8217;s possible to avoid many of these problems.</p>
<p>In any case, this plugin is about favicons.  Here was my wish list:</p>
<ol>
<li>To enter an arbitrary image for the favicon
<li>Specify the image relevant to my WordPress directory or as absolute URI
<li>To change it whenever I wanted
<li>To use gif/icon/png files for the favicon
<li>Optionally use it in my rss2 feed
<li>Optionally use it in my atom feed
<li>Everything configurable from the admin panel
<li>A &#8220;plug and play&#8221; plugin &#8212; install and activate, nothing more
</ol>
<p>To my surprise, this was pretty easy.  Perhaps an hour or so of reading the relevant documentation, about 15 minutes coding, another hour or so testing it, and about two hours of writing up and documentation. <img src='http://www.digitalramble.com/wordpress/smilies/yahoo_bigsmile.gif' alt='&#58;&#45;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#45;&#68;' />  That&#8217;s a pretty typical ratio&#8230;</p>
<p><b>Update:</b> the completed plugin is available at http://www.digitalramble.com/favicon-manager-wordpress-plugin/ (take a peek at the sidebar).</p>
<h3>Header Hooks</h3>
<p>In order to add something to the headers, without requiring the user to edit their WordPress files, you use<br />
<pre><code>
// insert favicon into header using hooks
add_action(&#039;wp_head&#039;, &#039;add_favicon_to_headers&#039;);
</code></pre><br />
where <code>add_favicon_to_headers</code> is a simple parameterless function that prints out what you want added into the headers.  It&#8217;s that simple.  The first cut at the function does what it&#8217;s supposed to do, upon testing:<br />
<pre><code>
function add_favicon_to_headers()
{
&nbsp;&nbsp;$favicon_location=&quot;http://example.com/example.ico&quot;;
&nbsp;&nbsp;$favicon_type=&quot;x-icon&quot;;
&nbsp;&nbsp;print &#039; &lt;link rel=&quot;icon&quot; href=&quot;&#039;. $favicon_location .&#039;&quot; type=&quot;image/&#039;. $favicon_type .&#039;&quot; /&gt;&#039;;
&nbsp;&nbsp;print &quot;\n&quot;;
&nbsp;&nbsp;print &#039; &lt;link rel=&quot;shortcut icon&quot; href=&quot;&#039;. $favicon_location .&#039;&quot; type=&quot;image/&#039;. $favicon_type .&#039;&quot; /&gt;&#039;;
&nbsp;&nbsp;print &quot;\n&quot;;
}
</code></pre><br />
Of course this is only the first crack at it, just to make sure it works.  As it does indeed, if you were to drop the above (encapsulated in the &lt;?php enclosures and with a correct location other than example.ico) into a file with the .php extenstion into your plugin directory.  There is in fact a very simple favicon plugin out there that <a target="window" href="http://benjoblog.weblogs.us/category/software/wordpress-plugins/">does just that</a> but of course it&#8217;s not configurable as per my wish list <img src='http://www.digitalramble.com/wordpress/smilies/yahoo_wink.gif' alt='&#59;&#45;&#41;' class='wp-smiley' width='18' height='18' title='&#59;&#45;&#41;' />.</p>
<h3>Database</h3>
<p>In order to have persistent, retrievable values, I had to make use of the database utilities offered in WordPress.  There&#8217;s <code>add_option</code>, <code>update_option</code> and <code>get_option</code> for a very simple interface.  So I make sure there&#8217;s a database entry for the favicon&#8217;s location:<br />
<pre><code>
// add the saved items to the database if not already there
function favicon_mgr_add_options()
{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add_option(&#039;fm_favicon_location&#039;, &#039;&#039;);
}

favicon_mgr_add_options();
</code></pre><br />
At this point the database now has a new item with an empty string value for this plugin to use.  I tried to use long descriptive names to reduce the possibliity of name space collision.  It would have been easier on my fingers to just use &#8220;favicon&#8221; but of course the possiblity is higher that sooner or later it will run into someone else with the same brilliant idea.</p>
<p>This means that the hook should now retrieve the value from the database:<br />
<pre><code>
function add_favicon_to_headers()
{
&nbsp;&nbsp;$favicon_location=get_option(&#039;fm_favicon_location&#039;);
&nbsp;&nbsp;$favicon_type=get_favicon_type($favicon_location);
&nbsp;&nbsp;print &#039; &lt;link rel=&quot;icon&quot; href=&quot;&#039;. $favicon_location .&#039;&quot; type=&quot;image/&#039;. $favicon_type .&#039;&quot; /&gt;&#039;;
&nbsp;&nbsp;print &quot;\n&quot;;
&nbsp;&nbsp;print &#039; &lt;link rel=&quot;shortcut icon&quot; href=&quot;&#039;. $favicon_location .&#039;&quot; type=&quot;image/&#039;. $favicon_type .&#039;&quot; /&gt;&#039;;
&nbsp;&nbsp;print &quot;\n&quot;;
}
</code></pre><br />
Now you see why I used variables to begin with <img src='http://www.digitalramble.com/wordpress/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' />.  The <code>get_favicon_type</code> is another function I wrote (but didn&#8217;t include for clarity above) that returns the correct type (x-icon, gif, jpg, png) depending on the favicon&#8217;s name.  So now I&#8217;m set regardless of what the user enters (I do need to add a check in case the extension is unknown, but again I&#8217;m keeping things as short as I can).</p>
<h3>Admin panel</h3>
<p>Wordpress also provides a pretty straightforward set of functions for creating an admin panel.   It was actually pretty easy.  First there&#8217;s the hook to put a new menu item under Options (you can do more, but for basic stuff like this, Option&#8217;s fine).</p>
<p><pre><code>
// create hook for new submenu
add_action(&#039;admin_menu&#039;, &#039;favicon_mgr_admin_menu&#039;);

// title of page, name of option in menu bar, which function lays out the html
function favicon_mgr_admin_menu()
{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add_options_page(__(&#039;Favicon Manager Options&#039;), __(&#039;Favicons&#039;), 5, basename(__FILE__), &#039;favicon_mgr_options_page&#039;);
}

// html layout for option page, plus detection/update on new settings
function favicon_mgr_options_page()
{
&nbsp;&nbsp;...
}
</code></pre></p>
<p>So what this all does is first a menu item is added in.  The menu item in turn specifies the function that lays out its page.  So then that function prints out the html necessary to allow input, etc.  That page will also have to update the database entries so that the header  hook retrieves the correct value to drop into the headers.  So it&#8217;s starting to come together.  Here&#8217;s the first cut at the options page:</p>
<p><pre><code>
function favicon_mgr_options_page()
{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$updated = false;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (isset($_POST[&#039;fm_favicon_location&#039;]))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$fm_favicon_location = $_POST[&#039;fm_favicon_location&#039;];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;update_option(&#039;fm_favicon_location&#039;, $fm_favicon_location);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$updated = true;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$fm_favicon_location = get_option(&#039;fm_favicon_location&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($updated)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&quot;updated&quot;&gt;&lt;p&gt;&lt;strong&gt;Options saved.&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

</code></pre><br />
Let&#8217;s take the pause that refreshes.  Remember that this page can be used when the user first enters the option page, or after they&#8217;ve hit the submit button.  So the first thing to check is to see if this is on submission.  <code>isset</code> provides a way of checking to see if that form input element has been set or not.  If it has, I drop it into the database, and set update to true.<br />
<pre><code>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&quot;wrap&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h2&gt;Favicon Settings&lt;/h2&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;&lt;?php echo $_SERVER[&#039;REQUEST_URI&#039;]; ?&gt;&quot;&gt;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;fieldset class=&quot;options&quot;&gt;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;legend&gt;Favicon in WordPress Pages&lt;/legend&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;table width=&quot;100%&quot; cellspacing=&quot;2&quot; cellpadding=&quot;5&quot; class=&quot;editform&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr valign=&quot;top&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;? php
}
</code></pre><br />
This part prints out the actual form page, with values in the input field if any exist.  The layout is already controlled via the stylesheets and classes used here, so the familiar blue and white theme layout comes right up.</p>
<p>That&#8217;s it!  Pretty much the only items left are the arbitrary or relative locations for the favicon (I want the users to be able to enter the location either way) and the RSS2/Atom options.  The former is easily resolved with one more function:<br />
<code></code><br />
And now I update instances where I get the favicon_location to run the results through this before using it.  I do not use this before storing the location into the database, though.  To avoid user confusion, I prefer to retain what they actually entered.</p>
<h3>The Feed Options</h3>
<p>I&#8217;m only going to describe the RSS2 additions here.  The Atom is exactly the same other than the actual output in the hook.</p>
<p>As of WordPress 2.0, hooks are provided for RSS2:<br />
<pre><code>
function add_image_to_rss2_feed()
{
&nbsp;&nbsp;// do this or not depending on user settings in panel!
&nbsp;&nbsp;if (get_option(&#039;fm_rss2_feed_option&#039;)==&quot;Y&quot;)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$favicon_location=create_favicon_uri(get_option(&#039;fm_favicon_location&#039;));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;image&gt;\n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&nbsp;&nbsp;&lt;link&gt;&quot;. get_bloginfo_rss(&#039;url&#039;) .&quot;&lt;/link&gt;\n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&nbsp;&nbsp;&lt;url&gt;&quot;. $favicon_location .&quot;&lt;/url&gt;\n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&nbsp;&nbsp;&lt;title&gt;&quot;. get_bloginfo_rss(&#039;name&#039;) .&quot;&lt;/title&gt;\n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;/image&gt;\n&quot;;
&nbsp;&nbsp;}
}

// insert image into rss2 feed
add_action(&#039;rss2_head&#039;, &#039;add_image_to_rss2_feed&#039;);
</code></pre><br />
So now I add it to my database:<br />
<pre><code>
// add the saved items to the database if not already there
function favicon_mgr_add_options()
{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add_option(&#039;fm_favicon_location&#039;, &#039;&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add_option(&#039;fm_rss2_feed_option&#039;, &#039;&#039;);
}
</code></pre><br />
This gets added to the option page function before printing out whether or not new options have been saved:<br />
<pre><code>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// checkboxes flip on/off
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($_POST[&#039;fm_rss2_feed_option&#039;]!=get_option(&#039;fm_rss2_feed_option&#039;))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$fm_rss2_feed_option = $_POST[&#039;fm_rss2_feed_option&#039;];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;update_option(&#039;fm_rss2_feed_option&#039;, $fm_rss2_feed_option);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$updated = true;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$fm_rss2_feed_option = get_option(&#039;fm_rss2_feed_option&#039;);
</code></pre><br />
The checkboxes work a little bit differently than text input boxes.  If you uncheck a checkbox, you do NOT get input.  Since this is an on/off switch, the fix is to simple check if the value is the same as what is stored since only two values are possible.</p>
<p>Now I add in the bit of HTML to ask the user to check off whether they want the favicon added to their RSS2 feed:<br />
<pre><code>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;legend&gt;Images in Feeds&lt;/legend&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;table width=&quot;100%&quot; cellspacing=&quot;2&quot; cellpadding=&quot;5&quot; class=&quot;editform&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr valign=&quot;top&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/table&gt;
</code></pre><br />
This is put into the fieldset wrapper of the options page.</p>
<p>Atom is identical, but the image is added through an <code>&amp;lt;icon&amp;gt;</code> marker and the value is simply the location of the favicon.</p>
<p>The feed images are handled a little differently from the header favicons.  They don&#8217;t actually have to be 16&#215;16, they can be a little bit larger.  Traditionally they appear along the header field in an aggregator, and if you look at a wunderground.com weather feed in Bloglines, you&#8217;ll notice a relatively large rainstorm/weather icon at the top of its articles.  But (using Bloglines for reference again), the images can also be used on the left in Blogline&#8217;s &#8220;bookmarks&#8221; tree.  It may be worthwhile giving an optional image field for the feeds: if it&#8217;s left empty use the favicon, otherwise use the image for the feeds only.  I haven&#8217;t decided&#8230;  </p>
<h3>Support Files</h3>
<p>Although the code is written up and tested, I&#8217;m not yet finished.  I need to put together a couple more things:</p>
<ul>
<li>A readme.txt file to be bundled with the favicon manager php file
<li>A zipped version with the correct directory, etc to be put out in the public directory
<li>A help/support page where potential users can read about the plugin, find directions for installing, and find the bundle itself
</ul>
<p>There&#8217;s a few other more optional actions to take as well, such as whether to register the plugin with Codex, WP Plugins Database, and other forums that collect plugin info.</p>
<h3>Some Thoughts</h3>
<p>I might be able to make this plugin work for earlier versions of WordPress by protecting the feed options with a check for the existence of the feed hooks.  If they&#8217;re not there, then skip all the feed elements.  Thus the plugin would degrade to favicons-in-headers-only mode, provided none of the other function calls or hooks have changed substantially.  But given that I have written this well after the 2.0 upgrade, I&#8217;m not particularly inclined to do this&#8230;especially since I don&#8217;t have the means for testing it anyway.</p>
<h2>Italian</h2>
<p><a name="italian"></a></p>
<h3>Panoramica</h3>
<p>Ho scavato più in profondità nella documentazione di WordPress, perchè volevo che il mio plugin rispettasse alcuni criteri: volevo che avesse un pannello di amministrazione perchè NON volevo che chiunque lo usasse fosse obbligato a fare altro che impostare opzioni tramite il pannello. In altre parole, basta modifiche al codice.</p>
<p>Diverse ragioni per questo. Primo, non tutti gli utenti WordPress sono smanettoni come me. Secondo, è noioso anche per gli smanettoni come me cambiare temi o aggiornare WordPress e dover riapplicare tutte le piccole modifiche. Per questo motivo sto diventando la più grande fan dei plugin plug’n&#8217;play.</p>
<p>Per essere onesti, non sempre questo è evitabile. In particolare, gli elementi delle barre laterali non sono facilmente integrabili (credo sia questa l’idea alle spalle dei widget, ma non ho ancora approfondito abbastanza da esserne certa). In ogni caso ho già visto diversi metodi interessanti nel lavoro di altri autori di plugin, e credo sia possibile evitare molti di questi problemi.</p>
<p>Comunque sia, questo plugin riguarda le favicons. Questa era la mia lista dei desideri:</p>
<ol>
<li>Poter inserire una immagine arbitraria come favicon</li>
<li>Poter specificare l’immagine rilevante nella mia cartella WordPress anzichè come URI assoluta.</li>
<li>Poter modificare questa immagine in qualunque momento.</li>
<li>Poter usare files gif/icon/png per la favicon</li>
<li>Eventualmente usare l’immagine nel mio feed rss2</li>
<li>Eventualmente usare l’immagine nel mio feed atom</li>
<li>Tutto questo configurabile nel pannello di amministrazione</li>
<li>Un plugin “plug and play” &#8211; da installare e attivare, null’altro.</li>
</ol>
<p>Con mia sorpresa, questo è stato abbastanza semplice. Più o meno un ora per leggere la documentazione rilevante, circa 15 minuti per programmare, un’altra ora per il collaudo, e quasi due ore di scrittura e documentazione <img src='http://www.digitalramble.com/wordpress/smilies/yahoo_bigsmile.gif' alt='&#58;&#45;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#45;&#68;' /> Questa è un proporzione abbastanza tipica…</p>
<p>Il plugin completo è disponibile all’indirizzo<br />
http://www.digitalramble.com/favicon-manager-wordpress-plugin/<br />
(date un’occhiata sul lato).</p>
<h3>Agganci agli header</h3>
<p>Per aggiungere qualcosa agli header, senza obbligare l’utente a modificare i propri files di WordPress, potete usare</p>
<p><pre><code>
// insert favicon into header using hooks
add_action(&#039;wp_head&#039;, &#039;add_favicon_to_headers&#039;);
</code></pre></p>
<p>dove add_favicon_to_headers è una semplice funzione senza parametri che inserisce ciò che volete all’interno degli header. E’ molto semplice. La prima bozza della funzione è in grado di fare ciò che vorremmo facesse, durante i test:</p>
<p><pre><code>
function add_favicon_to_headers()
{
&nbsp;&nbsp;$favicon_location=&quot;http://example.com/example.ico&quot;;
&nbsp;&nbsp;$favicon_type=&quot;x-icon&quot;;
&nbsp;&nbsp;print &#039; &lt;link rel=&quot;icon&quot; href=&quot;&#039;. $favicon_location .&#039;&quot; type=&quot;image/&#039;. $favicon_type .&#039;&quot; /&gt;&#039;;
&nbsp;&nbsp;print &quot;n&quot;;
&nbsp;&nbsp;print &#039; &lt;link rel=&quot;shortcut icon&quot; href=&quot;&#039;. $favicon_location .&#039;&quot; type=&quot;image/&#039;. $favicon_type .&#039;&quot; /&gt;&#039;;
&nbsp;&nbsp;print &quot;n&quot;;
}
</code></pre></p>
<p>Ovviamente questa è solo una prima stesura, giusto per essere certi che funzioni. E può funzionare, se inserite il codice qui sopra (all’interno dei codici ?php e con un indirizzo corretto al posto di example.ico) in un file con estensione .php nella vostra cartella dei plugin. Esiste infatti un semplice favicon plugin che fa esattamente questo ma non è configurabile come ho detto nella mia lista dei desideri <img src='http://www.digitalramble.com/wordpress/smilies/yahoo_wink.gif' alt='&#59;&#45;&#41;' class='wp-smiley' width='18' height='18' title='&#59;&#45;&#41;' /></p>
<h3>Database</h3>
<p>Per avere valori persistenti e recuperabili, ho dovuto fare uso delle utilità a livello database offerte in WordPress. Ci sono add_option, update_option e get_option per un interfacciamento semplice. Quindi farò in modo di verificare che sia presente un dato nel database con l’indirizzo della favicon:</p>
<p><pre><code>
// add the saved items to the database if not already there
function favicon_mgr_add_options()
{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add_option(&#039;fm_favicon_location&#039;, &#039;&#039;);
}

favicon_mgr_add_options();
</code></pre></p>
<p>A questo punto il database ha ora un nuovo elemento, con un valore vuoto (una stringa di testo) disponibile per questo plugin. Ho provato a usare nomi lunghi e descrittivi (nelle funzioni, N.d.T.) per ridurre l’eventualità di una collisione di name space. Sarebbe stato più semplice per le mie dita usare solo “favicon”, ma ovviamente sarebbe stata più alta la possibilità che qualcuno abbia avuto prima o poi la mia stessa brillante idea.</p>
<p>Questo significa che l’aggancio ora può recuperare valori dal database:</p>
<p><pre><code>
function add_favicon_to_headers()
{
&nbsp;&nbsp;$favicon_location=get_option(&#039;fm_favicon_location&#039;);
&nbsp;&nbsp;$favicon_type=get_favicon_type($favicon_location);
&nbsp;&nbsp;print &#039; &lt;link rel=&quot;icon&quot; href=&quot;&#039;. $favicon_location .&#039;&quot; type=&quot;image/&#039;. $favicon_type .&#039;&quot; /&gt;&#039;;
&nbsp;&nbsp;print &quot;n&quot;;
&nbsp;&nbsp;print &#039; &lt;link rel=&quot;shortcut icon&quot; href=&quot;&#039;. $favicon_location .&#039;&quot; type=&quot;image/&#039;. $favicon_type .&#039;&quot; /&gt;&#039;;
&nbsp;&nbsp;print &quot;n&quot;;
}
</code></pre></p>
<p>Ora potete vedere perchè ho usato le variabili fino ad ora <img src='http://www.digitalramble.com/wordpress/smilies/yahoo_smiley.gif' alt='&#58;&#45;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#45;&#41;' />. La funzione get_favicon_type è un’altra funzione che ho scritto (e non ho incluso sopra per chiarezza) che restituisce il tipo corretto (x-icon, gif, jpg, png) a seconda del nome della favicon. In questo modo la funzione è pronta qualunque sia l’input dell’utente (dovrei aggiungere un controllo nel caso l’estensione sia sconosciuta, ma ancora una volta sto cercando di rendere le cose più semplici possibile).</p>
<h3>Pannello di amministrazione</h3>
<p>WordPress offre anche un set diretto di funzioni per crare un pannello di amministrazione. E’ stato decisamente semplice. Per prima cosa è presente un aggancio per inserire un nuovo menù sotto il menu Opzioni (potete fare anche altro, ma per cose basilari come queste, Opzioni è più che sufficiente).</p>
<p><pre><code>
// create hook for new submenu
add_action(&#039;admin_menu&#039;, &#039;favicon_mgr_admin_menu&#039;);

// title of page, name of option in menu bar, which function lays out the html
function favicon_mgr_admin_menu()
{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add_options_page(__(&#039;Favicon Manager Options&#039;), __(&#039;Favicons&#039;), 5, basename(__FILE__), &#039;favicon_mgr_options_page&#039;);
}

// html layout for option page, plus detection/update on new settings
function favicon_mgr_options_page()
{
&nbsp;&nbsp;...
}
</code></pre></p>
<p>Quindi, tutto ciò che questo produce è l’inserimento di un oggetto menu. L’oggetto specifica a sua volta la funzione che definirà la pagina. Quindi, la funzione inserirà il codice necessario a permettere gli input e il resto. Questa pagina dovrà inoltre poter aggiornare i record nel database in modo che gli agganci della testata possano ricevere i valori corretti da inserire nella stessa. In questo modo le cose iniziano a essere collegate. Una prima stesura della pagina di opzioni:</p>
<p><pre><code>
function favicon_mgr_options_page()
{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$updated = false;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (isset($_POST[&#039;fm_favicon_location&#039;]))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$fm_favicon_location = $_POST[&#039;fm_favicon_location&#039;];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;update_option(&#039;fm_favicon_location&#039;, $fm_favicon_location);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$updated = true;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$fm_favicon_location = get_option(&#039;fm_favicon_location&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($updated)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&quot;updated&quot;&gt;
&lt;strong&gt;Options saved.&lt;/strong&gt;&lt;/div&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
</code></pre></p>
<p>Prendiamo una pausa rinfrescante. Ricordiamoci che questa pagina verrà mostrata solo quando l’utente entrerà nella pagina di opzioni, oppure dopo aver modificato le opzioni stesse. Quindi la prima cosa da verificare è se l’elemento input del modulo è stato modificato o meno. Nel primo caso, verrà inserito nel database, e verrà impostato update su true.</p>
<p><pre><code>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&quot;wrap&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h2&gt;Favicon Settings&lt;/h2&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;&lt;?php echo $_SERVER[&#039;REQUEST_URI&#039;]; ?&gt;&quot;&gt;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;fieldset class=&quot;options&quot;&gt;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;legend&gt;Favicon in WordPress Pages&lt;/legend&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;table width=&quot;100%&quot; cellspacing=&quot;2&quot; cellpadding=&quot;5&quot; class=&quot;editform&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr valign=&quot;top&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;th width=&quot;33%&quot; scope=&quot;row&quot;&gt;Location:&lt;/th&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;input name=&quot;fm_favicon_location&quot; type=&quot;text&quot; width=&quot;60&quot; value=&quot;&lt;?php echo $fm_favicon_location; ?&gt;&quot;/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/td&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;? php
</code></pre></p>
<p>Questa parte restituisce la pagina del modulo, con i valori nel campo imput se sono già impostati. La presentazione è già controllata tramite i fogli di stile e le classi usate, quindi verrà usato il familiare tema bianco e blu.</p>
<p>E’ tutto qui! In pratica gli unici elementi non inseriti sono la posizione abitraria o relativa della favicon (voglio che gli utenti abbiano la possibilità di inserire entrambe) e l’opzione RSS2/Atom. La prima è risolta facilmente con una ulteriore funzione:</p>
<p><code></code></p>
<p>Ora aggiornerò le istanze in cui richiamo $favicon_location per processare i risultati tramite questa funzione prima di usarli. Non userò comunque questa funzione prima di memorizzare la posizione nel database. Per evitare confusioni da parte dell’utente, preferisco tenere ciò che hanno inserito.</p>
<h3>L’opzione Feed</h3>
<p>Spiegherò solamente l’aggiunta per RSS, in quanto l’opzione Atom è identica, eccetto l’output nell’aggancio.</p>
<p>A partire da WordPress 2.0, sono forniti agganci per gli RSS2:</p>
<p><pre><code>
function add_image_to_rss2_feed()
{
&nbsp;&nbsp;// do this or not depending on user settings in panel!
&nbsp;&nbsp;if (get_option(&#039;fm_rss2_feed_option&#039;)==&quot;Y&quot;)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$favicon_location=create_favicon_uri(get_option(&#039;fm_favicon_location&#039;));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;image&gt;n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&nbsp;&nbsp;&lt;link&gt;&quot;. get_bloginfo_rss(&#039;url&#039;) .&quot;&lt;/link&gt;n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&nbsp;&nbsp;&lt;url&gt;&quot;. $favicon_location .&quot;&lt;/url&gt;n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&nbsp;&nbsp;&lt;title&gt;&quot;. get_bloginfo_rss(&#039;name&#039;) .&quot;&lt;/title&gt;n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&lt;/image&gt;n&quot;;
&nbsp;&nbsp;}
}

// insert image into rss2 feed
add_action(&#039;rss2_head&#039;, &#039;add_image_to_rss2_feed&#039;);
</code></pre></p>
<p>Quindi inserirò nel mio database:</p>
<p><pre><code>
// add the saved items to the database if not already there
function favicon_mgr_add_options()
{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add_option(&#039;fm_favicon_location&#039;, &#039;&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add_option(&#039;fm_rss2_feed_option&#039;, &#039;&#039;);
}
</code></pre></p>
<p>Questo verrà aggiunto alla pagina di opzioni prima dell’output, a prescindere dal fatto che le nuove opzioni siano già salvate.</p>
<p><pre><code>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// checkboxes flip on/off
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($_POST[&#039;fm_rss2_feed_option&#039;]!=get_option(&#039;fm_rss2_feed_option&#039;))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$fm_rss2_feed_option = $_POST[&#039;fm_rss2_feed_option&#039;];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;update_option(&#039;fm_rss2_feed_option&#039;, $fm_rss2_feed_option);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$updated = true;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$fm_rss2_feed_option = get_option(&#039;fm_rss2_feed_option&#039;);
</code></pre></p>
<p>Le caselle di selezione funzionano in modo leggermente differente dai campi di input testuale. Se deselezionate una casella, NON avrete un input. Dal momento che è un selettore acceso/spento, la soluzione è controllare se il valore è lo stesso di quello memorizzato, dal momento che solo due valori sono possibili.</p>
<p>Ora aggiungerò del codice HTML per chiedere all’utente di scegliere se usare la favicon nei propri feed RSS2:</p>
<p><pre><code>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;legend&gt;Images in Feeds&lt;/legend&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;table width=&quot;100%&quot; cellspacing=&quot;2&quot; cellpadding=&quot;5&quot; class=&quot;editform&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr valign=&quot;top&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;th width=&quot;33%&quot; scope=&quot;row&quot;&gt;Add to RSS2 Feed?&lt;/th&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;input name=&quot;fm_rss2_feed_option&quot; type=&quot;checkbox&quot; value=&quot;Y&quot; &lt;?php if ($fm_rss2_feed_option==&quot;Y&quot;) echo &quot;checked&quot;; ?&gt; &gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/td&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/table&gt;
</code></pre></p>
<p>Questo è inserito nel contenitore fieldset della pagina di opzioni.</p>
<p>Atom è identico, ma l’immagine è inserita tramite un tag e il valore è semplicemente l’indirizzo della favicon.</p>
<p>Le immagini dei feed sono gestite in modo differente dalle favicon della testata. Non devono essere per forza 16×16, ma possono essere un po’ più grandi. Di solito appaiono accanto al campo della testata in un aggregatore, e se date un’occhiata al feed delle previsioni del tempo su Bloglines, potrete notare una icona relativamente grande in cima ai suoi articoli. Ma (usando per esempio ancor Bloglines), le immagini possono anche essere usate sulla destra, nei bookmarks di Bloglines (le informazioni su Bloglines possono essere variate, N.d.T. ). Può valere la pena offrire un campo opzionale per l’immagine dei feed: se è lasciato vuoto verrà usata la favicon, altrimenti verrà usata questa immagine solo per i feed. Non ho ancora deciso…</p>
<p>Files di supporto</p>
<p>Anche se il codice è scritto e collaudato, non ho ancora finito. Devo aggiungere a questo alcune cose:</p>
<p>    * Un file readme.txt da allegare con il file php del plugin<br />
    * Una versione compressa con le cartelle e i files corretti da mettere nella mia cartella pubblica<br />
    * Una pagina di aiuto e supporto dove i potenziali utenti potranno trovare informazioni sul plugin, istruzioni per l’installazione, e dove sarà disponibile l’archivio stesso.</p>
<p>Ci sono alcune azioni facoltative che potreste voler intraprendere, come registrare il plugin su Codex, nel database dei plugin WP, e in altri forum che raccolgono informazioni sui plugin.</p>
<p>Alcuni pensieri</p>
<p>Potrei essere in grado di rendere questo plugin funzionante con versioni precedenti di WordPress, proteggendo l’opzione dei feed con un controllo sulll’esistenza dell’aggancio ai feed. Se non è presente, allora evita tutti gli elementi feed. In questo modo il plugin dovrebbe degradare in modalità favicon-solo-header, tenendo conto che nessuna delle altre funzioni è stata modificata. Ma dato che ho scritto questo ben dopo l’aggiornamento alla versione 2.0, non sono particolarmente invogliata a farlo… specialmente visto che non ho i mezzi necessari per fare i test.</p>
<hr/>Copyright &copy; 2010 <strong><a href="http://www.digitalramble.com">Digital Ramble</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact legal@www.digitalramble.com so we can take legal action immediately.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.digitalramble.com/2006/06/06/34/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>
