<?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>piouPiouM&#039;s dev&#187; Archives pour le tag WordPress – piouPiouM&#039;s dev</title>
	<atom:link href="http://pioupioum.fr/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://pioupioum.fr</link>
	<description>Bloc-note d&#039;un développeur web</description>
	<lastBuildDate>Thu, 29 Jul 2010 16:47:44 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</title>
		<link>http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html</link>
		<comments>http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html#comments</comments>
		<pubDate>Tue, 09 Feb 2010 14:50:30 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[upload]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=316</guid>
		<description><![CDATA[WordPress ne supporte en upload qu&#8217;une liste exhaustive de formats de fichiers. Si comme moi vous souhaitez uploader1 des fichiers issus de TextMate, comme les .tmCommand et autres .tmSnippet, ajoutez le code qui suit dans le fichier functions.php de votre thème2.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
&#60;?php
// Add the new filter
add_filter&#40;'upload_mimes', 'addUploadMimes'&#41;;
&#160;
/**
 * Adds new supported media types for upload.
 *
 [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>WordPress ne supporte en upload qu&#8217;une liste exhaustive de formats de fichiers. Si comme moi vous souhaitez uploader<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> des fichiers issus de <a href="http://macromates.com/" title="TextMate — The Missing Editor for Mac OS X">TextMate</a>, comme les <code>.tmCommand</code> et autres <code>.tmSnippet</code>, ajoutez le code qui suit dans le fichier <code>functions.php</code> de votre thème<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>.</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Add the new filter</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'upload_mimes'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'addUploadMimes'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Adds new supported media types for upload.
 *
 * @see wp_check_filetype() or get_allowed_mime_types()
 * @param array $mimes Array of mime types keyed by the file extension regex corresponding to those types.
 * @return array
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> addUploadMimes<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mimes</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$mimes</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mimes</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'tmbundle|tmCommand|tmDragCommand|tmSnippet|tmLanguage|tmPreferences'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'application/octet-stream'</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$mimes</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<p>Indiquez en clé les nouvelles extensions de fichier (séparées par des <em>pipes</em>) et en valeur le type mime associé.</p>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/outils-astuces/wordpress-recuperation-avancee-images-article.html' title='WordPress : récupération avancée des images d&#8217;un article'>WordPress&#160;: récupération avancée des images d&#8217;un article</a></li><li><a href='http://pioupioum.fr/outils-astuces/afficher-images-article-page-media.html' title='WordPress : lister les images d&#8217;un article sur une page media'>WordPress&#160;: lister les images d&#8217;un article sur une page media</a></li><li><a href='http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html' title='Optimiser le chargement des AdSense'>Optimiser le chargement des AdSense</a></li><li><a href='http://pioupioum.fr/snippets/apache-rotation-logs.html' title='Rotation des logs Apache'>Rotation des logs Apache</a></li><li><a href='http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html' title='WordPress jQuery UI Effects'>WordPress jQuery UI Effects</a></li></ul>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>sous Mac OS X tout du moins, <a href="http://swfupload.org/" title="SWFUpload News | SWFUpload">SWFUpload</a> me désactive la sélection des fichiers de TextMate m&#8217;obligeant à passer par l&#8217;interface d&#8217;upload native du navigateur. Je suis preneur de toute solution.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>à choisir, l&#8217;ajouter dans un plugin serait plus judicieux puisque cette fonctionnalité ne dépend pas du thème.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress jQuery UI Effects</title>
		<link>http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html</link>
		<comments>http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html#comments</comments>
		<pubDate>Wed, 06 Jan 2010 01:37:10 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Plugins WordPress]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[projet]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=301</guid>
		<description><![CDATA[WordPress jQuery UI Effects est un plugin pour WordPress permettant d&#8217;enregistrer et de charger les composants JavaScript de la librairie jQuery UI Effects.

Ce ne sont pas moins de 14 effets que vous pourrez utiliser dans vos développement de plugins ou dans la personnalisation de vos thèmes&#160;: Blind, Clip, Drop, Explode, Fold, Puff, Slide, Scale, Bounce, [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p><strong>WordPress jQuery UI Effects</strong> est un <strong>plugin</strong> pour <strong><a href="http://wordpress.org/" title="WordPress &#8250; Blog Tool and Publishing Platform">WordPress</a></strong> permettant d&#8217;enregistrer et de charger les composants JavaScript de la librairie <strong><a href="http://docs.jquery.com/UI/Effects/" title="UI/Effects - jQuery JavaScript Library">jQuery UI Effects</a></strong>.</p>

<p>Ce ne sont pas moins de 14 effets que vous pourrez utiliser dans vos développement de plugins ou dans la personnalisation de vos thèmes&#160;: <a href="http://docs.jquery.com/UI/Effects/Blind" title="UI/Effects/Blind - jQuery JavaScript Library">Blind</a>, <a href="http://docs.jquery.com/UI/Effects/Clip" title="UI/Effects/Clip - jQuery JavaScript Library">Clip</a>, <a href="http://docs.jquery.com/UI/Effects/Drop" title="UI/Effects/Drop - jQuery JavaScript Library">Drop</a>, <a href="http://docs.jquery.com/UI/Effects/Explode" title="UI/Effects/Explode - jQuery JavaScript Library">Explode</a>, <a href="http://docs.jquery.com/UI/Effects/Fold" title="UI/Effects/Fold - jQuery JavaScript Library">Fold</a>, <a href="http://docs.jquery.com/UI/Effects/Puff" title="UI/Effects/Puff - jQuery JavaScript Library">Puff</a>, <a href="http://docs.jquery.com/UI/Effects/Slide" title="UI/Effects/Slide - jQuery JavaScript Library">Slide</a>, <a href="http://docs.jquery.com/UI/Effects/Scale" title="UI/Effects/Scale - jQuery JavaScript Library">Scale</a>, <a href="http://docs.jquery.com/UI/Effects/Bounce" title="UI/Effects/Bounce - jQuery JavaScript Library">Bounce</a>, <a href="http://docs.jquery.com/UI/Effects/Highlight" title="UI/Effects/Highlight - jQuery JavaScript Library">Highlight</a>, <a href="http://docs.jquery.com/UI/Effects/Pulsate" title="UI/Effects/Pulsate - jQuery JavaScript Library">Pulsate</a>, <a href="http://docs.jquery.com/UI/Effects/Shake" title="UI/Effects/Shake - jQuery JavaScript Library">Shake</a>, <a href="http://docs.jquery.com/UI/Effects/Size" title="UI/Effects/Size - jQuery JavaScript Library">Size</a> et <a href="http://docs.jquery.com/UI/Effects/Transfer" title="UI/Effects/Transfer - jQuery JavaScript Library">Transfer</a>.</p>

<p><span id="more-301"></span></p>

<h2 id="toc">Table des matières</h2>

<ol>
<li><a href="#telecharger">Téléchargement</a></li>
<li><a href="#installer">Installation</a></li>
<li><a href="#faq">Foire aux questions</a>

<ol>
<li><a href="#usage">Comment utiliser ce plugin&#160;?</a></li>
<li><a href="#charger-dependance">Comment déclarer un script dépendant de l&#8217;effet jQuery UI Effect Highlight&#160;?</a></li>
<li><a href="#liste-gestionnaires">Comment trouver la liste des gestionnaires disponibles&#160;?</a></li>
<li><a href="#non-dependant-jquery-ui">La librairie jQuery UI est-elle nécessaire au fonctionnement de jQuery UI Effects&#160;?</a></li>
</ol></li>
<li><a href="#developpement">Développement</a></li>
<li><a href="#changelog">Historique des versions</a></li>
</ol>

<h2 id="telecharger">Téléchargement</h2>

<div class="download box">
    <a href="http://downloads.wordpress.org/plugin/wordpress-jquery-ui-effects.1.0.0.zip" title="Téléchargement depuis les serveurs de WordPress.org"><span>Télécharger la dernière version du plugin WordPress jQuery UI Effects</span></a>
</div>

<p>Vous pouvez également vous rendre sur la <a href="http://wordpress.org/extend/plugins/wordpress-jquery-ui-effects/" title="WordPress &#8250; WordPress jQuery UI Effects &laquo; WordPress Plugins">page WordPress.org du plugin</a> ou lancer son téléchargement et installation directement depuis l&#8217;interface d&#8217;administration de votre WordPress.</p>

<h2 id="installer">Installation</h2>

<p><strong>WordPress jQuery UI Effects</strong> s&#8217;installe en 3 étapes&#160;:</p>

<ol>
<li>Téléversez le répertoire <code>wp-jquery-ui-effects</code> et son contenu dans votre répertoire <code>/wp-content/plugins/</code>.</li>
<li>Activez le plugin <code>WordPress jQuery UI Effects</code> <em>via</em> le menu <em>Extensions</em> du panel d&#8217;administration de WordPress.</li>
<li>C&#8217;est tout <img src='http://pioupioum.fr/wp/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
</ol>

<h2 id="faq">Foire aux questions</h2>

<h3 id="usage">Comment utiliser ce plugin&#160;?</h3>

<p>Pour charger l&#8217;effet <strong>Bounce</strong> dans votre thème ou un plugin, utilisez la méthode <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" title="Function Reference/wp enqueue script &laquo; WordPress Codex">wp_enqueue_script</a>&#160;:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> my_init_method<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery-ui-effects-bounce'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_init_method'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<p>WordPress chargera<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> l&#8217;effet <em>jQuery UI Effects Bounce</em> et, si besoin est, ses dépendances&#160;: <em>jQuery</em> et <em>jQuery UI Effects Core</em>.</p>

<h3 id="charger-dependance">Comment déclarer un script dépendant de l&#8217;effet jQuery UI Effect Highlight&#160;?</h3>

<p>Déclarez et chargez en toute simplicité un nouveau script dépendant de jQuery UI Effect Highlight&#160;:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
wp_enqueue_script<span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'my-script'</span><span style="color: #339933;">,</span>
    get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_url'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'raw'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/js/my-script.js'</span><span style="color: #339933;">,</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery-ui-effects-highlight'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'1.0'</span><span style="color: #339933;">,</span>
    <span style="color: #009900; font-weight: bold;">true</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<h3 id="liste-gestionnaires">Comment trouver la liste des gestionnaires disponibles&#160;?</h3>

<p>Préfixez le nom de l&#8217;effet voulu par <code>jquery-ui-effects-</code> pour obtenir le nom du gestionnaire associé<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>. Attention, le nom du gestionnaire doit être en minuscules.</p>

<p>Par exemple, chargez l&#8217;effet <strong>Shake</strong> soit&#160;:</p>

<ul>
<li>avec le gestionnaire <code>jquery-ui-effects-shake</code>&#160;;</li>
<li>en utilisant la méthode statique <code>WPjQueryUIEffects::getHandle('shake')</code>.</li>
</ul>

<h3 id="non-dependant-jquery-ui">La librairie jQuery UI est-elle nécessaire au fonctionnement de jQuery UI Effects&#160;?</h3>

<p>Non. Vous n&#8217;avez donc pas à charger le gestionnaire <code>jquery-ui-core</code> (fichier <code>ui.core.js</code>) en tant que dépendance d&#8217;un quelconque effet pour que ce dernier fonctionne.</p>

<h3 id="version">Quelle est la version de jQuery UI Effects utilisé&#160;?</h3>

<p>Le <strong>plugin</strong> utilise <strong>jQuery UI Effects</strong> dans sa version <code>1.7.2</code>.<br />
Il nécessite également jQuery <code>1.3+</code>, disponible depuis WordPress 2.8.</p>

<h2 id="developpement">Développement</h2>

<p>Distribué sous licence <a href="http://fr.wikipedia.org/wiki/Licence_publique_générale_GNU">GNU/GLP</a>, le <a href="http://github.com/piouPiouM/wordpress-jquery-ui-effects" title="piouPiouM's wordpress-jquery-ui-effects at master - GitHub">code source du plugin</a> est accessible sur GitHub.</p>

<p>Une suggestion, une amélioration, une critique ou un bug à me soumettre&#160;? Ça se passe du côté du <a href="http://github.com/piouPiouM/wordpress-jquery-ui-effects/issues" title="Issues - piouPiouM/wordpress-jquery-ui-effects - GitHub">bugtracker</a> <img src='http://pioupioum.fr/wp/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<h2 id="changelog">Historique des versions</h2>

<h3>1.0.0</h3>

<ul>
<li>Version initiale.</li>
</ul>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/developpement/jquery-color-plugin-animation-rgba-support.html' title='Du RGBA dans vos animations avec le plugin jQuery Color'>Du RGBA dans vos animations avec le plugin jQuery Color</a></li><li><a href='http://pioupioum.fr/plugins-wordpress/get-authors-comments.html' title='Get Author&#8217;s Comments'>Get Author&#8217;s Comments</a></li><li><a href='http://pioupioum.fr/developpement/javascript-detecter-support-rgba.html' title='JavaScript : tester le support des couleurs RGBA'>JavaScript&#160;: tester le support des couleurs RGBA</a></li><li><a href='http://pioupioum.fr/outils-astuces/supprimer-neige-scripts-greasemonkey.html' title='Supprimer les effets de neige avec Greasemonkey'>Supprimer les effets de neige avec Greasemonkey</a></li><li><a href='http://pioupioum.fr/plugins-spip/google-tools-1-0-1.html' title='SPIP Google Tools 1.0.1'>SPIP Google Tools 1.0.1</a></li></ul>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>Les scripts sont chargés en pied de page.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>Notez que les effets <strong>Puff</strong> et <strong>Size</strong> sont accessibles en chargeant le composant <strong>Scale</strong>.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WordPress&#160;: récupération avancée des images d&#8217;un article</title>
		<link>http://pioupioum.fr/outils-astuces/wordpress-recuperation-avancee-images-article.html</link>
		<comments>http://pioupioum.fr/outils-astuces/wordpress-recuperation-avancee-images-article.html#comments</comments>
		<pubDate>Tue, 15 Sep 2009 00:11:27 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Outils, trucs et astuces]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[recherche]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=245</guid>
		<description><![CDATA[De nombreux thèmes WordPress proposent, via un champ personnalisé, une gestion des miniatures à afficher sur la page d&#8217;accueil. Mais pourquoi contraindre ses rédacteurs à cette manipulation, qui, il faut le dire, est relativement lourde,surtout pour le néophyte1. Le plus simple serait de recourir dans son thème à une fonction qui automatiserait la recherche de [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>De nombreux thèmes WordPress proposent, <em>via</em> un <strong>champ personnalisé</strong>, une gestion des miniatures à afficher sur la page d&#8217;accueil. Mais pourquoi contraindre ses rédacteurs à cette manipulation, qui, il faut le dire, est <strong>relativement lourde</strong>,surtout pour le néophyte<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>. Le plus simple serait de recourir dans son thème à une fonction qui automatiserait la recherche de l&#8217;image à afficher en tant que thumbnail.</p>

<p>Évidemment, nous pouvons trouver au détour du web des fonctions <a href="http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it" title="How to: Get the first image from the post and display it">au code douteux</a><sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup> qui vont se contenter de chercher la première image dans le contenu du billet.</p>

<p>Pourquoi ne pas étendre (et améliorer tant que nous y sommes =) ce type de fonction afin d&#8217;obtenir un outil de <strong>recherche d&#8217;images</strong> au sein d&#8217;un billet&#160;? C&#8217;est ce que je vous propose ici.
<span id="more-245"></span></p>

<h2 id="toc">Table des matières</h2>

<ol>
<li><a href="#telecharger">Code source</a></li>
<li><a href="#fonctionnement">Fonctionnement</a></li>
<li><a href="#exemples">Exemples d&#8217;utilisation</a></li>
<li><a href="#parametres">Liste des paramètres</a></li>
<li><a href="#changelog">Historique des versions et changelog</a></li>
</ol>

<h2 id="telecharger">Code source</h2>

<p>Copiez le code qui suit dans le fichier <code>functions.php</code> de votre thème.</p>

<div class="box file-php">
    <a href="http://assets1.pioupioum.fr/uploads/2009/09/wp-get_post_images.phps" title="Téléchargement du fichier source"><span>Télécharger wp-get_post_images.phps (1.62&#160;Ko)</span></a>
</div>

<script type="text/javascript" src="http://gist.github.com/186392.js"></script>

<h2>Fonctionnement</h2>

<p>Petit retour sur ce code non commenté<sup id="fnref:3"><a href="#fn:3" rel="footnote">3</a></sup>, car, à la lecture aisée.</p>

<h3>Recherche des images</h3>

<p>La fonction <code>get_post_images</code> va effectuer une recherche d&#8217;image(s) dans les images jointes au billet cible si l&#8217;ordre de tri est différent à <strong>natural</strong>. En effet, cette option oblige à parser le contenu dans le sens de lecture de l&#8217;article, qui peut différer de l&#8217;ordre d&#8217;ajout des images dans sa bibliothèque de médias.<br />
Notez que la recherche non naturelle prend directement en compte les ordres de tri.</p>

<p>Si la recherche échoue (ou si l&#8217;ordre de tri est défini à <strong>natural</strong>), le contenu du post est analysé. Seront considérées les images comportants une classe <code>wp-image-(\d+)</code>. Si la recherche s&#8217;avère fructueuse, le tri est appliqué.</p>

<p>Finalement, <code>get_post_images</code> retournera le résultat de la recherche au format spécifié <em>via</em> le paramètre <strong>output</strong>. En cas d&#8217;échec, le booléen <code>false</code> est retourné.</p>

<h3>Quid de la présentation&#160;?</h3>

<p>Le formatage et l&#8217;affichage des données est laissé à la discrétion du développeur. La présentation pourra ainsi évoluer indépendamment de la fonction.</p>

<h2 id="exemples">Exemples d&#8217;utilisation</h2>

<h3>Récupérer les images triées par date (défaut)</h3>

<p>Nous supposons ici que l&#8217;action se déroule dans la boucle puisque qu&#8217;aucun identifiant d&#8217;article n&#8217;a été fourni. Autrement, la valeur de retour sera <em>FALSE</em>.</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> get_post_images<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></pre></div></div>


<h3>Liste des images triées par date inverse</h3>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_post_images<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'order=DESC'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>


<h3>Liste des images triées par ordre d&#8217;arrivée dans le billet</h3>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_post_images<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'orderby=natural'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>


<h3>Récupération de la première image</h3>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_post_images<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'number=1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>


<h3>Récupération de la première image (par contenu, forcé)</h3>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_post_images<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'number=1&amp;orderby=natural'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>


<h3>Afficher la miniature de la première image d&#8217;un article</h3>

<p>La fonction <code>first_thumbnail</code> qui suit affichera au format <em>thumbnail</em> la première image du billet ayant pour identifiant <var>$post_id</var>. Si ce dernier est omit, l&#8217;identifiant du billet en cours d&#8217;itération depuis <a href="http://codex.wordpress.org/fr:La_Boucle" title="fr:La Boucle &laquo; WordPress Codex">la boucle</a> sera utilisé.</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;"><span style="color: #009933; font-style: italic;">/**
 * Display thumb of the first image from a post.
 *
 * @author Mehdi Kabab &lt;http://pioupioum.fr&gt;
 * @copyright Copyright (C) 2009 Mehdi Kabab
 * @license http://www.gnu.org/licenses/gpl.html  GNU GPL version 3 or later
 *
 * @param  array $post_id Optional. Post ID.
 * @return bool False on failure.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> first_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</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;">$img</span> <span style="color: #339933;">=</span> get_post_images<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;post_id=<span style="color: #006699; font-weight: bold;">$post_id</span>&amp;number=1&quot;</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: #009900; font-weight: bold;">false</span> <span style="color: #339933;">!==</span> <span style="color: #000088;">$img</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> wp_get_attachment_link<span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thumbnail'</span><span style="color: #009900;">&#41;</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: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<h3>Générer une miniature de la première image d&#8217;un article avec timthumb</h3>

<p>La même fonction mais qui fait appel à <a href="http://code.google.com/p/timthumb/" title="timthumb - Project Hosting on Google Code">timthumb</a> pour générer une miniature aux dimensions arbitraires.</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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Display a dynamic thumbnail of the first image from a post.
 *
 * The defaults are as follows:
 *     'post_id' - Default is null. Post ID.
 *     'h' - Default is null. Thumbnail height.
 *     'w' - Default is null. Thumbnail width.
 *     'q' - Default is null. Thumbnail quality.
 *     'zc' - Default is null. Zoom crop used for generates the thumbnail.
 *
 * @author Mehdi Kabab &lt;http://pioupioum.fr&gt;
 * @copyright Copyright (C) 2009 Mehdi Kabab
 * @license http://www.gnu.org/licenses/gpl.html  GNU GPL version 3 or later
 *
 * @link http://code.google.com/p/timthumb/ Timthumb
 *
 * @param  array $args Optional. Overrides defaults.
 * @return bool False on failure.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> first_thumbnail<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: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$defaults</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'post_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'h'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'q'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'w'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'zc'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$args</span>    <span style="color: #339933;">=</span> wp_parse_args<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #000088;">$defaults</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$post_id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$args</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: #000088;">$img</span>     <span style="color: #339933;">=</span> get_post_images<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;post_id=<span style="color: #006699; font-weight: bold;">$post_id</span>&amp;number=1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</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>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">!==</span> <span style="color: #000088;">$img</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$img</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">===</span> <span style="color: #000088;">$post_id</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>in_the_loop<span style="color: #009900;">&#40;</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;">$post_id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</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: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_parent</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$post_id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$img</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_parent</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: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$query</span>     <span style="color: #339933;">=</span> <span style="color: #990000;">http_build_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&amp;amp;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$thumbnail</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;img src=&quot;%s?src=%s%s&quot; rel=&quot;attachment&quot;%s%s/&gt;'</span><span style="color: #339933;">,</span>
            get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_url'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'display'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/timthumb.php'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// customize timthumb url</span>
            <span style="color: #000088;">$img</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">guid</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'&amp;amp;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$query</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'w'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot; width=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">{$args['w']}</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'h'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot; height=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">{$args['h']}</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;a href=&quot;%s&quot; title=&quot;%s&quot;&gt;%s&lt;/a&gt;'</span><span style="color: #339933;">,</span>
            get_permalink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            esc_attr<span style="color: #009900;">&#40;</span>get_the_title<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #000088;">$thumbnail</span>
        <span style="color: #009900;">&#41;</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: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<p>Ainsi, pour afficher une miniature de 260x120 pixels de la première image de l&#8217;article courant nous utiliserons&#160;:</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> first_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'w=260&amp;h=120'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>


<h2 id="parametres">Liste des paramètres</h2>

<p>Voici la liste des paramètres acceptés par l&#8217;argument <code>$args</code> de la fonction <code>get_post_images</code>&#160;:</p>

<p><strong>number</strong><br />
<em>(integer)</em> <em>(optionnel)</em> Le nombre maximal d&#8217;images à retourner. Par défaut à <em>-1</em>, retourne toutes les images.</p>

<p><strong>order</strong><br />
<em>(string)</em> <em>(optionnel)</em> Ordre de tri. Les valeurs valides sont&#160;:</p>

<ul>
<li><code>'ASC'</code> - Croissant (du plus petit au plus grand). (Par défaut)</li>
<li><code>'DESC'</code> - Décroissant (du plus grand au plus petit).</li>
</ul>

<p><strong>orderby</strong><br />
<em>(string)</em> <em>(optionnel)</em> Ordonner les images par l&#8217;une des valeurs qui suivent&#160;:</p>

<ul>
<li><code>'date'</code> - Trier selon la date de création. (Par Défaut)</li>
<li><code>'post_id'</code> - Trier numériquement par l&#8217;ID des articles.</li>
<li><code>'natural'</code> - Trier selon l&#8217;affichage des images dans le contenu de l&#8217;article.</li>
</ul>

<p><strong>output</strong><br />
<em>(string)</em> <em>(optionnel)</em> Le format de sortie.</p>

<ul>
<li><code>OBJECT</code> - Retourne un tableau d&#8217;objets instances de la classe stdClass. (Par défaut)</li>
<li><code>ARRAY_A</code> - Retourne un tableau associatif (nom des champs => valeurs).</li>
<li><code>ARRAY_N</code> - Retourne un tableau indexé numériquement de la valeur des champs.</li>
</ul>

<p><strong>post_id</strong><br />
<em>(integer)</em> <em>(optionnel)</em> L&#8217;identifiant de l&#8217;article à analyser. Par défaut à <em>NULL</em>, utilise celui du billet courant dans la boucle.</p>

<p><strong>preserve_keys</strong><br />
<em>(boolean)</em> <em>(optionnel)</em> Préserver les clés retournées par l&#8217;API de WordPress, c.-à-d les identifiants des images. Par défaut à <em>FALSE</em>, le tableau résultat est indexé numériquement à partir de 0.</p>

<h2 id="changelog">Historique des versions et changelog</h2>

<h3>1.0.0</h3>

<ul>
<li>Version initiale.</li>
</ul>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html' title='WordPress : autoriser l&#8217;upload de fichiers au format non-supporté'>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</a></li><li><a href='http://pioupioum.fr/outils-astuces/afficher-images-article-page-media.html' title='WordPress : lister les images d&#8217;un article sur une page media'>WordPress&#160;: lister les images d&#8217;un article sur une page media</a></li><li><a href='http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html' title='WordPress jQuery UI Effects'>WordPress jQuery UI Effects</a></li><li><a href='http://pioupioum.fr/snippets/convertir-icone-icns-png.html' title='Convertir une icône ICNS en une image PNG'>Convertir une icône ICNS en une image PNG</a></li><li><a href='http://pioupioum.fr/outils-astuces/faille-wordpress-mot-passe-correctif.html' title='Correctif pour la faille WordPress de réinitialisation de mot de passe'>Correctif pour la faille WordPress de réinitialisation de mot de passe</a></li></ul>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>uploader l&#8217;image, récupérer son URL relative donc en supprimer la racine du site, ajouter un champ personnalisé pour y renseigner l&#8217;URL précédemment copiée.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>franchement, que d&#8217;erreurs dans cette fonction qui a pourtant fait du bruit&#160;: la temporisation n&#8217;est d&#8217;aucune utilité, la globale <var>$posts</var> ne sert à rien, une Notice est générée lorsque l&#8217;article ne contient pas d&#8217;image, l&#8217;auteur de la fonction sait qu&#8217;il recherche 1 image alors pourquoi recourir à <code>preg_match_all</code> au lieu d&#8217;un simple <code>preg_match</code>&#160;? C&#8217;est court donc c&#8217;est cool, c&#8217;est ça&#160;? (&#8216;o_o)&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:3">
<p>vous pouvez me flageller <img src='http://pioupioum.fr/wp/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> &#160;<a href="#fnref:3" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/outils-astuces/wordpress-recuperation-avancee-images-article.html/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>WordPress&#160;: lister les images d&#8217;un article sur une page media</title>
		<link>http://pioupioum.fr/outils-astuces/afficher-images-article-page-media.html</link>
		<comments>http://pioupioum.fr/outils-astuces/afficher-images-article-page-media.html#comments</comments>
		<pubDate>Wed, 26 Aug 2009 15:04:50 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Outils, trucs et astuces]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[suggestion]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=207</guid>
		<description><![CDATA[Julien a présenté ce 25 août 2009 une fonction d&#8217;affichage des miniatures liées à un même article pour WordPress. Bien que fonctionnelle, elle ne se révèle pas être des plus pratique.

Note&#160;:
J&#8217;écris ici même parce qu&#8217;en fin de billet je colle une fonction qui ferait un peu pavé dans les commentaires de l&#8217;article de Julien. Je [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p><a href="http://www.webinventif.fr/" title="Design web, applications, jQuery, Wordpress | Webinventif">Julien</a> a présenté ce 25 août 2009 une fonction d&#8217;<a href="http://www.webinventif.fr/wordpress-afficher-toutes-miniatures-liees-article-pages-media/" title="Wordpress : afficher toutes les miniatures liées à un article sur les pages média">affichage des miniatures liées à un même article</a> pour WordPress. Bien que fonctionnelle, elle ne se révèle pas être des plus pratique.</p>

<p><strong>Note&#160;:</strong><br />
J&#8217;écris ici même parce qu&#8217;en fin de billet je colle une fonction qui ferait un peu <em>pavé</em> dans les commentaires de l&#8217;article de Julien. Je ne fais également plus confiance aux services de pasties en ligne, ayant perdu trop d&#8217;extraits de code…
<span id="more-207"></span></p>

<p>Comme le relève <a href="http://www.webinventif.fr/wordpress-afficher-toutes-miniatures-liees-article-pages-media/#comment-42456" title="Se rendre à son commentaire">OncleTom</a>, la présentation et la logique sont mélangées.<br />
La fonction <code>wallthumb</code> dispose d&#8217;un argument <code>$id</code> qui est finalement inutile. Il sert simplement à tester la vignette courante, mais, comme la fonction est à appeler sur la page d&#8217;un media, l&#8217;élément courant est obligatoirement le media affiché.<br />
Enfin, les arguments de présentation cassent avec la logique introduite par WordPress. Dans son API, ce dernier fait généralement appel à un unique argument<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>, passé sous la forme d&#8217;un tableau ou d&#8217;une chaîne de caractères.</p>

<p>Ci-dessous, une fonction de remplacement à ajouter dans le fichier <code>functions.php</code> de votre thème.</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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Retrieve the list of images attached to the same post that the current attachment.
 *
 * @author Mehdi Kabab &lt;http://pioupioum.fr&gt;
 * @copyright Copyright (C) 2009 Mehdi Kabab
 * @license http://www.gnu.org/licenses/gpl.html  GNU GPL version 3 or later
 *
 * @link http://www.webinventif.fr/wordpress-afficher-toutes-miniatures-liees-article-pages-media/ Inspiration
 *
 * @param  string $output Optional. Constant for return type, either OBJECT (default), ARRAY_A, ARRAY_N.
 * @return array|bool False on failure
 **/</span>
<span style="color: #000000; font-weight: bold;">function</span> get_other_attachments<span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> OBJECT<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: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>is_attachment<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">===</span> <span style="color: #009900;">&#40;</span>bool<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_parent</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$attachments</span> <span style="color: #339933;">=</span> get_children<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'post_type'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'attachment'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'post_mime_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'image'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'post_status'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'inherit'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'post_parent'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_parent</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$attachments</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Display the HTML list of images attached to the same post that the current attachment.
 *
 * Only works on an attachment page.
 *
 * @author Mehdi Kabab &lt;http://pioupioum.fr&gt;
 * @copyright Copyright (C) 2009 Mehdi Kabab
 * @license http://www.gnu.org/licenses/gpl.html  GNU GPL version 3 or later
 *
 * @link http://www.webinventif.fr/wordpress-afficher-toutes-miniatures-liees-article-pages-media/ Inspiration
 *
 * @param  string|array $args Optional. User defined arguments for replacing the defaults.
 * @return bool False on failure.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> wallthumb<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: #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;">$attachments</span> <span style="color: #339933;">=</span> get_other_attachments<span style="color: #009900;">&#40;</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: #339933;">!</span><span style="color: #000088;">$attachments</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$defaults</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'id'</span>            <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'gallery-%d'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'current_class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'current'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'thumb_class'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'gallerythumb'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'before_thumb'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;li class=&quot;%s&quot;&gt;'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'after_thumb'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'before_list'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;ul id=&quot;%s&quot;&gt;'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'after_list'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$args</span>        <span style="color: #339933;">=</span> wp_parse_args<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #000088;">$defaults</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$current_id</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$thumb_class</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'thumb_class'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    static <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$stack</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'before_list'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">++</span><span style="color: #000088;">$i</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: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$attachments</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$attachment</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_id</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$attachment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$buf</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'before_thumb'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$thumb_class</span><span style="color: #009900;">&#41;</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;">$buf</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'before_thumb'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thumb_class</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'current_class'</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: #009900;">&#125;</span>
        <span style="color: #000088;">$buf</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;a href=&quot;%s&quot; title=&quot;%s&quot; rel=&quot;attachment&quot;&gt;%s&lt;/a&gt;'</span><span style="color: #339933;">,</span>
            get_attachment_link<span style="color: #009900;">&#40;</span><span style="color: #000088;">$attachment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            esc_attr<span style="color: #009900;">&#40;</span>get_the_title<span style="color: #009900;">&#40;</span><span style="color: #000088;">$attachment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            wp_get_attachment_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$attachment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thumbnail'</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$buf</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'after_thumb'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$stack</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$buf</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$stack</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #006699; font-weight: bold;">{$args['after_list']}</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html' title='WordPress : autoriser l&#8217;upload de fichiers au format non-supporté'>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</a></li><li><a href='http://pioupioum.fr/outils-astuces/wordpress-recuperation-avancee-images-article.html' title='WordPress : récupération avancée des images d&#8217;un article'>WordPress&#160;: récupération avancée des images d&#8217;un article</a></li><li><a href='http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html' title='WordPress jQuery UI Effects'>WordPress jQuery UI Effects</a></li><li><a href='http://pioupioum.fr/outils-astuces/faille-wordpress-mot-passe-correctif.html' title='Correctif pour la faille WordPress de réinitialisation de mot de passe'>Correctif pour la faille WordPress de réinitialisation de mot de passe</a></li><li><a href='http://pioupioum.fr/outils-astuces/wordpress-smartypants-shortcode-caption.html' title='WordPress et SmartyPants : des légendes qui disparaissent'>WordPress et SmartyPants&#160;: des légendes qui disparaissent</a></li></ul>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>Voir la fonction <a href="http://codex.wordpress.org/Function_Reference/register_sidebar" title="Function Reference/register sidebar &laquo; WordPress Codex">register_sidebar</a> par exemple.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/outils-astuces/afficher-images-article-page-media.html/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Correctif pour la faille WordPress de réinitialisation de mot de passe</title>
		<link>http://pioupioum.fr/outils-astuces/faille-wordpress-mot-passe-correctif.html</link>
		<comments>http://pioupioum.fr/outils-astuces/faille-wordpress-mot-passe-correctif.html#comments</comments>
		<pubDate>Tue, 11 Aug 2009 12:41:37 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Outils, trucs et astuces]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[sécurité]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=194</guid>
		<description><![CDATA[Une faille a été récemment découverte dans WordPress. Elle permet à quiconque de forcer la réinitialisation de mot de passe du compte admin (compte par défaut de WordPress).

Diverses &#8220;solutions&#8221; ont été apportées notamment par Korben ou encore par l&#8217;équipe de développement de l&#8217;outil de blogging.

Cependant ces correctifs sont crades&#160;: ils nous obligent à directement modifier [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Une faille a été récemment découverte dans WordPress. Elle permet à quiconque de forcer la réinitialisation de mot de passe du compte admin (compte par défaut de WordPress).</p>

<p>Diverses &#8220;solutions&#8221; ont été apportées notamment par <a href="http://www.korben.info/se-proteger-du-hack-wordpress-2-8-3-qui-reinitialise-le-mot-de-passe.html" title="Se protéger du hack wordpress 2.8.3 qui réinitialise le mot de passe">Korben</a> ou encore par l&#8217;<a href="http://www.geekeries.fr/articles/faille-wordpress-reinitialisation-du-mot-de-passe/" title="Faille WordPress : Réinitialisation du mot de passe | Geekeries.fr - Astuces Wordpress 2.8, Plugins Wordpress 2.8, Blogging, Référencement, Actualités High Tech">équipe de développement</a> de l&#8217;outil de blogging.</p>

<p>Cependant ces correctifs sont <em>crades</em>&#160;: ils nous obligent à directement modifier le fichier <code>wp-login.php</code> de WordPress. Vous allez me dire que cela n&#8217;est pas gravisime compte tenu du fait qu&#8217;une mise à jour de WordPress sortira sous peu. Certes. Mais je déteste agir directement sur les sources de l&#8217;outil si ce dernier m&#8217;offre des points d&#8217;entrées pour arriver à mes fins depuis l&#8217;extérieur.</p>

<p>Ainsi, il vous suffit d&#8217;ajouter ce morceau de code dans le fichier <code>functions.php</code> de votre thème pour fixer le trou de sécurité.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> fixes_reset_password_security<span style="color: #009900;">&#40;</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;">$wp_version</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">version_compare</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_version</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'2.8.3'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;='</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span>
        <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">!==</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SCRIPT_FILENAME'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp-login.php'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span>
        <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'key'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'key'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #009900;">&#123;</span>
        <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'key'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fixes_reset_password_security'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/outils-astuces/wordpress-smartypants-shortcode-caption.html' title='WordPress et SmartyPants : des légendes qui disparaissent'>WordPress et SmartyPants&#160;: des légendes qui disparaissent</a></li><li><a href='http://pioupioum.fr/developpement/shortcode-wordpress-integrer-flux-rss.html' title='Shortcode WordPress : intégrer un flux RSS'>Shortcode WordPress&#160;: intégrer un flux RSS</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html' title='WordPress : autoriser l&#8217;upload de fichiers au format non-supporté'>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</a></li><li><a href='http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html' title='WordPress jQuery UI Effects'>WordPress jQuery UI Effects</a></li><li><a href='http://pioupioum.fr/outils-astuces/wordpress-recuperation-avancee-images-article.html' title='WordPress : récupération avancée des images d&#8217;un article'>WordPress&#160;: récupération avancée des images d&#8217;un article</a></li></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/outils-astuces/faille-wordpress-mot-passe-correctif.html/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>WordPress et SmartyPants&#160;: des légendes qui disparaissent</title>
		<link>http://pioupioum.fr/outils-astuces/wordpress-smartypants-shortcode-caption.html</link>
		<comments>http://pioupioum.fr/outils-astuces/wordpress-smartypants-shortcode-caption.html#comments</comments>
		<pubDate>Fri, 07 Aug 2009 13:10:57 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Outils, trucs et astuces]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[shortcode]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=186</guid>
		<description><![CDATA[Si comme moi vous utilisez Typographer, extension de SmartyPants1, en tant que plugin WordPress vous l&#8217;aurez certainement relevé&#160;: son activation entraîne la disparition des légendes pour les images.

Pour corriger cet effet de bord, éditez le fichier smartypants.php2 pour y remplacer la priorité d&#8217;application des filtres the_content et the_excerpt (originellement à 10)&#160;:


137
138
add_filter&#40;'the_content', 'SmartyPants', 11&#41;;
add_filter&#40;'the_excerpt', 'SmartyPants', 11&#41;;


Le [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Si comme moi vous utilisez <em><a href="http://michelf.com/projets/php-smartypants/typographer/" title="PHP SmartyPants Typographer">Typographer</a></em>, extension de <strong><a href="http://michelf.com/projets/php-smartypants/" title="PHP SmartyPants">SmartyPants</a></strong><sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>, en tant que plugin <a href="http://fr.wordpress.org/" title="WordPress | France">WordPress</a> vous l&#8217;aurez certainement relevé&#160;: son activation entraîne la disparition des <strong>légendes</strong> pour les images.</p>

<p>Pour corriger cet effet de bord, éditez le fichier <code>smartypants.php</code><sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup> pour y remplacer la priorité d&#8217;application des filtres <code>the_content</code> et <code>the_excerpt</code> (originellement à 10)&#160;:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>137
138
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'SmartyPants'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">11</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_excerpt'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'SmartyPants'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">11</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<p>Le plugin SmartyPants Typographer<sup id="fnref:3"><a href="#fn:3" rel="footnote">3</a></sup> entre ainsi en action après le traitement du shortcode <strong>caption</strong>.</p>

<p>Le bug et son correctif ont été reportés auprès de <a href="http://michelf.com/" title="ici Michel Fortin">Michel Fortin</a>.</p>

<p><strong>Mise à jour du 09/08/2009</strong><br />
Le correctif sera appliqué dans la prochaine version de SmartyPants (et son extension Typographer).</p>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/developpement/shortcode-wordpress-integrer-flux-rss.html' title='Shortcode WordPress : intégrer un flux RSS'>Shortcode WordPress&#160;: intégrer un flux RSS</a></li><li><a href='http://pioupioum.fr/outils-astuces/faille-wordpress-mot-passe-correctif.html' title='Correctif pour la faille WordPress de réinitialisation de mot de passe'>Correctif pour la faille WordPress de réinitialisation de mot de passe</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html' title='WordPress : autoriser l&#8217;upload de fichiers au format non-supporté'>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</a></li><li><a href='http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html' title='WordPress jQuery UI Effects'>WordPress jQuery UI Effects</a></li><li><a href='http://pioupioum.fr/outils-astuces/wordpress-recuperation-avancee-images-article.html' title='WordPress : récupération avancée des images d&#8217;un article'>WordPress&#160;: récupération avancée des images d&#8217;un article</a></li></ul>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>ici, SmartyPants version 1.5.1oo2.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>dans le cas de l&#8217;extension <abbr title="WordPress">WP</abbr> SmartyPants, le correctif est à appliquer aux lignes 61 et 62.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:3">
<p>SmartyPants Typographer version 1.0.&#160;<a href="#fnref:3" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/outils-astuces/wordpress-smartypants-shortcode-caption.html/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Get Author&#8217;s Comments</title>
		<link>http://pioupioum.fr/plugins-wordpress/get-authors-comments.html</link>
		<comments>http://pioupioum.fr/plugins-wordpress/get-authors-comments.html#comments</comments>
		<pubDate>Mon, 03 Aug 2009 14:45:18 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Plugins WordPress]]></category>
		<category><![CDATA[commentaires]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[projet]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=168</guid>
		<description><![CDATA[Get Author&#8217;s Comments est un plugin pour WordPress permettant de récupérer ou d&#8217;afficher la liste des commentaires posté par un utilisateur. De nombreuses options sont disponibles offrant entre autres comme possibilités de&#160;:


lister les commentaires d&#8217;un utilisateur dans l&#8217;article courant.
récupérer les commentaires qu&#8217;une personne a posté dans un article donné.
afficher les 10 derniers commentaires d&#8217;un utilisateur.
etc.


Afin [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p><strong>Get Author&#8217;s Comments</strong> est un <strong>plugin</strong> pour <strong><a href="http://wordpress.org/" title="WordPress &#8250; Blog Tool and Publishing Platform">WordPress</a></strong> permettant de récupérer ou d&#8217;afficher la liste des <strong>commentaires</strong> posté par un utilisateur. De nombreuses options sont disponibles offrant entre autres comme possibilités de&#160;:</p>

<ul>
<li>lister les commentaires d&#8217;un utilisateur dans l&#8217;article courant.</li>
<li>récupérer les commentaires qu&#8217;une personne a posté dans un article donné.</li>
<li>afficher les 10 derniers commentaires d&#8217;un utilisateur.</li>
<li>etc.</li>
</ul>

<p>Afin d&#8217;éviter les homonymes, un utilisateur est identifié par son nom et son ou ses adresses e-mails.</p>

<p>En affichage direct, <strong>Get Author&#8217;s Comments</strong> produit des items de liste (&lt;li>). Il se base en effet sur la fonction <a href="http://codex.wordpress.org/Template_Tags/wp_list_comments" title="Template Tags/wp list comments &laquo; WordPress Codex">wp_list_comments</a> qui a été introduite dans la version 2.7 de l&#8217;API de WordPress.
<span id="more-168"></span></p>

<h2 id="toc">Table des matières</h2>

<ol>
<li><a href="#telecharger">Téléchargement</a></li>
<li><a href="#installer">Installation</a></li>
<li><a href="#exemples">Exemples d&#8217;utilisation</a></li>
<li><a href="#parametres">Liste des paramètres</a></li>
<li><a href="#todo">Tâches à faire</a></li>
<li><a href="#changelog">Historique des versions et changelog</a></li>
</ol>

<h2 id="telecharger">Téléchargement</h2>

<div class="download box">
    <a href="http://downloads.wordpress.org/plugin/get-authors-comments.1.1.0.zip" title="Téléchargement depuis les serveurs de WordPress.org"><span>Télécharger la dernière version du plugin Get Author&#8217;s Comments</span></a>
</div>

<p>Vous pouvez également vous rendre sur la <a href="http://wordpress.org/extend/plugins/get-authors-comments/" title="WordPress &#8250; Get Author's Comments &laquo; WordPress Plugins">page WordPress.org du plugin</a> ou lancer son téléchargement et installation directement depuis l&#8217;interface d&#8217;administration de votre WordPress.</p>

<h2 id="installer">Installation</h2>

<p>Get Author&#8217;s Comments s&#8217;installe en 3 étapes&#160;:</p>

<ol>
<li>Téléversez le répertoire <code>get_authors_comments</code> dans votre répertoire <code>/wp-content/plugins/</code>.</li>
<li>Activez le plugin <code>Get Author's Comments</code> <em>via</em> le menu <em>Extensions</em> du pannel d&#8217;administration de WordPress.</li>
<li>Utilisez-le dans votre thème&#160;:</li>
</ol>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>function_exist<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ppm_author_comments'</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>
    &lt;ol&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> ppm_author_comments<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'nom'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'email'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post_ID'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'args'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;/ol&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<h2 id="exemples">Exemples d&#8217;utilisation</h2>

<h3>Afficher les commentaires d&#8217;un utilisateur postés dans l&#8217;article courant</h3>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #339933;">&lt;</span>ol<span style="color: #339933;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> ppm_author_comments<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'piouPiouM'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'foo@example.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;/ol&gt;
?&gt;</pre></td></tr></table></div>


<p>Ou, si l&#8217;utilisateur <em>piouPiouM</em> a écrit avec 2 adresses e-mails différentes&#160;:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #339933;">&lt;</span>ol<span style="color: #339933;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> ppm_author_comments<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'piouPiouM'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'foo@example.com'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'bar@example.org'</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>
    &lt;/ol&gt;
?&gt;</pre></td></tr></table></div>


<h3>Afficher l&#8217;intégralité des commentaires posté par un utilisateur sur le site</h3>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #339933;">&lt;</span>ol<span style="color: #339933;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> ppm_author_comments<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'piouPiouM'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'foo@example.com'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'all=1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;/ol&gt;
?&gt;</pre></td></tr></table></div>


<h3>Lister les commentaires rédigés par un utilisateur dans l&#8217;article ayant 9 pour identifiant</h3>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #339933;">&lt;</span>ol<span style="color: #339933;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> ppm_author_comments<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'piouPiouM'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'foo@example.com'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;/ol&gt;
?&gt;</pre></td></tr></table></div>


<p><strong>Note&#160;:</strong><br />
Si vous utilisez les fonctions <code>ppm_author_comments</code> ou <code>ppm_get_author_comments</code> à l&#8217;intérieur de <a href="http://codex.wordpress.org/fr:La_Boucle" title="La Boucle &laquo; WordPress Codex">la boucle</a>, l&#8217;argument <code>$postID</code> sera remplacé automatiquement par l&#8217;identifiant numérique de l&#8217;article courant s&#8217;il n&#8217;était pas renseigné ou défini à <code>null</code>.</p>

<h3>Afficher les derniers commentaires d&#8217;un utilisateur, ordonnés par post_ID</h3>

<p>Le code qui suit sert à lister les 10 derniers commentaires de piouPiouM, ordonnés par post_ID ascendant, et affichera la date et l&#8217;extrait des commentaires concernés.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #000088;">$comments</span> <span style="color: #339933;">=</span> ppm_get_author_comments<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'piouPiouM'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'foo@example.com'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'number=10&amp;order=ASC&amp;orderby=post_id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$comments</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$comment</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;p&gt;&lt;cite&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_author_link<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/cite&gt; à dit&amp;nbsp;:&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;
        &lt;p&gt;Commentaire posté le <span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_date<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'n-j-Y'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>:&lt;br/&gt;&lt;/p&gt;
        &lt;p&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_excerpt<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>&lt;/p&gt;
    &lt;/li&gt;
&lt;/ol&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<h3>Commentaires avec un affichage personnalisé</h3>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #339933;">&lt;</span>ol<span style="color: #339933;">&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> ppm_author_comments<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'piouPiouM'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'info@example.com'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'callback=mytheme_comment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;/ol&gt;
?&gt;</pre></td></tr></table></div>


<p>Se reporter à la page <a href="http://codex.wordpress.org/Template_Tags/wp_list_comments#Comments_Only_With_A_Custom_Comment_Display" title="Template Tags/wp list comments &laquo; WordPress Codex">Comments Only With A Custom Comment Display</a> pour un exemple d&#8217;utilisation de la fonction de callback.</p>

<h3>Afficher un compteur des commentaires posté par l&#8217;utilisateur identifié sur le site</h3>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    get_currentuserinfo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$comments</span> <span style="color: #339933;">=</span> ppm_get_author_comments<span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$current_user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_email</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'all=1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Hello &lt;a href=&quot;/author/%s/&quot;&gt;%s&lt;/a&gt;&amp;nbsp;! '</span>
         <span style="color: #339933;">.</span> <span style="color: #0000ff;">'[ &lt;a href=&quot;%s&quot; class=&quot;logout&quot;&gt;Déconnexion&lt;/a&gt; ]&lt;br/&gt;'</span>
         <span style="color: #339933;">.</span> <span style="color: #0000ff;">'%d articles and %d commentaires'</span><span style="color: #339933;">,</span>
        <span style="color: #000088;">$current_user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_login</span><span style="color: #339933;">,</span>
        <span style="color: #000088;">$current_user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display_name</span><span style="color: #339933;">,</span>
        wp_logout_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        get_usernumposts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$comments</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></td></tr></table></div>


<p>Produira le code HTML&#160;:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">Hello &lt;a href=&quot;/author/piouPiouM/&quot;&gt;piouPiouM&lt;/a&gt;&amp;nbsp;! [ &lt;a href=&quot;http://www.example.com/wp-login.php?action=logout&amp;amp;_wpnonce=xxxxxxxxxx&quot; class=&quot;logout&quot;&gt;Déconnexion&lt;/a&gt; ]&lt;br/&gt;
12 articles and 35 commentaires</pre></td></tr></table></div>


<p><div id="attachment_167" class="wp-caption aligncenter" style="width: 620px"><a href="http://assets1.pioupioum.fr/uploads/2009/08/get-authors-comment-la-lune-mauve.jpg" title="Agrandir"><img src="http://assets1.pioupioum.fr/uploads/2009/08/get-authors-comment-la-lune-mauve-610x205.jpg" alt="Afficher un compteur de commentaires pour un utilisateur donné" width="610" height="205" class="size-medium wp-image-167"/></a><p class="wp-caption-text">Afficher un compteur de commentaires pour un utilisateur donné. Source&#160;: <a href='http://www.lalunemauve.fr/'>La Lune Mauve</a>.</p></div></p>

<h2 id="parametres">Liste des paramètres</h2>

<p>Voici la liste des paramètres acceptés par le 4<sup>ème</sup> argument <code>$args</code> des fontions <code>ppm_get_author_comments</code> et <code>ppm_author_comments</code>&#160;:</p>

<p><strong>all</strong><br />
<em>(boolean)</em> <em>(optionnel)</em> Récupérer tous les commentaires. Par défaut à <em>FALSE</em>.</p>

<p><strong>number</strong><br />
<em>(integer)</em> <em>(optionnel)</em> Le nombre de commentaires à retourner. Par défaut à <em>None</em>, retourne tous les commentaires.</p>

<p><strong>offset</strong><br />
<em>(integer)</em> <em>(optionnel)</em> Numéro de commentaire à partir duquel la recherche sera effectuée. Par défaut à 0.</p>

<p><strong>orderby</strong><br />
<em>(string)</em> <em>(optionnel)</em> Ordonner les commentaires par l&#8217;une ou plusieurs des valeurs qui suivent (séparées par un espace)&#160;:</p>

<ul>
<li><code>'comment_ID'</code> - Trier numériquement par l&#8217;ID des commentaires.</li>
<li><code>'content'</code> - Trier suivant le contenu.</li>
<li><code>'date'</code> - Trier selon la date de création. (Par Défaut)</li>
<li><code>'post_ID'</code> - Trier numériquement par l&#8217;ID des articles.</li>
<li><code>'rand'</code> - Trier aléatoirement.</li>
<li><code>'status'</code> - Trier par statut.</li>
<li><code>'type'</code> - Trier par type.</li>
</ul>

<p><strong>order</strong><br />
<em>(string)</em> <em>(optionnel)</em> Ordre de tri. Les valeurs valides sont&#160;:</p>

<ul>
<li><code>'ASC'</code> - Croissant (du plus petit au plus grand).</li>
<li><code>'DESC'</code> - Décroissant (du plus grand au plus petit). (Par défaut)</li>
</ul>

<p><strong>output</strong><br />
<em>(string)</em> <em>(optionnel)</em> Le format de sortie. Seulement pour <code>ppm_get_author_comments</code>.</p>

<ul>
<li><code>OBJECT</code> - Retourne un objet. (Default)</li>
<li><code>ARRAY_A</code> - Retourne un tableau associatif (nom des champs => valeurs).</li>
<li><code>ARRAY_N</code> - Retourne un tableau indexé numériquement de la valeur des champs.</li>
<li><code>HTML</code> - Retourne une version (x)HTML générée par la fonction <a href="http://codex.wordpress.org/Template_Tags/wp_list_comments">wp&#95;list&#95;comments</a>.</li>
</ul>

<p><strong>status</strong><br />
<em>(string)</em> <em>(optionnel)</em> Les statut des commentaires. Par défaut à «&thinsp;en attente&thinsp;» et «&thinsp;approuvé&thinsp;». Valeurs valides&#160;:</p>

<ul>
<li><code>'hold'</code> - En attente de validation.</li>
<li><code>'approve'</code> - Approuvé.</li>
<li><code>'spam'</code> - Indésirable.</li>
</ul>

<h2 id="todo">Tâches à faire</h2>

<p>Fonctionnalités en attente de développement.</p>

<ul>
<li>Tester la prise en charge de la pagination.</li>
</ul>

<h2 id="changelog">Historique des versions et changelog</h2>

<h3>1.1.0</h3>

<ul>
<li>Ajout du paramètre <code>all</code> permettant de récupérer tous les commentaires d&#8217;un utilisateur.</li>
<li>Ajout du changelog et de nouveaux exemples d&#8217;utilisation.</li>
</ul>

<h3>1.0.1</h3>

<ul>
<li>Les paramètres de <code>$args</code> sont désormais non sensibles à la casse.</li>
<li>Support de 2 nouveaux paramètres de tri&#160;: <code>comment_ID</code> et <code>post_ID</code>.</li>
<li>Définit par défaut le tri par <code>date</code>.</li>
</ul>

<h3>1.0.0</h3>

<ul>
<li>Version initiale.</li>
</ul>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html' title='WordPress jQuery UI Effects'>WordPress jQuery UI Effects</a></li><li><a href='http://pioupioum.fr/plugins-spip/google-tools-1-0-1.html' title='SPIP Google Tools 1.0.1'>SPIP Google Tools 1.0.1</a></li><li><a href='http://pioupioum.fr/plugins-spip/google-tools.html' title='SPIP Google Tools'>SPIP Google Tools</a></li><li><a href='http://pioupioum.fr/outils-astuces/license-helper-textmate-bundle.html' title='Bundle License Helper pour TextMate'>Bundle License Helper pour TextMate</a></li><li><a href='http://pioupioum.fr/developpement/jquery-color-plugin-animation-rgba-support.html' title='Du RGBA dans vos animations avec le plugin jQuery Color'>Du RGBA dans vos animations avec le plugin jQuery Color</a></li></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/plugins-wordpress/get-authors-comments.html/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WordPress et index.html&#160;: supprimer les erreurs 404</title>
		<link>http://pioupioum.fr/outils-astuces/wordpress-supprimer-erreur-404-page-index.html</link>
		<comments>http://pioupioum.fr/outils-astuces/wordpress-supprimer-erreur-404-page-index.html#comments</comments>
		<pubDate>Sun, 02 Aug 2009 11:40:11 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Outils, trucs et astuces]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[404]]></category>
		<category><![CDATA[permalien]]></category>
		<category><![CDATA[URL rewrinting]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=160</guid>
		<description><![CDATA[C&#8217;est en consultant mes statistiques de fréquentation que je me suis aperçu que des accès se faisaient sur des pages virtuelles comme http://pioupioum.fr/index.html ou encore http://pioupioum.fr/contact/index.html. Malheureusement, WordPress retournait un code HTTP 404&#160;; les pages étaient introuvables.

Utilisant la structure de permaliens /%category%/%postname%.html, un accès à la page index.html contraint WordPress à rechercher un article ayant [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>C&#8217;est en consultant mes statistiques de fréquentation que je me suis aperçu que des accès se faisaient sur des pages virtuelles comme http://pioupioum.fr/index.html ou encore http://pioupioum.fr/contact/index.html. Malheureusement, WordPress retournait un code HTTP 404&#160;; les pages étaient introuvables.</p>

<p>Utilisant la structure de <a href="http://fr.wikipedia.org/wiki/Permalien" title="Permalien - Wikipédia">permaliens</a> <code>/%category%/%postname%.html</code>, un accès à la page <code>index.html</code> contraint WordPress à rechercher un article ayant pour <em>slug</em> (identifiant) <code>index</code>. Bien évidemment je n&#8217;en ai pas.</p>

<p>Je corrige ce comportement en complétant les règles de réécriture d&#8217;URLs de WordPress avec les lignes 6 à 8 de cet extrait de mon fichier .htaccess&#160;:</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
</pre></td><td class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;"># BEGIN WordPress</span>
&lt;<span style="color: #000000; font-weight:bold;">IfModule</span> mod_rewrite.c&gt;
    <span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span>
    <span style="color: #00007f;">RewriteBase</span> /
&nbsp;
    <span style="color: #adadad; font-style: italic;"># Eviter l'erreur 404 sur les pages index.html</span>
    <span style="color: #00007f;">RewriteCond</span> %{THE_REQUEST} ^.*/index.html
    <span style="color: #00007f;">RewriteRule</span> ^(.*)index.html /$<span style="color: #ff0000;">1</span> [R=<span style="color: #ff0000;">301</span>,L]
&nbsp;
    <span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME} !-f
    <span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME} !-d
    <span style="color: #00007f;">RewriteRule</span> . /index.php [L]
&lt;/<span style="color: #000000; font-weight:bold;">IfModule</span>&gt;
<span style="color: #adadad; font-style: italic;"># END WordPress</span></pre></td></tr></table></div>


<p>En clair, dès qu&#8217;un utilisateur cherchera à atteindre une page <code>index.html</code> Apache le redirigera vers son niveau hiérarchique parent.</p>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html' title='WordPress : autoriser l&#8217;upload de fichiers au format non-supporté'>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</a></li><li><a href='http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html' title='WordPress jQuery UI Effects'>WordPress jQuery UI Effects</a></li><li><a href='http://pioupioum.fr/outils-astuces/wordpress-recuperation-avancee-images-article.html' title='WordPress : récupération avancée des images d&#8217;un article'>WordPress&#160;: récupération avancée des images d&#8217;un article</a></li><li><a href='http://pioupioum.fr/outils-astuces/afficher-images-article-page-media.html' title='WordPress : lister les images d&#8217;un article sur une page media'>WordPress&#160;: lister les images d&#8217;un article sur une page media</a></li><li><a href='http://pioupioum.fr/outils-astuces/faille-wordpress-mot-passe-correctif.html' title='Correctif pour la faille WordPress de réinitialisation de mot de passe'>Correctif pour la faille WordPress de réinitialisation de mot de passe</a></li></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/outils-astuces/wordpress-supprimer-erreur-404-page-index.html/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Shortcode WordPress&#160;: intégrer un flux RSS</title>
		<link>http://pioupioum.fr/developpement/shortcode-wordpress-integrer-flux-rss.html</link>
		<comments>http://pioupioum.fr/developpement/shortcode-wordpress-integrer-flux-rss.html#comments</comments>
		<pubDate>Fri, 17 Jul 2009 01:02:36 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Développement Web]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[shortcode]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=70</guid>
		<description><![CDATA[Dans son article Mastering WordPress Shortcodes, Smashing Magazine nous invite dans son 4ème exemple à intégrer le contenu d&#8217;un flux RSS dans vos billets WordPress à l&#8217;aide d&#8217;un shortcode.

Houston, on a un problème

Reprenons le code donné dans l&#8217;article&#160;:


1
2
3
4
5
6
7
8
9
10
11
12
13
//This file is needed to be able to use the wp_rss() function.
include_once&#40;ABSPATH.WPINC.'/rss.php'&#41;;
&#160;
function readRss&#40;$atts&#41; &#123;
    extract&#40;shortcode_atts&#40;array&#40;
 [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Dans son article <a href="http://www.smashingmagazine.com/2009/02/02/mastering-wordpress-shortcodes/" title="Mastering WordPress Shortcodes | Developer&#039;s Toolbox | Smashing Magazine">Mastering WordPress Shortcodes</a>, <a href="http://www.smashingmagazine.com/" title="Smashing Magazine">Smashing Magazine</a> nous invite dans son 4<sup>ème</sup> exemple à intégrer le contenu d&#8217;un flux <abbr title="Really Simple Syndication">RSS</abbr> dans vos billets <a href="http://www.wordpress-fr.net/" title="WordPress Francophone – La communauté du CMS Opensource">WordPress</a> à l&#8217;aide d&#8217;un <a href="http://codex.wordpress.org/Shortcode_API" title="Shortcode API » WordPress Codex">shortcode</a>.</p>

<h2>Houston, on a un problème</h2>

<p>Reprenons le code donné dans l&#8217;article&#160;:</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="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//This file is needed to be able to use the wp_rss() function.</span>
<span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span>ABSPATH<span style="color: #339933;">.</span>WPINC<span style="color: #339933;">.</span><span style="color: #0000ff;">'/rss.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> readRss<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">&quot;feed&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://'</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">&quot;num&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1'</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> wp_rss<span style="color: #009900;">&#40;</span><span style="color: #000088;">$feed</span><span style="color: #339933;">,</span> <span style="color: #000088;">$num</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rss'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'readRss'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<p>Si vous le testez, comme <a href="http://twitter.com/Fran6/status/2671399288" title="sur twitter">@Fran6</a> par exemple, vous constaterez que le résultat n&#8217;est pas celui escompté&#160;: le flux de syndication précède le contenu de votre article au lieu d&#8217;être inséré là où vous l&#8217;attendiez.<span id="more-70"></span></p>

<p>La raison&#160;? À la <code>ligne 10</code>, le résultat de la fonction <code>wp_rss()</code> est retourné au moteur de WordPress pour remplacer le shortcode dans le contenu du billet. Or, la fonction <code>wp_rss()</code> <strong>ne retourne rien</strong> mais <strong>affiche directement</strong> le résultat. Ainsi, tout appel du shortcode entraîne l&#8217;envoi au client du flux <abbr title="Really Simple Syndication">RSS</abbr> (sous la forme d&#8217;une liste non-ordonnée) suivi du contenu du billet.</p>

<h2>Solution</h2>

<p>On corrige le <a href="http://codex.wordpress.org/Shortcode_API" title="Shortcode API » WordPress Codex">shortcode</a> en capturant la sortie de la fonction <code>wp_rss()</code> à l&#8217;aide d&#8217;une <a href="http://fr.php.net/manual/fr/intro.outcontrol.php" title="PHP: Contrôle de l'affichage - Introduction - Manual">tamporisation de sortie</a>.</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//This file is needed to be able to use the wp_rss() function.</span>
<span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span>ABSPATH<span style="color: #339933;">.</span>WPINC<span style="color: #339933;">.</span><span style="color: #0000ff;">'/rss.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> readRss<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">&quot;feed&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">&quot;num&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1'</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    wp_rss<span style="color: #009900;">&#40;</span><span style="color: #000088;">$feed</span><span style="color: #339933;">,</span> <span style="color: #000088;">$num</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">ob_get_clean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rss'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'readRss'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/outils-astuces/wordpress-smartypants-shortcode-caption.html' title='WordPress et SmartyPants : des légendes qui disparaissent'>WordPress et SmartyPants&#160;: des légendes qui disparaissent</a></li><li><a href='http://pioupioum.fr/outils-astuces/faille-wordpress-mot-passe-correctif.html' title='Correctif pour la faille WordPress de réinitialisation de mot de passe'>Correctif pour la faille WordPress de réinitialisation de mot de passe</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html' title='WordPress : autoriser l&#8217;upload de fichiers au format non-supporté'>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</a></li><li><a href='http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html' title='WordPress jQuery UI Effects'>WordPress jQuery UI Effects</a></li><li><a href='http://pioupioum.fr/outils-astuces/wordpress-recuperation-avancee-images-article.html' title='WordPress : récupération avancée des images d&#8217;un article'>WordPress&#160;: récupération avancée des images d&#8217;un article</a></li></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/developpement/shortcode-wordpress-integrer-flux-rss.html/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
