<?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>Ordo Ab Chao - Il blog di Rocco Agostino &#187; WordPress</title>
	<atom:link href="http://blog.roccoagostino.eu/category/informatica/wordpress-informatica/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.roccoagostino.eu</link>
	<description>Il mio blog personale in cui si discute di libri,musica,scrittura,poesia,video,foto,news,attualità,informatica e tecnologia. Un &#34;corner&#34; da condividere con voi che commentate,criticate o apprezzate.</description>
	<lastBuildDate>Fri, 18 Nov 2011 05:48:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<atom:link rel='hub' href='http://blog.roccoagostino.eu/?pushpress=hub'/>
		<item>
		<title>Personalizzare i commenti nidificati in WordPress</title>
		<link>http://blog.roccoagostino.eu/2011/11/06/personalizzare-i-commenti-nidificati-in-wordpress/</link>
		<comments>http://blog.roccoagostino.eu/2011/11/06/personalizzare-i-commenti-nidificati-in-wordpress/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 05:55:36 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[funzioni]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[thumbnail]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=910</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/>WordPress dalla versione 2.7 supporta il threading dei commenti, ovvero l’incapsulamento di tutte le discussioni di un articolo. Il tag wp_list_comments() si prende carico della gestione delle liste nidificate, delle classi associate ad ogni livello di commento, di predisporre i link giusti e di recuperare i contenuti dei commenti. Il problema nasce quando si vuole personalizzare la modalità di visualizzazione dei commenti. In questo caso è necessario utilizzare l'opzione di callback che viene fornito nella lista degli argomenti di wp_list_comments().]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/><p>WordPress dalla versione 2.7 supporta il threading dei commenti, ovvero l’incapsulamento di tutte le discussioni di un articolo. Il tag <em>wp_list_comments()</em> si prende carico della gestione delle liste nidificate, delle classi associate ad ogni livello di commento, di predisporre i link giusti e di recuperare i contenuti dei commenti. Il problema nasce quando si vuole personalizzare la modalità di visualizzazione dei commenti. In questo caso è necessario utilizzare l&#8217;opzione di callback che viene fornito nella lista degli argomenti di <em>wp_list_comments()</em>.</p>
<p><span id="more-910"></span></p>
<p>Un callback è un&#8217;istruzione per eseguire un&#8217;altra funzione definita. Nel nostro caso la useremo per personalizzare il codice HTML dei commenti, pur mantenendo la possibilità di utilizzare il threading.<br />
&nbsp;</p>
<h1>Definiamo il callback</h1>
<p>&nbsp;<br />
Per prima cosa definiamo la nostra funzione di callback ed inseriamola nel file <em>function.php</em> (ovviamente ricordatevi si fare una copia di backup).<br />
&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">function miotema_comment($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment;
?&gt;
	&lt;li <span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> id=&quot;li-comment-<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
		&lt;div id=&quot;comment-<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
			&lt;div class=&quot;comment-author vcard&quot;&gt;
				<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> get_avatar<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_author_email</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">48</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;cite class=&quot;fn&quot;&gt;%s&lt;/cite&gt; &lt;span class=&quot;says&quot;&gt;says:&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> get_comment_author_link<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;/div&gt;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_approved</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				&lt;em&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Il tuo commento è in attesa di moderazione.'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/em&gt;
				&lt;br /&gt;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
			&lt;div class=&quot;comment-meta commentmetadata&quot;&gt;
				&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span> get_comment_link<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_ID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%1$s at %2$s'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> get_comment_date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>  get_comment_time<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;
				<span style="color: #000000; font-weight: bold;">&lt;?php</span> edit_comment_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'(Edit)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'  '</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;/div&gt;
                        &lt;/br&gt;&lt;/br&gt;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_text<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;div class=&quot;reply&quot;&gt;
				<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_reply_link<span style="color: #009900;">&#40;</span><span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'depth'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$depth</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'max_depth'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max_depth'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;/div&gt;
		&lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>&nbsp;<br />
