<?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 de la catégorie Outils, trucs et astuces &#8211; piouPiouM&#039;s dev</title>
	<atom:link href="http://pioupioum.fr/outils-astuces/feed/" rel="self" type="application/rss+xml" />
	<link>http://pioupioum.fr</link>
	<description>Bloc-note d&#039;un développeur web</description>
	<lastBuildDate>Mon, 30 Apr 2012 09:42:02 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Page Fan&#160;: ajout simplifié d&#8217;application onglet à vos pages fan Facebook</title>
		<link>http://pioupioum.fr/outils-astuces/facebook-application-add-page-tab-bookmarklet.html</link>
		<comments>http://pioupioum.fr/outils-astuces/facebook-application-add-page-tab-bookmarklet.html#comments</comments>
		<pubDate>Fri, 23 Dec 2011 20:53:42 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Outils, trucs et astuces]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=562</guid>
		<description><![CDATA[Facebook a annoncé la suppression des profils d&#8217;applications au 1er février 2012. Vous ne pourrez plus associer une application onglet à une page fan comme vous le faisiez actuellement. En effet, la page de profil d&#8217;une application mettait à disposition un lien pour ajouter cette dernière à/aux page(s) fan de votre choix.

Facebook propose bien de [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p><strong>Facebook</strong> a annoncé la <strong><a href="https://developers.facebook.com/blog/post/611/">suppression des profils d&#8217;applications</a></strong> au 1er février 2012. Vous ne pourrez plus associer une application onglet à une page fan comme vous le faisiez actuellement. En effet, la page de profil d&#8217;une application mettait à disposition un lien pour ajouter cette dernière à/aux page(s) fan de votre choix.</p>

<p>Facebook propose bien de créer manuellement une page associée à votre application, mais vu son utilité autant s&#8217;en passer. À la place, et pour éviter 50 clics supplémentaires, je vous propose, amis <em>Community manager</em>, un <strong>bookmarklet</strong> qui permet d&#8217;associer aisément vos applications à des <strong>pages fan Facebook</strong>.<span id="more-562"></span></p>

<h2>Mise en place du bookmarklet</h2>

<p>Glissez-déposez simplement le lien ci-dessous dans les favoris de votre navigateur&#160;; dans votre barre personnelle par exemple.</p>

<div class="box bookmarklet">
    <a href="javascript:(function(a,b,c,d,e,f,g){c=a.location,f=%22developers.facebook.com%22;if(f!==c.hostname||!a[b]){alert(%22Veuillez%20vous%20placer%20sur%20le%20profil%20d%27une%20application%20Facebook.%22);return}try{g=new%20RegExp(f.replace(/\./g,%22\\.%22)+%22/apps/(\\d+)(?:/*)?$%22,%22i%22),d=g.exec(c.href)[1]}catch(h){d=prompt(%22Veuillez%20saisir%20l%27identifiant%20de%20l%27application%22,%22%22);if(d==null)return}e=a[b].getDomain(%22https_www%22),c.href=e+%22/dialog/pagetab?app_id=%22+d+%22&#038;display=page&#038;redirect_uri=%22+e})(window,%22FB%22);" title='Adding an app to a Page – Facebook'><span>FB Add Page Tab</span></a>
</div>

<h2>Utilisation du bookmarklet <em>Facebook Add Page Tab</em></h2>

<p>Rendez-vous sur la page de configuration de votre application<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> puis cliquez sur le <strong>bookmarklet</strong>. Ce dernier vous redirige vers une page Facebook vous demandant les pages qui accueilleront votre application. L&#8217;association faite, vous serez redirigés sur l&#8217;accueil de Facebook, et pourrez accéder à votre/vos page(s) mise(s) à jour <em>via</em> le moteur de recherche ou le manager de pages.</p>

<p><div id="attachment_561" class="wp-caption aligncenter" style="width: 513px"><a href="http://assets1.pioupioum.fr/uploads/2011/12/facebook-configuration-application.jpg"><img src="http://assets1.pioupioum.fr/uploads/2011/12/facebook-configuration-application-503x350.jpg" alt="Page de configuration d&#039;une application Facebook" title="facebook-configuration-application" width="503" height="350" class="size-medium wp-image-561" /></a><p class="wp-caption-text">Page de configuration d&#8217;une application Facebook</p></div></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/dailymotion-download-bookmarklet.html' title='Dailymotion Download Bookmarklet'>Dailymotion Download Bookmarklet</a></li><li><a href='http://pioupioum.fr/developpement/javascript-array-intersection.html' title='JavaScript : optimiser le calcul de l&#8217;intersection de tableaux de grandes tailles'>JavaScript&#160;: optimiser le calcul de l&#8217;intersection de tableaux de grandes tailles</a></li><li><a href='http://pioupioum.fr/developpement/jslint-console-rhino.html' title='Une console JSLint pour aider vos validations JavaScript'>Une console JSLint pour aider vos validations JavaScript</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/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>

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

<li id="fn:1">
<p>il s&#8217;agit de la page sur laquelle vous récupérez l&#8217;ID de l&#8217;application.&#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/facebook-application-add-page-tab-bookmarklet.html/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Shortcode WordPress&#160;: afficher les documents liés aux billets</title>
		<link>http://pioupioum.fr/outils-astuces/wordpress-shortcode-afficher-fichiers-joints.html</link>
		<comments>http://pioupioum.fr/outils-astuces/wordpress-shortcode-afficher-fichiers-joints.html#comments</comments>
		<pubDate>Thu, 23 Sep 2010 06:55:29 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Outils, trucs et astuces]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[shortcode]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=453</guid>
		<description><![CDATA[J&#8217;ai récemment eu besoin d&#8217;afficher de manière élégante les pièces jointes à des articles et des pages. Seulement, avec un WordPress qui autorise l&#8217;ajout de documents autres que des images/vidéos et rien pour les insérer proprement dans un contenu, la tâche est loin d&#8217;être aisée.


  Un coup de XHTML et roule ma poule&#160;!


Oui&#160;! Si [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>J&#8217;ai récemment eu besoin d&#8217;afficher de manière élégante les <strong>pièces jointes</strong> à des articles et des pages. Seulement, avec un <strong>WordPress</strong> qui autorise l&#8217;ajout de documents autres que des images/vidéos et rien pour les insérer proprement dans un contenu, la tâche est loin d&#8217;être aisée.</p>

<blockquote>
  <p>Un coup de XHTML et roule ma poule&#160;!</p>
</blockquote>

<p>Oui&#160;! Si j&#8217;étais le rédacteur du site (comme ici). Mais il n&#8217;en est rien. Il fallait une solution utilisable depuis l&#8217;éditeur WYSIWYG, sans avoir à intervenir sur la source XHTML (genre pour ajouter un div, une image, des classes CSS, etc).</p>

<p>Voici donc un <strong><a href="http://codex.wordpress.org/Shortcode_API" title="Shortcode API &laquo; WordPress Codex">shortcode</a> WordPress</strong> qui <strong>affiche la liste des pièces jointes</strong>.</p>

<p><div id="attachment_468" class="wp-caption aligncenter" style="width: 620px"><img src="http://assets1.pioupioum.fr/uploads/2010/09/wp-shortcode-attachments.png" alt="Le shortcode en action" title="Shortcode attachments - Illustration" width="610" height="255" class="size-full wp-image-468"/><p class="wp-caption-text">Le shortcode en action</p></div><span id="more-453"></span></p>

<h2>Table des matières</h2>

<ol>
<li><a href="#telecharger">Code source</a></li>
<li><a href="#styles">Différents styles d&#8217;affichage</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="#personnaliser">Personnaliser le shortcode</a></li>
<li><a href="#changelog">Historique des versions et changelog</a></li>
</ol>

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

<p>Le shortcode présenté dans ce billet nécessite la présence de la <a href="http://pioupioum.fr/snippets/wordpress-create-shortcode-class.html" title="WordPress : une classe abstraite pour aider la création de shortcodes &#8211; PHP abstract class to create shortcodes in WordPress – piouPiouM&#039;s dev">classe abstraite d&#8217;aide à la création de shortcode</a> <strong>PPM_Shortcode</strong>. Si ce n&#8217;est pas déjà fait, récupérez-là et rendez-la disponible pour la classe <code>AttachmentsListShortCode</code>.</p>

<p>Copiez le code qui suit dans le fichier <code>functions.php</code> de votre thème<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
</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;">/**
 * Add the new shortcode `attachments`.
 */</span>
<span style="color: #000088;">$attachments_list</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AttachmentsListShortCode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'attachments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$attachments_list</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">register</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Shortcode to display a list of attachments of the current post.
 *
 * Attributes to use as follows:
 *     'exclude' - Default is none. List of IDs of the attachments to exclude of search.
 *     'orderby' - Default is 'title ASC'. How to order the attachments.
 *     'style'   - Default is 'large'. Presentation style to use.
 *
 * @author Mehdi Kabab &lt;http://pioupioum.fr/&gt;
 * @copyright Copyright (C) 2010 Mehdi Kabab
 * @license http://www.gnu.org/licenses/gpl.html  GNU GPL version 3 or later
 * @version 1.0.0
 * @link http://pioupioum.fr/outils-astuces/wordpress-shortcode-afficher-fichiers-joints.html
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> AttachmentsListShortCode <span style="color: #000000; font-weight: bold;">extends</span> PPM_Shortcode
<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
     * Default options.
     *
     * @var array
     **/</span>
    protected <span style="color: #000088;">$_default_options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'exclude'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'orderby'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'title ASC'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'style'</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>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Keys allowed in the query ORDER BY clause.
     *
     * @param array
     */</span>
    protected <span style="color: #000088;">$_allowed_orderby</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'mime_type'</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Directory of MIME icons.
     * The path is relative to the current theme.
     *
     * @var string
     */</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_icons_dir</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Clause ORDER BY to be applied to sorting.
     *
     * @var string
     */</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_orderby</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Stack of the presentation styles for the attachments.
     *
     * @var ArrayObject
     **/</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_styles</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Constructor.
     *
     * @param string $tag Shortcode tag to be searched in post content.
     * @param string $icons_dir Directory of MIME icons.
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tag</span><span style="color: #339933;">,</span> <span style="color: #000088;">$icons_dir</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'images/mime'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIconsDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$icons_dir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_styles <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayObject<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                                         ArrayObject<span style="color: #339933;">::</span><span style="color: #004000;">ARRAY_AS_PROPS</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;">$this</span><span style="color: #339933;">-&gt;</span>_getDefaultStyles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$tpl</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$data</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: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'default'</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: #000088;">$default</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>boolean<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'default'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'default'</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: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$default</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tpl</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #000088;">$default</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Retrieve directory of MIME icons.
     *
     * @return string
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getIconsDirectory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_icons_dir<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Set the directory of MIME icons.
     *
     * @return PPM_Shortcode
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setIconsDirectory<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_icons_dir <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Retrieve the stack of the presentation styles.
     *
     * @return ArrayObject
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getStyles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_styles<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Set a presentation style of the attachments.
     *
     * @param string $name Presentation style name.
     * @param array $data Style data.
     * @param boolean $default True for set this style as default style.
     * @return PPM_Shortcode
     * @throws Exception If the data are not valid.
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setStyle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #000088;">$default</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</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: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_isValidStyle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            throw <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Data for the style `%s` are not valid!'</span><span style="color: #339933;">,</span>
                                        <span style="color: #000088;">$name</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;">$this</span><span style="color: #339933;">-&gt;</span>_styles<span style="color: #009900;">&#91;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayObject<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span>
                                                   ArrayObject<span style="color: #339933;">::</span><span style="color: #004000;">ARRAY_AS_PROPS</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;">true</span> <span style="color: #339933;">===</span> <span style="color: #000088;">$default</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setStyleByDefault</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Retrieve name of the presentation style used by default.
     *
     * @return string
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getStyleByDefault<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_default_options<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'style'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Set name of the presentation style to use by default.
     *
     * @param string $name
     * @return PPM_Shortcode
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setStyleByDefault<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_default_options<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'style'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$name</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * [filter] Edit the clause ORDER BY to allow sorting by mime_type.
     *
     * @param string $orderby The ORDER BY clause.
     * @return string The new ORDER BY clause.
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> filterOrderby<span style="color: #009900;">&#40;</span><span style="color: #000088;">$orderby</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: #009900; font-weight: bold;">null</span> <span style="color: #339933;">!==</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_orderby <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_orderby<span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_allowed_orderby<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$orderby</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#^([^\.]+\.)(\w+)(\s+ASC|DESC)$#i'</span><span style="color: #339933;">,</span>
                                    <span style="color: #0000ff;">'$1post_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_orderby <span style="color: #339933;">.</span> <span style="color: #0000ff;">'$3'</span><span style="color: #339933;">,</span>
                                    <span style="color: #000088;">$orderby</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$orderby</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @see PPM_Shortcode::_process()
     */</span>
    protected <span style="color: #000000; font-weight: bold;">function</span> _process<span style="color: #009900;">&#40;</span><span style="color: #000088;">$attributes</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</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: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getStyles</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">offsetExists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'style'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$style</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'style'</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;">$style</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getStyleByDefault</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;
        <span style="color: #666666; font-style: italic;">// Order and Order by clauses</span>
        <span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$orderby</span><span style="color: #339933;">,</span> <span style="color: #000088;">$order</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_default_options<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'orderby'</span><span style="color: #009900;">&#93;</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: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'orderby'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' '</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$orderby</span><span style="color: #339933;">,</span> <span style="color: #000088;">$order</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'orderby'</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: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$orderby</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'orderby'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_orderby <span style="color: #339933;">=</span> <span style="color: #000088;">$orderby</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Retrieve the attachments</span>
        <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_parent'</span> <span style="color: #339933;">=&gt;</span> get_the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</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;">'numberposts'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'exclude'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'exclude'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'orderby'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_orderby<span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'order'</span>       <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ASC'</span> <span style="color: #339933;">===</span> <span style="color: #990000;">strtoupper</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$order</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'ASC'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'DESC'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'exclude'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'exclude'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'suppress_filters'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #666666; font-style: italic;">// Allows to edit the query</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">===</span> <span style="color: #000088;">$attachments</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Edit the query</span>
        add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posts_orderby'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'filterOrderby'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$tpl</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getStyles</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$style</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: #666666; font-style: italic;">// Do not display image attachments</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">===</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attachment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_mime_type</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'image/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// Determine the filename</span>
            <span style="color: #000088;">$file_type</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attachment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_mime_type</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/-'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'__'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$file_name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getIconsDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file_type</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.png'</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span>get_stylesheet_directory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file_name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$icon_file</span> <span style="color: #339933;">=</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'stylesheet_directory'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span>
                             <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file_name</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;">$icon_file</span> <span style="color: #339933;">=</span> wp_mime_type_icon<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>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'getimagesize'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$size_attr</span> <span style="color: #339933;">=</span>  <span style="color: #990000;">getimagesize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$icon_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$size_attr</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$size_attr</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$size_attr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #000088;">$file_path</span> <span style="color: #339933;">=</span> get_attached_file<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>
            <span style="color: #000088;">$context</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: #000088;">$attachment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'filename'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attachment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">guid</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'file_date'</span> <span style="color: #339933;">=&gt;</span> mysql2date<span style="color: #009900;">&#40;</span>get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'date_format'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                                          <span style="color: #000088;">$attachment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_date</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'file_size'</span> <span style="color: #339933;">=&gt;</span> esc_attr<span style="color: #009900;">&#40;</span>size_format<span style="color: #009900;">&#40;</span><span style="color: #990000;">filesize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_path</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: #0000ff;">'file_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$attachment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_mime_type</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'file_url'</span>  <span style="color: #339933;">=&gt;</span> esc_attr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$attachment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">guid</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'icon_atts'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$size_attr</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'icon_path'</span> <span style="color: #339933;">=&gt;</span> esc_attr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$icon_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'title'</span>     <span style="color: #339933;">=&gt;</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>
                <span style="color: #0000ff;">'label_filename'</span>  <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'File name:'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'label_file_date'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Upload date:'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'label_file_size'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Size:'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// Hook for customize the context</span>
            <span style="color: #000088;">$context</span> <span style="color: #339933;">=</span> apply_filters<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'attachments_list_context'</span><span style="color: #339933;">,</span>
                                     <span style="color: #000088;">$context</span><span style="color: #339933;">,</span>
                                     <span style="color: #000088;">$attachment</span><span style="color: #339933;">,</span>
                                     <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getStyles</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$style</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$result</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_compileMarkup<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tpl</span><span style="color: #339933;">,</span> <span style="color: #000088;">$context</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$tpl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">before</span> <span style="color: #339933;">.</span> do_shortcode<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$result</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$tpl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">after</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Performs substitutions in the markup of the selected presentation style.
     *
     * @param ArrayObject $tpl
     * @param array $context
     * @return string The markup after substitutions.
     */</span>
    protected <span style="color: #000000; font-weight: bold;">function</span> _compileMarkup<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tpl</span><span style="color: #339933;">,</span> <span style="color: #000088;">$context</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$markup</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$tpl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">markup</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$context</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$markup</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'%'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #339933;">,</span> <span style="color: #000088;">$markup</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$markup</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Retrieve the default stack of the presentation styles.
     *
     * Declare the `medium`, `small` and `large` presentation styles.
     *
     * @return array
     */</span>
    protected <span style="color: #000000; font-weight: bold;">function</span> _getDefaultStyles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'medium'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                <span style="color: #0000ff;">'before'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;div class=&quot;attachments-list-medium&quot;&gt;'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'after'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;/div&gt;'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'markup'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;div class=&quot;attachment-item attachment-%ID%&quot;&gt;'</span> <span style="color: #339933;">.</span>
                            <span style="color: #0000ff;">'&lt;a href=&quot;%file_url%&quot; title=&quot;%title% (%file_size%)&quot; rel=&quot;attachment&quot;&gt;'</span> <span style="color: #339933;">.</span>
                            <span style="color: #0000ff;">'&lt;img src=&quot;%icon_path%&quot;%icon_atts% alt=&quot;&quot;/&gt;&lt;small&gt;%title%&lt;/small&gt;&lt;/a&gt;'</span> <span style="color: #339933;">.</span> 
                            <span style="color: #0000ff;">'&lt;/div&gt;'</span>
            <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'small'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                <span style="color: #0000ff;">'before'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;div class=&quot;attachments-list-small&quot;&gt;'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'after'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;/div&gt;'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'markup'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;div class=&quot;attachment-small-icon attachment-%ID%&quot;&gt;'</span> <span style="color: #339933;">.</span>
                            <span style="color: #0000ff;">'&lt;img src=&quot;%icon_path%&quot;%icon_atts% alt=&quot;&quot;/&gt;'</span> <span style="color: #339933;">.</span>
                            <span style="color: #0000ff;">'&lt;a href=&quot;%file_url%&quot; title=&quot;%title%&quot; rel=&quot;attachment&quot;&gt;'</span> <span style="color: #339933;">.</span>
                            <span style="color: #0000ff;">'%title%&lt;/a&gt;&amp;nbsp;(%file_size%)'</span> <span style="color: #339933;">.</span> 
                            <span style="color: #0000ff;">'&lt;/div&gt;'</span>
            <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'large'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                <span style="color: #0000ff;">'before'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;div class=&quot;attachments-list-large&quot;&gt;'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'after'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;/div&gt;'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'markup'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;dl class=&quot;attachment-item attachment-%ID%&quot;&gt;'</span> <span style="color: #339933;">.</span>
                            <span style="color: #0000ff;">'&lt;dt&gt;&lt;a href=&quot;%file_url%&quot; title=&quot;%title%&quot; rel=&quot;attachment&quot;&gt;'</span> <span style="color: #339933;">.</span>
                            <span style="color: #0000ff;">'&lt;img class=&quot;alignleft&quot; src=&quot;%icon_path%&quot;%icon_atts% alt=&quot;&quot;/&gt;'</span> <span style="color: #339933;">.</span>
                            <span style="color: #0000ff;">'%title%&lt;/a&gt;&lt;/dt&gt;'</span> <span style="color: #339933;">.</span>
                            <span style="color: #0000ff;">'&lt;dd&gt;&lt;span&gt;%label_filename%&lt;/span&gt; %filename%&lt;/dd&gt;'</span> <span style="color: #339933;">.</span>
                            <span style="color: #0000ff;">'&lt;dd&gt;&lt;span&gt;%label_file_date%&lt;/span&gt; %file_date%&lt;/dd&gt;'</span> <span style="color: #339933;">.</span>
                            <span style="color: #0000ff;">'&lt;dd&gt;&lt;span&gt;%label_file_size%&lt;/span&gt; %file_size%&lt;/dd&gt;'</span> <span style="color: #339933;">.</span>
                            <span style="color: #0000ff;">'&lt;/dl&gt;'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'default'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span>
            <span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Test if the data of a presentation style are well formed.
     *
     * @param array $data
     * @return boolean
     */</span>
    protected <span style="color: #000000; font-weight: bold;">function</span> _isValidStyle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$ok</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span> <span style="color: #339933;">===</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</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;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'before'</span><span style="color: #009900;">&#93;</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;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'after'</span><span style="color: #009900;">&#93;</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;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'markup'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$ok</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<p>Il vous faut également intégrer à votre thème les styles CSS qui suivent. Ceux-ci demeurant être une suggestion.</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
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.attachments-list-large</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.attachments-list-medium</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.attachments-list-small</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.attachments-list-large</span> <span style="color: #6666ff;">.attachment-item</span> img<span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.attachments-list-medium</span> <span style="color: #6666ff;">.attachment-item</span> img<span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.attachments-list-small</span> <span style="color: #6666ff;">.attachment-item</span> img <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.attachments-list-large</span> <span style="color: #6666ff;">.attachment-item</span> dl <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1.5em</span> <span style="color: #933;">1em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.attachments-list-large</span> <span style="color: #6666ff;">.attachment-item</span> dt <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.attachments-list-large</span> <span style="color: #6666ff;">.attachment-item</span> dd <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0.85em</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.5em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.attachments-list-large</span> <span style="color: #6666ff;">.attachment-item</span> img <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.attachments-list-large</span> <span style="color: #6666ff;">.attachment-item</span> img <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.attachments-list-medium</span> <span style="color: #6666ff;">.attachment-item</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline-table</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.5em</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">0.15em</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.attachments-list-medium</span> <span style="color: #6666ff;">.attachment-item</span> a <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.attachments-list-medium</span> <span style="color: #6666ff;">.attachment-item</span> small <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0.85em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.attachments-list-small</span> img <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> text-<span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">16px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">16px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>


<p>Ou si vous utilisez SCSS&#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
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
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.attachments-list-large</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.attachments-list-medium</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.attachments-list-small</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1em</span><span style="color: #00AA00;">;</span>
    <span style="color: #6666ff;">.attachment-item</span> <span style="color: #00AA00;">&#123;</span>
        img <span style="color: #00AA00;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
        <span style="color: #00AA00;">&#125;</span>
    <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.attachments-list-large</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #6666ff;">.attachment-item</span> <span style="color: #00AA00;">&#123;</span>
        $space<span style="color: #00AA00;">:</span> <span style="color: #933;">1em</span><span style="color: #00AA00;">;</span>
        dl <span style="color: #00AA00;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #00AA00;">&#40;</span>$space <span style="color: #00AA00;">+</span> <span style="color: #933;">0.5em</span><span style="color: #00AA00;">&#41;</span> $space<span style="color: #00AA00;">;</span>
        <span style="color: #00AA00;">&#125;</span>
        dt <span style="color: #00AA00;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
        <span style="color: #00AA00;">&#125;</span>
        dd <span style="color: #00AA00;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0.85em</span><span style="color: #00AA00;">;</span>
            <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #00AA00;">&#40;</span>$space <span style="color: #00AA00;">+</span> <span style="color: #933;">0.5em</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
        <span style="color: #00AA00;">&#125;</span>
        img <span style="color: #00AA00;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
            <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
            <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #00AA00;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span> $space<span style="color: #00AA00;">;</span>
            <span style="color: #00AA00;">&#125;</span>
        <span style="color: #00AA00;">&#125;</span>
    <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.attachments-list-medium</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #6666ff;">.attachment-item</span> <span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline-table</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.5em</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">0.15em</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10em</span><span style="color: #00AA00;">;</span>
        a <span style="color: #00AA00;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
        <span style="color: #00AA00;">&#125;</span>
        small <span style="color: #00AA00;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
            <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0.85em</span><span style="color: #00AA00;">;</span>
        <span style="color: #00AA00;">&#125;</span>
    <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.attachments-list-small</span> <span style="color: #00AA00;">&#123;</span>
    img <span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> text-<span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">16px</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">16px</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>


<h2 id="styles">Différents styles d&#8217;affichage</h2>

<p>Le <strong>shortcode attachments</strong> propose trois formats d&#8217;affichage des pièces jointes&#160;: <em>medium</em>, <em>large</em> (par défaut) et <em>small</em>.</p>

<p><img src="http://assets1.pioupioum.fr/uploads/2010/09/attachment-shortcode-small.png" alt="Shortcode attachments - Style small" title="Shortcode attachments - Style small" width="600" height="200" class="aligncenter size-full wp-image-479" /></p>

<pre><code>[attachments style="small"]
</code></pre>

<p><img src="http://assets1.pioupioum.fr/uploads/2010/09/attachment-shortcode-medium.png" alt="Shortcode attachments - Style medium" title="Shortcode attachments - Style medium" width="600" height="310" class="aligncenter size-full wp-image-482" /></p>

<pre><code>[attachments style="medium"]
</code></pre>

<p><img src="http://assets1.pioupioum.fr/uploads/2010/09/attachment-shortcode-large.png" alt="Shortcode attachments - Style large" title="Shortcode attachments - Style large" width="600" height="345" class="aligncenter size-full wp-image-483" /></p>

<pre><code>[attachments style="large"]
</code></pre>

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

<h3>Usage basique</h3>

<pre><code>[attachments]
</code></pre>

<h3>Exclure des documents de la liste</h3>

<p>Ici, nous excluons de la liste les documents ayant les identifiants <code>53</code> et <code>56</code>.</p>

<pre><code>[attachments exclude="53,56"]
</code></pre>

<h3>Liste des documents triés par date de mise en ligne</h3>

<pre><code>[attachments orderby="date"]
</code></pre>

<h3>Liste des documents triés par date, les plus récents en premier</h3>

<pre><code>[attachments orderby="date DESC"]
</code></pre>

<h3>Liste des documents triés par type de document</h3>

<pre><code>[attachments orderby="mime_type"]
</code></pre>

<h3>Cumul des paramètres</h3>

<p>Les paramètres peuvent être cumulés, sans ordre précis.</p>

<pre><code>[attachments style="large" exclude="53" orderby="date"]
</code></pre>

<h3>Ajouter un titre à la liste</h3>

<p>Le <strong>shortcode attachments</strong> existe aussi en forme englobante. Tout contenu englobé préfixera la liste des pièces jointes générées.</p>

<p><img src="http://assets1.pioupioum.fr/uploads/2010/09/attachment-shortcode-large-content.png" alt="Shortcode attachments - Avec contenu" title="Shortcode attachments - Avec contenu" width="600" height="195" class="aligncenter size-full wp-image-484" /></p>

<pre><code>[attachments]
&lt;h2&gt;Avec un contenu&lt;/h2&gt;
&lt;p&gt;Ce shortcode englobe le titre qui précède et ce paragraphe.&lt;/p&gt;
[/attachments]
</code></pre>

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

<p>Voici la liste des paramètres acceptés par le shortcode <code>attachments</code>&#160;:</p>

<p><strong>exclude</strong><br />
<em>(optionnel)</em> La liste des ID séparés par des virgules des documents à exclure de la liste. Vide par défaut. Toutes les pièces jointes au contenu sont affichées.</p>

<p><strong>orderby</strong><br />
<em>(optionnel)</em> Le type de tri appliqué à la liste. Par défaut <em>title ASC</em>, les document sont triés par titre et par ordre alphabétique.</p>

<p><strong>style</strong>
<em>(optionnel)</em> Le type de présentation de la liste. Trois formats sont disponibles&#160;: <code>small</code>, <code>medium</code> et <code>large</code> (par défaut). Se reporter aux <a href="#exemples">exemples</a> pour avoir des aperçus.</p>

<h2 id="personnaliser">Personnaliser le shortcode</h2>

<p>Afin de correspondre aux besoins du plus grand nombre, le <strong>shortcode attachments</strong> offre diverses possibilités de personnalisation.</p>

<h3>Ajouter un type de présentation</h3>

<p>Si vous souhaitez afficher une simple liste ordonnée des pièces jointes, déclarez un nouveau style au shortcode comme suit&#160;:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</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;">$attachments_list</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AttachmentsListShortCode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'attachments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$ol_style</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'before'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;ol class=&quot;attachments-list-ol&quot;&gt;'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'after'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;/ol&gt;'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'markup'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;li&gt;&lt;a href=&quot;%file_url%&quot; rel=&quot;attachment&quot;&gt;%title%&lt;/a&gt;&lt;/li&gt;'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$attachments_list</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ol'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ol_style</span><span style="color: #009900;">&#41;</span>
                 <span style="color: #339933;">-&gt;</span><span style="color: #004000;">register</span><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></td></tr></table></div>


<p>Puis, appelez-le dans un billet&#160;:</p>

<pre><code>[attachments style="ol"]
</code></pre>

<p><img src="http://assets1.pioupioum.fr/uploads/2010/09/attachment-shortcode-customized.png" alt="Shortcode attachments - Style personnalisé" title="Shortcode attachments - Style personnalisé" width="600" height="215" class="aligncenter size-full wp-image-491" /></p>

<p>Notez que la déclaration d&#8217;un style peut se faire après l&#8217;enregistrement du shortcode. La seule contrainte étant de la faire avant l&#8217;appel au shortcode par WordPress.</p>

<p>Si vous souhaitez définir un style de présentation à utiliser par défaut, deux possibilités&#160;:</p>

<ul>
<li>Lors de la déclaration d&#8217;un style, préciser la clé <code>'default' =&gt; true</code>.</li>
<li>À l&#8217;aide de la méthode <code>setStyleByDefault($name)</code>&#160;: <code>$attachments_list-&gt;setStyleByDefault('ol);</code>.</li>
</ul>

<p>Ci-après, la liste des différentes tags disponibles pour vos styles&#160;:</p>

<ul>
<li><strong>ID</strong>. L&#8217;identifiant de la pièce jointe.</li>
<li><strong>title</strong>. Le titre de la pièce jointe.</li>
<li><strong>filename</strong>. Le nom de fichier de la pièce jointe.</li>
<li><strong>file_date</strong>. La date de transfert de la pièce jointe.</li>
<li><strong>file_size</strong>. La taille de la pièce jointe, en [K|M]Bytes.</li>
<li><strong>file_type</strong>. Le type MIME du fichier.</li>
<li><strong>file_url</strong>. L&#8217;URL de téléchargement de la pièce jointe.</li>
<li><strong>icon_atts</strong>. D&#8217;éventuels attributs ajoutés à la balise <code>&lt;img/&gt;</code>.</li>
<li><strong>icon_path</strong>. L&#8217;URL de l&#8217;icône illustrative.</li>
<li><strong>label_filename</strong>. Label annonçant le titre du fichier.</li>
<li><strong>label&#95;file_date</strong>. Label annonçant la date de transfert du document.</li>
<li><strong>label&#95;file_size</strong>. Label annonçant la taille de la pièce jointe.</li>
</ul>

<h3>Personnaliser les icônes</h3>

<p>Par défaut le shortcode affiche les icônes disponibles dans WordPress. Le shortcode permet d&#8217;utiliser un set d&#8217;icône personnalisé.</p>

<p>Il suffit pour cela de déclarer un chemin d&#8217;accès aux icônes des différents types MIME. Par défaut <em>images/mime</em>. Ce chemin <strong>doit être</strong> <em>relatif au dossier du thème</em>.</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: #000088;">$attachments_list</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AttachmentsListShortCode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pièces jointes'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$attachments_list</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIconsDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'img/icons'</span><span style="color: #009900;">&#41;</span>
                 <span style="color: #339933;">-&gt;</span><span style="color: #004000;">register</span><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></td></tr></table></div>


<p>Afin que les icônes soient récupérées, les fichiers images des types MIME doivent être de la forme <code>type_mime.png</code>.<br />
C&#8217;est à dire qu&#8217;un document PDF de type MIME <code>application/pdf</code> aura pour icône le fichier <code>application_pdf.png</code>. Un document ODT de type MIME <code>application/vnd.oasis.opendocument.text</code> se référera quand à lui à l&#8217;image <code>application_vnd.oasis.opendocument.text.png</code>.</p>

<p>J&#8217;utilise le pack d&#8217;<a href="http://kde-look.org/content/show.php/Oxygen+Icons?content=74184" title="Oxygen Icons KDE-Look.org">icônes Oxygen</a> dans les exemples présentés de cette page.</p>

<h3>Filtre <code>attachments_list_context</code></h3>

<p>Le filtre <code>attachments_list_context</code> permet de modifier le contexte qui sera utilisé pour réaliser les substitions dans le style de présentation.</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
</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> filter_attachments_list_context<span style="color: #009900;">&#40;</span><span style="color: #000088;">$context</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attachment</span><span style="color: #339933;">,</span> <span style="color: #000088;">$size</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// WordPress ne comportant pas de chaîne 'Size:', cette</span>
    <span style="color: #666666; font-style: italic;">// dernière ne peut être localisée automatiquement.</span>
    <span style="color: #666666; font-style: italic;">// Travaillant sur un site exclusivement localisé en français</span>
    <span style="color: #666666; font-style: italic;">// on peut se permettre les deux traitements qui suivent.</span>
    <span style="color: #000088;">$context</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'label_file_size'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Taille&amp;nbsp;:'</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$context</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file_size'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$context</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file_size'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'B'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'o'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$context</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'attachments_list_context'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'filter_attachments_list_context'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</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>


<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-create-shortcode-class.html' title='WordPress : une classe abstraite pour aider la création de shortcodes'>WordPress&#160;: une classe abstraite pour aider la création de shortcodes</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/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/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>ou dans un fichier à part, à inclure dans le fichier <code>functions.php</code>.&#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/wordpress-shortcode-afficher-fichiers-joints.html/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Bundle License Helper pour TextMate</title>
		<link>http://pioupioum.fr/outils-astuces/license-helper-textmate-bundle.html</link>
		<comments>http://pioupioum.fr/outils-astuces/license-helper-textmate-bundle.html#comments</comments>
		<pubDate>Thu, 29 Jul 2010 16:29:29 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Outils, trucs et astuces]]></category>
		<category><![CDATA[licence MIT]]></category>
		<category><![CDATA[projet]]></category>
		<category><![CDATA[TextMate]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=426</guid>
		<description><![CDATA[Parce que j&#8217;en avais ma claque de chercher le texte des licences à ajouter en en-tête de mes sources1, voici un bundle TextMate pour palier à cette répétitive perte de temps.



Table des matières


Installation
Utilisation du bundle
Personnaliser le sélecteur des licences
Corriger le formatage de la licence
Licences supportées
Développement


Installation

Depuis les sources, avec Git

cd ~/Library/Application\ Support/TextMate/Bundles
git clone git://github.com/piouPiouM/license-helper.tmbundle.git "License Helper.tmbundle"
osascript [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Parce que j&#8217;en avais ma claque de chercher le texte des licences à ajouter en en-tête de mes sources<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>, voici un <strong><a href="http://pioupioum.fr/tag/textmate/" title="Archives pour le tag TextMate – piouPiouM&#039;s dev">bundle TextMate</a></strong> pour palier à cette répétitive perte de temps.</p>

<p><img src="http://assets1.pioupioum.fr/uploads/2010/07/License-Helper-Textmate-Bundle.png" alt="License Helper Textmate Bundle" title="License Helper Textmate Bundle" width="610" height="385" class="aligncenter size-full wp-image-431" /><span id="more-426"></span></p>

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

<ol>
<li><a href="#installer">Installation</a></li>
<li><a href="#usage">Utilisation du bundle</a></li>
<li><a href="#personnaliser">Personnaliser le sélecteur des licences</a></li>
<li><a href="#formatage">Corriger le formatage de la licence</a></li>
<li><a href="#licenses">Licences supportées</a></li>
<li><a href="#developpement">Développement</a></li>
</ol>

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

<h3>Depuis les sources, avec Git</h3>

<pre><code>cd ~/Library/Application\ Support/TextMate/Bundles
git clone git://github.com/piouPiouM/license-helper.tmbundle.git "License Helper.tmbundle"
osascript -e 'tell app "TextMate" to reload bundles'
</code></pre>

<h3>Depuis les sources, sans Git</h3>

<pre><code>cd ~/Library/Application\ Support/TextMate/Bundles
wget http://github.com/piouPiouM/license-helper.tmbundle/tarball/master
tar zxf license-helper.tmbundle.tar.gz
rm license-helper.tmbundle.tar.gz
mv license-helper.tmbundle "License Helper.tmbundle"
osascript -e 'tell app "TextMate" to reload bundles'
</code></pre>

<h3>Téléchargement direct</h3>

<div class="download box">
    <a href="http://github.com/piouPiouM/license-helper.tmbundle/tarball/master" title="Téléchargement depuis les serveurs de GitHub"><span>Télécharger la dernière version du bundle License Helper pour TextMate</span></a>
</div>

<p>Après récupération, décompressez l&#8217;archive, renommez le dossier en <code>License Helper.tmbundle</code>. Acceptez le changement d&#8217;extension. Il ne reste plus qu&#8217;à installer le bundle d&#8217;un double-clic sur le fichier.</p>

<h2 id="usage">Utilisation du bundle</h2>

<p>Utilisez le lanceur <code>license⇥</code> pour <strong>sélectionner une licence</strong> <em>via</em> la boîte de dialogue qui s&#8217;affiche.</p>

<p><div id="attachment_427" class="wp-caption aligncenter" style="width: 349px"><img src="http://assets1.pioupioum.fr/uploads/2010/07/license-helper-textmate-bundle-dialog.png" alt="Choix d&#039;une licence – License Helper Textmate Bundle" title="license-helper-textmate-bundle-dialog" width="339" height="384" class="size-full wp-image-427" /><p class="wp-caption-text">Choix d&#8217;une licence – License Helper Textmate Bundle</p></div></p>

<p>Un bloc de licence est inséré en tant que Snippet. Utilisez la touche de tabulation pour vous déplacez sur les différents placeholders.</p>

<h3>Liste des variables d&#8217;environnement utilisées</h3>

<p>Déclarez dans votre projet les variables d&#8217;environnement qui suivent pour auto-compléter les blocs de licence à insérer&#160;:</p>

<ul>
<li><code>TM_PROJECT_YEAR</code>. L&#8217;année de production. Par défaut&#160;: l&#8217;année courante.</li>
<li><code>TM_PROJECT_COPYRIGHT_HOLDERS</code> ou <code>TM_AUTHOR</code> ou <code>TM_ORGANIZATION_NAME</code>. Les détenteurs du copyright.</li>
<li><code>TM_ORGANIZATION_EMAIL</code>. Adresse mail de l&#8217;organisation détentrice du copyright.</li>
<li><code>TM_PROJECT_DESCRIPTION</code>. Description brève du projet.</li>
</ul>

<p>Notez que les variables sont utilisées en fonction de la licence choisie et qu&#8217;il n&#8217;est pas nécessaire de toutes les renseigner si vous n&#8217;en avez pas l&#8217;usage.</p>

<p>Vous pouvez fixer la licence de votre projet en ajoutant la variable d&#8217;environnement de projet <code>TM_PROJECT_LICENSE</code>. Ainsi, vous n&#8217;aurez plus à la sélectionner.</p>

<h2 id="personnaliser">Personnaliser le sélecteur des licences</h2>

<p>La commande accessible depuis le menu <em>License Helper → Edit licenses order</em> lance l&#8217;édition du fichier de configuration du bundle.<br />
Modifiez l&#8217;ordre des licences déclarées selon vos préférences d&#8217;apparition dans le sélecteur de licences.</p>

<h2 id="formatage">Corriger le formatage de la licence</h2>

<p>Il est possible qu&#8217;avec certains langages, le rendu des blocs de licences ne corresponde pas à vos attentes. Si tel est le cas, définissez votre propre format&#160;:</p>

<ol>
<li>Bundles → Bundle Editor</li>
<li>Dans l&#8217;entrée <strong>License Helper</strong>, créez une nouvelle Preference et donnez-lui le nom du langage.</li>
<li>Remplissez le champ Scope Selector avec le scope approprié – i.e. <code>source.java</code> pour les sources java.</li>
<li>Définissez les shellVariables <code>TM_LICENSE_HELPER_HEADER</code> (début du bloc de commentaire) et <code>TM_LICENSE_HELPER_FOOTER</code> (fin du bloc de commentaire), comme suit&#160;:</li>
</ol>

<pre>{  shellVariables = (
        {   name = 'TM_LICENSE_HELPER_HEADER';
            value = '/*';
        },
        {   name = 'TM_LICENSE_HELPER_FOOTER';
            value = '*/';
        },
    );
}</pre>

<p><strong>Note&#160;:</strong> chacune des lignes de la licence peut être préfixée de la variable <code>TM_LICENSE_HELPER_LINE</code>.</p>

<h2 id="licenses">Licences supportées</h2>

<p>La liste des licences prises en charge par le plugin n&#8217;est pas figée. N&#8217;hésitez pas à me <a href="#developpement">soumettre</a> celles qui vous font défaut.</p>

<ul>
<li><a href="http://www.opensource.org/licenses/agpl-v3.html" title="GNU AFFERO GENERAL PUBLIC LICENSE v3 | Open Source Initiative">Affero GNU Public License 3.0</a></li>
<li><a href="http://www.opensource.org/licenses/apache2.0.php" title="Open Source Initiative OSI - Apache License, Version 2.0:Licensing | Open Source Initiative">Apache license 2.0</a></li>
<li><a href="http://www.cecill.info/" title="CeCILL">CeCILL license</a></li>
<li><a href="http://sam.zoy.org/wtfpl/" title="WTFPL - Do What The Fuck You Want To Public License">Do What The Fuck You Want To Public License</a></li>
<li><a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html" title="GNU General Public License v2.0 - GNU Project - Free Software Foundation (FSF)">GNU General Public License version 2</a></li>
<li><a href="http://www.gnu.org/licenses/gpl-3.0.html" title="The GNU General Public License - GNU Project - Free Software Foundation (FSF)">GNU General Public License version 3</a></li>
<li><a href="http://www.gnu.org/licenses/lgpl.html" title="GNU Lesser General Public License - GNU Project - Free Software Foundation (FSF)">GNU Lesser General Public License version 3</a></li>
<li><a href="http://www.opensource.org/licenses/mit-license.html" title="Open Source Initiative OSI - The MIT License:Licensing | Open Source Initiative">MIT license</a></li>
<li><a href="http://www.opensource.org/licenses/bsd-license.php" title="Open Source Initiative OSI - The BSD License:Licensing | Open Source Initiative">New and Simplified BSD licenses</a></li>
<li><a href="http://www.opensource.org/licenses/bsd-license.php" title="Open Source Initiative OSI - The BSD License:Licensing | Open Source Initiative">Original BSD license</a></li>
<li><a href="http://www.opensource.org/licenses/postgresql" title="The PostgreSQL Licence (TPL) | Open Source Initiative">PostgreSQL license</a></li>
</ul>

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

<p>Distribué sous <a href="http://www.opensource.org/licenses/mit-license.html" title="Open Source Initiative OSI - The MIT License:Licensing | Open Source Initiative">license MIT</a>, le <a href="http://github.com/piouPiouM/license-helper.tmbundle" title="piouPiouM's license-helper.tmbundle at master - GitHub">code source du bundle</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/license-helper.tmbundle/issues" title="Issues - piouPiouM/license-helper.tmbundle - GitHub">bugtracker</a> 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/snippets/textmate-commande-exporter-mots-word-wrap.html' title='TextMate : commande &laquo;&nbsp;Export words&nbsp;&raquo;'>TextMate&#160;: commande &laquo;&nbsp;Export words&nbsp;&raquo;</a></li><li><a href='http://pioupioum.fr/outils-astuces/textmate-convertir-couleur-hexadecimale-html-rgba.html' title='TextMate : convertir une couleur hexadécimale en notation RGBA'>TextMate&#160;: convertir une couleur hexadécimale en notation RGBA</a></li><li><a href='http://pioupioum.fr/developpement/javascript-array-intersection.html' title='JavaScript : optimiser le calcul de l&#8217;intersection de tableaux de grandes tailles'>JavaScript&#160;: optimiser le calcul de l&#8217;intersection de tableaux de grandes tailles</a></li><li><a href='http://pioupioum.fr/developpement/jslint-console-rhino.html' title='Une console JSLint pour aider vos validations JavaScript'>Une console JSLint pour aider vos validations JavaScript</a></li><li><a href='http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html' title='PHP : convertir un DATETIME en un timestamp UNIX'>PHP&#160;: convertir un DATETIME en un timestamp UNIX</a></li></ul>

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

<li id="fn:1">
<p>exception faite des projets pour lesquels j&#8217;utilise un builder qui l&#8217;ajoute comme un grand à ma place.&#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/license-helper-textmate-bundle.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TextMate&#160;: convertir une couleur hexadécimale en notation RGBA</title>
		<link>http://pioupioum.fr/outils-astuces/textmate-convertir-couleur-hexadecimale-html-rgba.html</link>
		<comments>http://pioupioum.fr/outils-astuces/textmate-convertir-couleur-hexadecimale-html-rgba.html#comments</comments>
		<pubDate>Thu, 15 Apr 2010 10:19:56 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Outils, trucs et astuces]]></category>
		<category><![CDATA[convertir]]></category>
		<category><![CDATA[couleur]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[licence MIT]]></category>
		<category><![CDATA[rgba]]></category>
		<category><![CDATA[TextMate]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=367</guid>
		<description><![CDATA[CSS supporte divers formats de description des couleurs, le plus utilisé étant la notation héxadécimale #RRGGBB. L&#8217;introduction du support des couleurs RGBA par CSS 3 a été l&#8217;occasion pour certains de découvrir les notations rgba(255, 255, 255, 1) et sa version sans gestion de l&#8217;opacité rgb(255, 255, 255).

Il faut avouer que si nous disposons d&#8217;une [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>CSS supporte divers formats de description des couleurs, le plus utilisé étant la <strong>notation héxadécimale</strong> <code>#RRGGBB</code>. L&#8217;introduction du support des <a href="http://pioupioum.fr/tag/rgba/" title="Archives pour le tag rgba – piouPiouM&#039;s dev">couleurs RGBA</a> par CSS 3 a été l&#8217;occasion pour certains de découvrir les notations <code>rgba(255, 255, 255, 1)</code> et sa version sans gestion de l&#8217;opacité <code>rgb(255, 255, 255)</code>.</p>

<p>Il faut avouer que si nous disposons d&#8217;une palette d&#8217;outils d&#8217;aide à la saisie de couleurs en notation hexadécimale, il en est rien pour insérer une couleur au format <code>rgb[a]</code>, et cela peut <a href="http://twitter.com/br1o/status/12041847261" title="une réaction sur twitter">agacer</a>. Mais c&#8217;était sans compter sur <a href="http://pioupioum.fr/tag/textmate/" title="Archives pour le tag TextMate – piouPiouM&#039;s dev">TextMate</a>&#160;!<span id="more-367"></span></p>

<h2>Convertir une couleur héxadécimale en notation RGBA</h2>

<p>La commande TextMate <strong>Convert Hex to RGB(A) color</strong> va vous permettre de convertir <em>via</em> le raccourci clavier <kbd>⌘⇧X</kbd> une couleur héxadécimale en son équivalent RGB(A).</p>

<h3>Installation</h3>

<p>Après avoir téléchargé le fichier qui suit, installez la commande d&#8217;un simple double-clique.</p>

<div class="box textmate-command">
    <a title="Télécharger" href="http://assets1.pioupioum.fr/uploads/2010/04/Convert-Hex-to-RGBA-color.tmCommand"><span>Convert Hex to RGB(A) color.tmCommand (4&#160;Ko)</span></a>
</div>

<p>La nouvelle commande est maintenant disponible dans le bundle <strong>Source</strong>.</p>

<p>Pourquoi l&#8217;installer dans le bundle <strong>Source</strong> au lieu du bundle <strong>CSS</strong>&#160;? Parce qu&#8217;elle peut être utile dans d&#8217;autre languages, comme JavaScript et sera ainsi disponible à tout moment, qu&#8217;importe le bundle actif.</p>

<h3>Usage</h3>

<p>Simple d&#8217;utilisation, positionnez-vous sur une couleur et activez la commande pour obtenir son équivalent en notation RGB&#160;:</p>

<pre>#6633ff => rgb(102, 51, 255)
#63F    => rgb(102, 51, 255)</pre>

<p>Ajoutez à une couleur héxadécimale la composante d&#8217;opacité pour remplacer la couleur par sa forme RGBA&#160;:</p>

<pre>#6633FF80 => rgba(102, 51, 255, .50)
#63FA     => rgba(102, 51, 255, .67)
#63F0     => rgba(102, 51, 255, 0)</pre>

<p>Vous pouvez également sélectionner une couleur (avec le sharp <code>#</code> initial) et lancer la convertion. Cela se révèle être particulièrement utile avec une sélection en colonne.</p>

<h3>Code source</h3>

<p>Voici le <a href="http://gist.github.com/366816" title="gist: 366816 - Source code of a TextMate Command- GitHub">code</a> ruby<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> utilisé au sein de la commande.
<script src="http://gist.github.com/366816.js?file=hex2rgba.rb"></script></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/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/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/license-helper-textmate-bundle.html' title='Bundle License Helper pour TextMate'>Bundle License Helper pour TextMate</a></li><li><a href='http://pioupioum.fr/snippets/textmate-commande-exporter-mots-word-wrap.html' title='TextMate : commande &laquo;&nbsp;Export words&nbsp;&raquo;'>TextMate&#160;: commande &laquo;&nbsp;Export words&nbsp;&raquo;</a></li><li><a href='http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html' title='PHP : convertir un DATETIME en un timestamp UNIX'>PHP&#160;: convertir un DATETIME en un timestamp UNIX</a></li></ul>

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

<li id="fn:1">
<p>Toute remarque ou conseil est le bienvenu. Il s&#8217;agit de mon premier script ruby…&#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/textmate-convertir-couleur-hexadecimale-html-rgba.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Supprimer les effets de neige avec Greasemonkey</title>
		<link>http://pioupioum.fr/outils-astuces/supprimer-neige-scripts-greasemonkey.html</link>
		<comments>http://pioupioum.fr/outils-astuces/supprimer-neige-scripts-greasemonkey.html#comments</comments>
		<pubDate>Mon, 21 Dec 2009 15:22:29 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Outils, trucs et astuces]]></category>
		<category><![CDATA[effets]]></category>
		<category><![CDATA[Greasemonkey]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[neige]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=279</guid>
		<description><![CDATA[La fin d&#8217;année approche à grands pas et voici que la la neige tombe sur les sites. Ces effets JavaScript, à l&#8217;esthétique discutable, entravent la navigation sur les pages mais surtout consomment un maximum de cycles CPU.

Supprimer les effets Snow Storm


  On en a gros&#160;!


Je sais, moi aussi je ne les supporte plus >&#95;&#60;

C&#8217;est [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>La fin d&#8217;année approche à grands pas et voici que la <strong>la neige tombe</strong> sur les sites. Ces <strong>effets JavaScript</strong>, à l&#8217;esthétique discutable, entravent la navigation sur les pages mais surtout consomment un <em>maximum de cycles <abbr title="Central Processing Unit">CPU</abbr></em>.</p>

<h2>Supprimer les effets Snow Storm</h2>

<blockquote>
  <p>On en a gros&#160;!</p>
</blockquote>

<p>Je sais, moi aussi je ne les supporte plus >&#95;&lt;</p>

<p>C&#8217;est pourquoi j&#8217;ai écrit deux scripts destinés aux utilisateurs de l&#8217;extension <strong><a href="http://www.greasespot.net/" title="Greasespot">Greasemonkey</a></strong>&#160;:</p>

<ul>
<li><a href="http://userscripts.org/scripts/show/39351" title="SnowStorm Killer for Greasemonkey">SnowStorm Killer</a> qui inhibe l&#8217;action de <a href="http://www.schillmania.com/projects/snowstorm/" title="JavaScript Snow: DHTML Snowstorm">SnowStorm</a><sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>.</li>
<li><a href="http://userscripts.org/scripts/show/64670" title="jSnow Killer for Greasemonkey">jSnow Killer</a> qui supprime l&#8217;effet du plugin jQuery <a href="http://www.dummwiam.com/jSnow" title="jSnow, a jQuery plugin for creating falling snow effect on your website | DuMmWiaM.com">jSnow</a>.</li>
</ul>

<p>Ils ciblent les 2 effets que je rencontre le plus souvent.</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/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/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/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/facebook-application-add-page-tab-bookmarklet.html' title='Page Fan : ajout simplifié d&#8217;application onglet à vos pages fan Facebook'>Page Fan&#160;: ajout simplifié d&#8217;application onglet à vos pages fan Facebook</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-forcer-chargement-jquery-footer.html' title='WordPress : forcer le chargement de jQuery en bas de page'>WordPress&#160;: forcer le chargement de jQuery en bas de page</a></li></ul>

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

<li id="fn:1">
<p>notamment porté en plugin WordPress <a href="http://blog.coma.sg/odds-and-ends/let-it-snow/" title="Let It Snow! | COMA Blog">Let It Snow!</a>, pour notre plus grand malheur.&#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/supprimer-neige-scripts-greasemonkey.html/feed/</wfw:commentRss>
		<slash:comments>1</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/outils-astuces/wordpress-shortcode-afficher-fichiers-joints.html' title='Shortcode WordPress : afficher les documents liés aux billets'>Shortcode WordPress&#160;: afficher les documents liés aux billets</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/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/snippets/wordpress-create-shortcode-class.html' title='WordPress : une classe abstraite pour aider la création de shortcodes'>WordPress&#160;: une classe abstraite pour aider la création de shortcodes</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-forcer-chargement-jquery-footer.html' title='WordPress : forcer le chargement de jQuery en bas de page'>WordPress&#160;: forcer le chargement de jQuery en bas de page</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>21</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/outils-astuces/wordpress-shortcode-afficher-fichiers-joints.html' title='Shortcode WordPress : afficher les documents liés aux billets'>Shortcode WordPress&#160;: afficher les documents liés aux billets</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/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/snippets/wordpress-create-shortcode-class.html' title='WordPress : une classe abstraite pour aider la création de shortcodes'>WordPress&#160;: une classe abstraite pour aider la création de shortcodes</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-forcer-chargement-jquery-footer.html' title='WordPress : forcer le chargement de jQuery en bas de page'>WordPress&#160;: forcer le chargement de jQuery en bas de page</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>11</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/outils-astuces/wordpress-shortcode-afficher-fichiers-joints.html' title='Shortcode WordPress : afficher les documents liés aux billets'>Shortcode WordPress&#160;: afficher les documents liés aux billets</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-create-shortcode-class.html' title='WordPress : une classe abstraite pour aider la création de shortcodes'>WordPress&#160;: une classe abstraite pour aider la création de shortcodes</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-forcer-chargement-jquery-footer.html' title='WordPress : forcer le chargement de jQuery en bas de page'>WordPress&#160;: forcer le chargement de jQuery en bas de page</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/outils-astuces/wordpress-shortcode-afficher-fichiers-joints.html' title='Shortcode WordPress : afficher les documents liés aux billets'>Shortcode WordPress&#160;: afficher les documents liés aux billets</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-create-shortcode-class.html' title='WordPress : une classe abstraite pour aider la création de shortcodes'>WordPress&#160;: une classe abstraite pour aider la création de shortcodes</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-forcer-chargement-jquery-footer.html' title='WordPress : forcer le chargement de jQuery en bas de page'>WordPress&#160;: forcer le chargement de jQuery en bas de page</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>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/outils-astuces/wordpress-shortcode-afficher-fichiers-joints.html' title='Shortcode WordPress : afficher les documents liés aux billets'>Shortcode WordPress&#160;: afficher les documents liés aux billets</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-create-shortcode-class.html' title='WordPress : une classe abstraite pour aider la création de shortcodes'>WordPress&#160;: une classe abstraite pour aider la création de shortcodes</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-forcer-chargement-jquery-footer.html' title='WordPress : forcer le chargement de jQuery en bas de page'>WordPress&#160;: forcer le chargement de jQuery en bas de page</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></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>
	</channel>
</rss>

