<?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; plugin</title>
	<atom:link href="http://blog.roccoagostino.eu/tag/plugin/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>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>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  blog.roccoagostino.eu/tag/plugin/feed/ ) in 0.95023 seconds, on Feb 6th, 2012 at 12:51 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 13th, 2012 at 12:51 pm UTC -->