Vediamo quale funzione entra in gioco.<br />
&nbsp;<br />
<span style="color: #ff0000;"><em>comment_class()</em></span><br />
Questa funzione crea un elenco di classi come class = &#8220;classe1 class2 class3&#8243; per identificare i commenti pari/dispari, la profondità attuale dei commenti o altro.<br />
&nbsp;<br />
<span style="color: #ff0000;"><em>comment_ID()</em></span><br />
L&#8217;ID è il numero univoco del commento in corso.<br />
&nbsp;<br />
<span style="color: #ff0000;"><em>get_avatar()</em></span><br />
Utilizza l&#8217;e-mail per associare un gravatar. Primo parametro deve essere l&#8217;oggetto $ comment, il secondo è il formato per l&#8217;avatar, l&#8217;ultimo è l&#8217;URL di un avatar di default (deve essere URL completo).<br />
&nbsp;<br />
<span style="color: #ff0000;"><em>get_comment_link()</em></span><br />
Ottiene il link al commento in corso.<br />
&nbsp;<br />
<span style="color: #ff0000;">edit_comment_link()</span><br />
Ottiene il link per modificare il commento corrente.<br />
&nbsp;<br />
<span style="color: #ff0000;"><em>comment_text()</em></span><br />
Ottiene il testo del il commento in corso.<br />
&nbsp;<br />
<span style="color: #ff0000;"><em>comment_reply_link()</em></span><br />
Ottiene il link per rispondere al commento in corso.<br />
&nbsp;</p>
<h1>Agganciamo la nostra funzione</h1>
<p>&nbsp;<br />
Il layout che andiamo a ridefinire è quello generato proprio da <em>wp_list_comments()</em>. Per fare ciò è sufficiente fornire il parametro “callback=nome_funzione” per indicare a WordPress di ignorare il normale comportamento della funzione e utilizzare invece una nostra versione personalizzata.<br />
&nbsp;<br />
Nel nostro file comments.php andiamo dunque a modificare <em>wp_list_comments()</em> in questo modo:<br />
&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">wp_list_comments <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'callback=miotema_comment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&nbsp;<br />
Ovviamente è possibile utilizzare un foglio di stile CSS per rendere i commenti gradevoli da vedere:  per esempio io ho utilizzato <a title="CSS Triangle Arrow DIVs" href="http://www.dynamicdrive.com/style/csslibrary/item/css_triangle_arrow_divs/" target="_blank">questo metodo</a> e questo è il risultato:<br />
&nbsp;<br />
<a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/11/commenti.png"><img class="aligncenter size-full wp-image-911" title="commenti" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/11/commenti.png" alt="" width="500" height="522" /></a><br />
&nbsp;<br />
<strong>Tutto qui. Come sempre lasciate dei commenti o magari mandatemi una e-mail. Anche eventuali suggerimenti o consigli sono sempre graditi.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2011/11/06/personalizzare-i-commenti-nidificati-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thumbnails per WordPress.com Popular Posts</title>
		<link>http://blog.roccoagostino.eu/2011/10/23/thumbnails-per-wordpress-com-popular-posts/</link>
		<comments>http://blog.roccoagostino.eu/2011/10/23/thumbnails-per-wordpress-com-popular-posts/#comments</comments>
		<pubDate>Sun, 23 Oct 2011 17:49:58 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[In evidenza]]></category>
		<category><![CDATA[Informatica]]></category>
		<category><![CDATA[Sviluppo WEB]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[funzioni]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[thumbnail]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[WordPress.com Popular Posts]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=829</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/css_ico.JPG" width="32" height="32" alt="" title="Sviluppo WEB" /><img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/>Modifica del plugin WordPress.com Popular Posts per inserire nella lista degli articoli più popolari, la thumbnail associata al post.]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/css_ico.JPG" width="32" height="32" alt="" title="Sviluppo WEB" /><img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/><p>Per la visualizazione degli articoli più popolari uso il plugin <a href="http://wordpress.org/extend/plugins/wordpress-popular-posts/" target="_blank">WordPress.com Popular Post</a>. Tale plugin permette molte personalizzazioni, ma manca la possibilità di poter visualizzare le immagini riferite ai post. L&#8217;idea di fondo parte da <a href="http://www.geoffblog.com/2010/07/thumbnails-for-wordpresscom-popular.html" target="_blank">questo articolo</a> che spiega come aggiungere delle immagini all&#8217;elenco dei post con l&#8217;ausilio di uno script esterno. Senza utilizzare script esterni, possiamo, invece, sfruttare le <a href="http://blog.roccoagostino.eu/2011/10/06/modificare-il-tema-di-wordpress-parte-1-la-funzione-post-thumbnail/" target="_blank">nuove features</a> di WordPress 3.x.<br />
<span id="more-829"></span><br />
Nel momento in cui vogliamo il percorso dell&#8217;immagine associata al post il programma procederà in questo modo:</p>
<ul>
<li>cerca la thumbnail associata al post;</li>
<li>nel caso in cui il tema non supporti tale funzione o non si è inserita in fase di creazione del post, cerca la prima immagine nel post;</li>
<li>nel caso in cui il post non abbia neanche una immagine, me associa una di default.</li>
</ul>
<p>&nbsp;</p>
<p>Vediamo come:</p>
<p>&nbsp;</p>
<h1>1) Modifica del plugin</h1>
<p>&nbsp;</p>
<p>Andando in Plugin-&gt;Editor selezioniamo il plugin WPPP e quindi il file <em>wppp.php</em>.</p>
<p>&nbsp;</p>
<p>Per prima cosa troviamo il codice:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Replace format with data</span>
<span style="color: #000088;">$replace</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'%post_permalink%'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> get_permalink<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_id'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'%post_title%'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> esc_html<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>truncateText<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title_length'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'%post_title_attribute%'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> esc_attr<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_title'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'%post_views%'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> number_format_i18n<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'views'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>e aggiungiamo la seguente riga:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$replace</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'%post_thumb%'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span>return_post_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>A questo punto dobbiamo inserire la funzione <em>return_post_image</em>.</p>
<p>&nbsp;</p>
<h1>2) Modifica del file function.php</h1>
<p>&nbsp;</p>
<p>Nel file <em>function.php</em> aggiungiamo:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
* Capture the first image from the post.
* @global object $post
* @global object $posts
* @return string
*/</span>
<span style="color: #000000; font-weight: bold;">function</span> theme_function_capture_first_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$firstImg</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">,</span> <span style="color: #000088;">$posts</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$firstImg</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #990000;">ob_end_clean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'//i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>post_content<span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$firstImg</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'//i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$p</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>post_content<span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$firstImg</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$firstImg</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ritorna una immagine associata al post: thumb, prima immagine del post, default</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> return_post_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">,</span><span style="color: #000088;">$dim</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$imgpath</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dim</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$dim</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$imgpath</span><span style="color: #339933;">=</span>get_the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dim</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imgpath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$imgpath</span> <span style="color: #339933;">=</span> theme_function_capture_first_image<span style="color: #009900;">&#40;</span>get_post<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imgpath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$imgpath</span> <span style="color: #339933;">=</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_directory'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/images/default_pp.gif'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$imgpath</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;img src=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$imgpath</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; alt=&quot;'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$title</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$imgpath</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>N.B.: Di default la dimensione dell&#8217;imamgine è di 60&#215;60. Nel caso in cui noi volessimo una immagine di dimensione diversa, per esempio 32&#215;32, basta modificare la chiamata alla funzione nel file <em>wppp.php</em> in questo modo:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">replace<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'%post_thumb%'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span>return_post_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">32</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">32</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Un&#8217;altra modifica, in futuro, potrebbe essere fare in modo di passare la dimensione dei thumbs nel momento in cui viene richiamato il plugin.</p>
<p>&nbsp;</p>
<p>A questo punto quando richiamiamo il plugin avremo a possibilità di inserire il tag %post_thumb% che ci darà l&#8217;&lt;img&gt; riferita all&#8217;immagine associata al post.</p>
<p>&nbsp;</p>
<h1>3) il CSS per lo stile</h1>
<p>&nbsp;</p>
<p>Concludiamo con il css per lo stile dell&#8217;elenco dei post, che nel mio caso è:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*Popular Posts*/</span>
&nbsp;
ul<span style="color: #6666ff;">.wppp_list</span> li <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">65px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span> <span style="color: #993333;">outside</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul<span style="color: #6666ff;">.wppp_list</span> img <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">4px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ECEFF5</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Ed ecco il risultato finale:<br />
<a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/ppp.png"><img class="aligncenter size-full wp-image-831" title="ppp" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/ppp.png" alt="" width="378" height="473" /></a></p>
<p>&nbsp;</p>
<p><strong>Enjoy it!</strong></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2011/10/23/thumbnails-per-wordpress-com-popular-posts/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Modificare il tema di WordPress (parte 3): personalizzare l&#8217;intestazione e lo sfondo</title>
		<link>http://blog.roccoagostino.eu/2011/10/17/modificare-il-tema-di-wordpress-parte-3-personalizzare-lintestazione-e-lo-sfondo/</link>
		<comments>http://blog.roccoagostino.eu/2011/10/17/modificare-il-tema-di-wordpress-parte-3-personalizzare-lintestazione-e-lo-sfondo/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 17:16:26 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[funzioni]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[sfondo]]></category>
		<category><![CDATA[testata]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=760</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/>Aggiornando la piattaforma alla versione 3.x di Wordpress, il tema che avete installato precedentemente sicuramente non conterrà le nuove funzioni di personalizzazione dell'intestazione e dello sfondo del blog. Grazie a semplici modifiche ai files del tema è possibile inserire, lato pannello di amministrazione, queste funzioni in modo da modificare l'aspetto del blog senza dover agire sul codice del tema stesso.]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/><p>Aggiornando la piattaforma alla versione 3.x di WordPress, il tema che avete installato precedentemente sicuramente non conterrà le nuove funzioni di personalizzazione dell&#8217;intestazione e dello sfondo del blog. Grazie a semplici modifiche ai files del tema è possibile inserire, lato pannello di amministrazione, queste funzioni in modo da modificare l&#8217;aspetto del blog senza dover agire sul codice del tema stesso.</p>
<p><span id="more-760"></span></p>
<p>&nbsp;</p>
<h1>la Testata</h1>
<p>Tra le novità di WordPress 3.x vi è il pannello per la personalizzazione delle intestazioni. E&#8217; possibile accedere alle intestazioni personalizzate abilitando la voce nel pannello di amministrazione di WordPress 3.x anche se il vostro tema non lo supporta nativamente.<br />
Per fare ciò basta inserire nel file <em>function.php</em> le seguenti linee di codice:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">define( 'HEADER_IMAGE', '%s/images/logo.jpj' ); //logo di defaul
define( 'HEADER_IMAGE_WIDTH', apply_filters( '', 948 ) ); // Larghezza del logo
define( 'HEADER_IMAGE_HEIGHT', apply_filters( '', 180 ) ); // Altezza del logo
define( 'NO_HEADER_TEXT', true );
add_custom_image_header( '', 'admin_header_style' ); // Abilita la voce nel pannello di controllo 
&nbsp;
// Foglio di stile per il pannello amministratore
if ( ! function_exists( 'admin_header_style' ) ) :
function admin_header_style() {
?&gt;
&lt;style type=&quot;text/css&quot;&gt;
#headimg {
height: <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> HEADER_IMAGE_HEIGHT<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>px;
width: <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> HEADER_IMAGE_WIDTH<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>px;
}
#headimg h1, #headimg #desc {
display: none;
}
&lt;/style&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Nel pannelo di controllo nel menu &#8220;aspetto&#8221; comparirà la voce &#8220;Testata&#8221;.</p>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/aspetto_testa.jpg"><img class="aligncenter size-full wp-image-761" style="border-width: 1px; border-color: black; border-style: solid;" title="aspetto_testa" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/aspetto_testa.jpg" alt="" width="166" height="168" /></a></p>
<p>&nbsp;</p>
<p>Selezionandola, comparirà la nuova pagina di amministrazione per la scelta delle immagini da inserire nell&#8217;header del blog.<br />
Una volta caricate le immagini possiamo anche decidere di visualizzarle in maniera random.</p>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/testata_personalizzazione.jpg"><img class="aligncenter size-full wp-image-764" style="border-width: 1px; border-color: black; border-style: solid;" title="testata_personalizzazione" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/testata_personalizzazione.jpg" alt="" width="540" height="568" /></a></p>
<p>&nbsp;</p>
<p>Nel <em>header.php</em> basta inserire la seguente linea di codice:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> header_image<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; width=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> HEADER_IMAGE_WIDTH<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; height=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> HEADER_IMAGE_HEIGHT<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; alt=&quot;&quot; /&gt;</pre></td></tr></table></div>

<p>o anche</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;div id=&quot;header-container&quot; style=&quot;background: url('<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> header_image<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>');&quot;&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<h1>lo Sfondo</h1>
<p>Altra modifica possibile per utilizzare le nuove funzioni di WordPress 3.x è la possibilità di personalizza lo sfondo</p>
<p>&nbsp;</p>
<p>Aggiungendo nel file <em>function.php</em> la linea di codice:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">add_custom_background<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p style="text-align: center;">nel pannello di amministrazione comparirà la voce &#8220;Sfondo&#8221; nel menù &#8220;Aspetto&#8221;:<br />
<a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/aspetto_sfondo.jpg"><img class="aligncenter size-full wp-image-780" style="border-width: 1px; border-color: black; border-style: solid;" title="aspetto_sfondo" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/aspetto_sfondo.jpg" alt="" width="166" height="168" /></a><br />
Selezionandola, comparirà la nuova pagina di amministrazione per la scelta dello sfondo da inserire nel blog.</p>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/sfondo_personalizzazione.jpg"><img class="aligncenter size-full wp-image-767" style="border-width: 1px; border-color: black; border-style: solid;" title="sfondo_personalizzazione" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/sfondo_personalizzazione.jpg" alt="" width="540" height="662" /></a></p>
<p>&nbsp;</p>
<p><strong>Enjoy it and.. see you soon!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2011/10/17/modificare-il-tema-di-wordpress-parte-3-personalizzare-lintestazione-e-lo-sfondo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modificare il tema di WordPress (parte 2): menù di navigazione</title>
		<link>http://blog.roccoagostino.eu/2011/10/08/modificare-il-tema-di-wordpress-parte-2-menu-di-navigazione/</link>
		<comments>http://blog.roccoagostino.eu/2011/10/08/modificare-il-tema-di-wordpress-parte-2-menu-di-navigazione/#comments</comments>
		<pubDate>Sat, 08 Oct 2011 21:04:17 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[funzioni]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=669</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/>Modificare il tema di Wordpress per poter utilizzare il menù di navigazione.]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/><p>WordPress include un meccanismo semplice per introdurre dei menù di navigazione personalizzati nel proprio tema. Per incorporare nel tema il supporto al menù, è necessario aggiungere poche righe di codice. Innanzitutto nel file <em>functions.php</em> del tema, si deve scrivere una funzione per registrare il nome dei menù che si vogliono creare. Il nome sarà quello che comparirà nella pagina del pannello di amministrazione di WordPress alla pagina Aspetto-&gt;Menu.<br />
<span id="more-669"></span><br />
Per esempio, tramite questo codice, nel box “Posizione dei temi” comparirà la posizione “Menu Intestazione”:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> register_my_menus<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  register_nav_menus<span style="color: #009900;">&#40;</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'menu-intestazione'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Menu Intestazione'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>questo codice, invece, farà comparire due nuove posizioni:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> register_my_menus<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
register_nav_menus<span style="color: #009900;">&#40;</span>
  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'menu-intestazione'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Menu Intestazione'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'menu-extra'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Menu Extra'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Per assicurarsi che il tema attivi l’opzione dei menù personalizzati, è necessario aggiungere anche questa riga che comunica al tema di eseguire la funzione “<em>register_my_menus</em>”:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'register_my_menus'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>A questo punto resta da inserire nel tema la posizione in cui vogliamo che il menù (o i vari menù) siano visualizzati. Per far questo si deve aprire nell’editor il file del template corrispondente alla posizione desiderata e inserire una chiamata alla funzione <em>wp_nav_menu()</em> per ciascuna posizione. Per esempio, si vuole posizionare il menu “Menu Intestazione”, precedentemente registrato nel file <em>header.php</em>, in modo che compaia nella testata del tema. Il codice da inserire è il seguente:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_nav_menu<span style="color: #009900;">&#40;</span>  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'theme_location'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'menu-intestazione'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>IMPORTANTE: il nome associato a theme_location deve essere lo stesso inserito in <em>functions.php</em>.</strong></p>
<p>&nbsp;</p>
<p>Questa funzione crea una lista del tipo</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;ul&gt; 
  &lt;li&gt;&lt;/li&gt;
  &lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></div></div>

<p>Se si aggiunge alla funzione <em>wp_nav_menu()</em> il parametro “<em>container_class</em>”, si può specificare la classe associata al menù:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_nav_menu<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'theme_location'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'menu-intestazione'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'container_class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'classe_menu_intestazione'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>In questo modo si può personalizzare la grafica del menù specificando nel CSS gli attributi della classe “classe_menu_intestazione”.</p>
<p>Oppure, come nel mio caso, se già esiste nel foglio di stile una classe per i menù tradizionali, basta sostituire il codice all&#8217;interno, per esempio, del</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=”menu”&gt;......&lt;/div&gt;</pre></div></div>

<p>richiamando la funzione</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_nav_menu<span style="color: #009900;">&#40;</span>  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'theme_location'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'menu-intestazione'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Enjoy it and.. see you soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2011/10/08/modificare-il-tema-di-wordpress-parte-2-menu-di-navigazione/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modificare il tema di WordPress (parte 1): la funzione post thumbnail</title>
		<link>http://blog.roccoagostino.eu/2011/10/06/modificare-il-tema-di-wordpress-parte-1-la-funzione-post-thumbnail/</link>
		<comments>http://blog.roccoagostino.eu/2011/10/06/modificare-il-tema-di-wordpress-parte-1-la-funzione-post-thumbnail/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 18:34:49 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[funzioni]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[thumbnail]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=625</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/>Come inserire nel proprio tema funzione post thumbnail (miniature) per associare una immagine agli articoli.]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/><p>Ormai del mio tema per wordpress, che ho scaricato tra quelli gratuiti nel lontano 2009, ci sta ben poco. Nel corso dei mesi tante sono state le modifiche: supporto ai plugin, ai widget, agli script in JQuery, modifiche in php che adesso ad elencarli tutti ho davvero tanta difficoltà. Wordpress si aggiorna, introduce nuove funzioni e nuove possibilità di fare blogging, ma il mio tema &#8220;no, non lo voglio cambiare!&#8221;.</p>
<p><span id="more-625"></span></p>
<p>Così, armato di santa pazienza, googlando un pò in giro, ecco che mi ritrovo per l&#8217;ennesima volta a far modifiche.</p>
<p>&nbsp;</p>
<p>Vediamo la prima: la funzione post thumbnail (miniature).</p>
<p>&nbsp;</p>
<p>Le icone che vedere associate agli articoli di questo blog sono in realtà associate alle categorie (uso il plugin <a href="http://blog.roccoagostino.eu/2009/08/30/associa-le-icone-alle-categorie-del-blog-wordpresscategory-icons-plugin/" target="_blank">Category Icons</a>). Pertanto esse non sono direttamente legate al contenuto dell&#8217;articolo. Stanco della visualizzazione testuale a lista dei post correlati ho installato il plugin <a href="http://wordpress.org/extend/plugins/related-posts-thumbnails/" target="_blank">Related Posts Thumbnails</a> che crea un riquadro per ogni articolo correlato inserendo una immagine contenuta nell&#8217;articolo stesso. Problema: e se nel contenuto non vi sono inserite delle immagini? Il plugin usa la minitura associata all&#8217;articolo!</p>
<p>&nbsp;</p>
<p>Per attivare la gestione lato backend della “miniatura articolo” è sufficiente editare il file <em>functions.php</em> e inserire le seguenti linee di codice che, nell&#8217;ottica di compatibilità e stabilità, sono:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'add_theme_support'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    add_theme_support<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post-thumbnails'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>&nbsp;</p>
<p>Fatto questo, entrando nell’amministrazione e andando nella modifica di un post, troveremo sulla sidebar destra un nuovo pannello:</p>
<p>&nbsp;</p>
<p><center><img class="aligncenter size-full wp-image-617" title="thumbs" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2011/10/thumbs.jpg" alt="" width="295" height="76" /></center>Da qui possiamo associare una immagine all&#8217;articolo.</p>
<p>&nbsp;</p>
<p>Con</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;!--</span>?php get_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>?<span style="color: #339933;">--&gt;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>recuperiamo l’url della nostra thumbnail e possiamo tranquillamente inserirlo nel loop in questo modo ad esempio:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;div&gt;&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; alt=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;&lt;/div&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Enjoy it and.. see you soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2011/10/06/modificare-il-tema-di-wordpress-parte-1-la-funzione-post-thumbnail/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Associa le icone alle categorie del blog WordPress &#8211; Category Icons Plugin</title>
		<link>http://blog.roccoagostino.eu/2009/08/30/associa-le-icone-alle-categorie-del-blog-wordpresscategory-icons-plugin/</link>
		<comments>http://blog.roccoagostino.eu/2009/08/30/associa-le-icone-alle-categorie-del-blog-wordpresscategory-icons-plugin/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 20:48:55 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=176</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/>Di norma non scrivo articoli sui plugin di WordPress, visto che googlando si trovano migliaia di post su questo tema, però il plugin Category Icons questa volta mi è piaciuto moltissimo, poichè è interessante l&#8217;idea di associare un articolo  alla categoria attraverso una immagine: specie nei blog con tante categorie, questo plugin può aumentare di molto [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/><p>Di norma non scrivo articoli sui plugin di WordPress, visto che googlando si trovano migliaia di post su questo tema, però  il plugin <strong>Category Icons</strong> questa volta mi è piaciuto moltissimo, poichè è interessante l&#8217;idea di associare un articolo  alla categoria attraverso una immagine: specie nei blog con tante categorie, questo plugin può aumentare di molto la visibilità di tutti gli articoli.</p>
<p>Ma entriamo nel vivo&#8230;.</p>
<p><span id="more-176"></span></p>
<p><strong>Category Icons</strong>, <a href="http://www.category-icons.com/" target="_blank">qui il sito di riferimento</a>, permette di associare delle icone alle gategorie del blog e di visualizzarle lì dove richiamate. L&#8217;interfaccia grafica per il setup è molto intuitiva e l&#8217;autore, nel suo sito, spiega in maniera molto chiara come inserire il codice all&#8217;interno delle pagine del vostro tema.<br />
<a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/08/cico1.JPG"><img class="aligncenter size-full wp-image-177" title="cico1" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/08/cico1.JPG" alt="cico1" width="157" height="254" /></a></p>
<p>Le icone vengono carica sul server andando dal menù &#8220;Icone&#8221; e ad ogni categoria può essere associata una icona piccola ed una grande.<br />
Il codice, per visualizzare le icone, può essere inserito in maniera automatica (menù &#8220;Opzioni&#8221; -&gt; &#8220;Template Tags&#8221;) o manuale (menù &#8220;Template Tags&#8221;); in quest&#8217;ultimo caso l&#8217;autore ci suggerisce il file php da modificare fornendo addirittura le coordinate espesse in riga e colonna.<br />
<a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/08/cico2.JPG"><img class="aligncenter size-full wp-image-178" title="cico2" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/08/cico2.JPG" alt="cico2" width="407" height="113" /></a>Con il plugin è compreso anche un widget delle categorie da personalizzare, che visualizza le icone associate, appunto, alle vostre categorie. Inoltre, sul sito alla voce &#8220;Translate the plugin&#8221; vi sono altre localizzazioni del plugin incluse quella italiana.</p>
<p><strong><em>Un consiglio: quando scegliete le immagini fate in modo tale che abbiano la medesima dimensione.  Per le immagini piccole, che compaiono nella pagina principale o associate ai permalink degli articoli, ho scelto la dimensione 32&#215;32, mentre per le immagini grandi, che ho inserito nella pagina dell&#8217;articolo, ho scelto la dimensione 116&#215;116. Ovviamente le dimensioni scelte dipendono dal vostro tema.</em></strong></p>
<p>Enjoy it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2009/08/30/associa-le-icone-alle-categorie-del-blog-wordpresscategory-icons-plugin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Crea il file .htaccess con il cPanel per settare i permalinks di WordPress</title>
		<link>http://blog.roccoagostino.eu/2009/08/23/crea-il-file-htaccess-con-il-cpanel-per-settare-i-permalinks-di-wordpress/</link>
		<comments>http://blog.roccoagostino.eu/2009/08/23/crea-il-file-htaccess-con-il-cpanel-per-settare-i-permalinks-di-wordpress/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 04:46:11 +0000</pubDate>
		<dc:creator>Rocky</dc:creator>
				<category><![CDATA[Informatica]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.roccoagostino.eu/?p=82</guid>
		<description><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/>Il file .htaccess è uno strumento molto potente, specialmente per chi usa WordPress: fra le tante opzioni, permette di utilizzare permalinks più complessi associati ai post. Il problema è che, a secondo delle diverse strategie dei server host che ospitano i nostri blog, la creazione di questo file può diventare abbastanza complessa. Nel mio caso, [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.roccoagostino.eu/wp/wp-content/uploads/wordpress_ico.jpg" width="33" height="33" alt="" title="WordPress" /><br/><p style="text-align: justify;"><span onmouseover="_tipon(this)" onmouseout="_tipoff()">Il file <strong>.htaccess</strong> è uno strumento molto potente, specialmente per chi usa WordPress: fra le tante opzioni, permette di utilizzare  permalinks più complessi associati ai post.</span> Il problema è che, a secondo delle diverse strategie dei server host che ospitano i nostri blog, la creazione di questo file può diventare abbastanza complessa.</p>
<p style="text-align: justify;">Nel mio caso, infatti, WordPress non riusciva a creare il file .htaccess, nè tantomeno, forzando con un upload tramite ftp, esso veniva letto in maniera corretta. <span onmouseover="_tipon(this)" onmouseout="_tipoff()">Ecco la soluzione che ha risolto il  problema sull&#8217;host che ospita il mio blog e che utilizza ,come interfaccia utente per il setup ,cPanel.</span></p>
<p><span id="more-82"></span></p>
<p style="text-align: justify;"><span onmouseover="_tipon(this)" onmouseout="_tipoff()">Accedi al cPanel con il tuo nome utente e password, quindi una volta che hai fatto il login individua il &#8220;File Manager&#8221;.<br />
</span>
</p>
<p style="text-align: center;"><a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/08/cpanel11.JPG"><img class="aligncenter size-full wp-image-91" style="border: 1px solid black;" title="cpanel1" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/08/cpanel11.JPG" alt="cpanel1" width="279" height="279" /></a></p>
<p style="text-align: justify;"><span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span style="direction: ltr; text-align: left;"><br />
L&#8217;interfaccia grafica del </span> File Manager è in stile Windows, molto familiare, e permette di gestire  i  file sul tuo account di hosting.</span> <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span style="direction: ltr; text-align: left;">Clicca </span> sulla icona della cartella public_html e successivamente sulla cartella dove sono salvati i file del WordPress (se diversa da root). Individua quindi l&#8217;icona del File Manager che permette di creare un nuovo file.<br />
</span><span onmouseover="_tipon(this)" onmouseout="_tipoff()"> </span>
</p>
<p style="text-align: center;"><a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/08/cpanel2.JPG"><img class="size-full wp-image-88  aligncenter" style="border: 1px solid black;" title="cpanel2" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/08/cpanel2.JPG" alt="cpanel2" width="457" height="216" /></a></p>
<p style="text-align: justify;"><span onmouseover="_tipon(this)" onmouseout="_tipoff()"><br />
Cliccando avrai la possibilità di salvare dentro la cartella il file &#8220;.htaccess&#8221;, all&#8217;inizio vuoto, ma con i permessi giusti. Riempi i campi richiesti e crea il file.<br />
</span>
</p>
<p style="text-align: center;"><a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/08/cpanel3.JPG"><img class="aligncenter size-full wp-image-89" style="border: 1px solid black;" title="cpanel3" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/08/cpanel3.JPG" alt="cpanel3" width="450" height="195" /></a></p>
<p style="text-align: justify;"><span onmouseover="_tipon(this)" onmouseout="_tipoff()"><br />
A questo punto è possibile aprire il file per poterlo editare (cercare l&#8217;icona &#8220;edit&#8221; selezionando il file .htaccess) e, una volta inseriti i valori suggeriti da Wordpres per l&#8217;impostazione dei permalinks, salvarlo.<br />
</span></p>
<p style="text-align: center;"><span onmouseover="_tipon(this)" onmouseout="_tipoff()"><a href="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/08/cpanel4.JPG"><img class="aligncenter size-full wp-image-86" style="border: 1px solid black;" title="cpanel4" src="http://www.roccoagostino.eu/wp/wp-content/uploads/2009/08/cpanel4.JPG" alt="cpanel4" width="319" height="264" /></a><br />
</span></p>
<p><span onmouseover="_tipon(this)" onmouseout="_tipoff()">I permalinks dovrebbero funzionare in maniera corretta. </span></p>
<p><span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span style="font-size: medium;"><strong>That&#8217;s all folks!</strong></span></span></p>
<p>gkv4tbdjfr</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roccoagostino.eu/2009/08/23/crea-il-file-htaccess-con-il-cpanel-per-settare-i-permalinks-di-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  blog.roccoagostino.eu/category/informatica/wordpress-informatica/feed/ ) in 1.83627 seconds, on Feb 6th, 2012 at 12:22 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 13th, 2012 at 12:22 pm UTC -->
