<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>piouPiouM&#039;s dev&#187; Archives pour le tag shortcode – piouPiouM&#039;s dev</title>
	<atom:link href="http://pioupioum.fr/tag/shortcode/feed/" rel="self" type="application/rss+xml" />
	<link>http://pioupioum.fr</link>
	<description>Bloc-note d&#039;un développeur web</description>
	<lastBuildDate>Fri, 23 Dec 2011 23:41:36 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<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>20</slash:comments>
		</item>
		<item>
		<title>WordPress&#160;: une classe abstraite pour aider la création de shortcodes</title>
		<link>http://pioupioum.fr/snippets/wordpress-create-shortcode-class.html</link>
		<comments>http://pioupioum.fr/snippets/wordpress-create-shortcode-class.html#comments</comments>
		<pubDate>Wed, 22 Sep 2010 16:58:43 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[shortcode]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=456</guid>
		<description><![CDATA[Une petite classe PHP abstraite pour aider la création de shortcodes dans WordPress.

Pour un exemple d&#8217;utilisation, se reporter au shortcode attachments.




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
&#60;?php
/**
 * Abstract class to create shortcodes in WordPress.
 *
 * @author Mehdi Kabab &#60;http://pioupioum.fr/&#62;
 * @copyright Copyright (C) 2010 Mehdi Kabab
 * @license http://www.gnu.org/licenses/gpl.html  GNU GPL version 3 or later
 * @version 1.0.0
 [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Une petite classe PHP abstraite pour aider la création de <strong>shortcodes dans WordPress</strong>.</p>

<p>Pour un exemple d&#8217;utilisation, se reporter au <a href="http://pioupioum.fr/outils-astuces/wordpress-shortcode-afficher-fichiers-joints.html" title="Shortcode WordPress : afficher les documents liés aux billets &#8211; Attachments shortcode – piouPiouM&#039;s dev">shortcode attachments</a>.</p>

<p><span id="more-456"></span></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
</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;">/**
 * Abstract class to create shortcodes in WordPress.
 *
 * @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/snippets/wordpress-create-shortcode-class.html
 */</span>
abstract <span style="color: #000000; font-weight: bold;">class</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: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Options after initialization of shortcode.
     *
     * @var ArrayObject
     */</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_options</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Tag name of shortcode.
     *
     * @var string
     **/</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_name</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;">/**
     * Constructor.
     *
     * @param string $tag Shortcode tag to be searched in post content.
     */</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: #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;">setTagName</span><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>_options <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: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Excecute the shortcode.
     *
     * Called by the shortcode API.
     *
     * @param array $attributes Attributes used in the call of the shortcode.
     * @param string $content The content of the shortcode. Default to null.
     * @return string
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> run<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: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOptions</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_default_options<span style="color: #339933;">,</span> <span style="color: #000088;">$attributes</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</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: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Check if the current shortcode tag already registered.
     *
     * @global array $shortcode_tags
     * @return boolean
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> isRegistered<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;">$shortcode_tags</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #990000;">array_key_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTagName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$shortcode_tags</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;">/**
     * Register the shortcode.
     *
     * @return PPM_Shortcode
     * @throws Exception If the shortcode already exists.
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> register<span style="color: #009900;">&#40;</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;">isRegistered</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>
            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;">'The shortcode `%s` already exists!'</span><span style="color: #339933;">,</span>
                                        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTagName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTagName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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;">'run'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Unregister the shortcode.
     *
     * @return PPM_Shortcode
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> unregister<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        remove_shortcode<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTagName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Retrieve the name of shortcode.
     *
     * @return string
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTagName<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>_name<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Set the name of shortcode.
     *
     * @param string $name Shortcode tag to be searched in post content.
     * @return PPM_Shortcode
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setTagName<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>_name <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;">/**
     * Retrieve the requested option.
     *
     * @param string $name The option to search.
     * @return mixed
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getOption<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: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_options<span style="color: #339933;">-&gt;</span><span style="color: #004000;">offsetGet</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: #009933; font-style: italic;">/**
     * Test if an option exists for the shortcode.
     *
     * @param string $name
     * @return boolean
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> hasOption<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: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_options<span style="color: #339933;">-&gt;</span><span style="color: #004000;">offsetExists</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: #009933; font-style: italic;">/**
     * Set an option.
     *
     * @param string $name
     * @param mixed $value
     * @return PPM_Shortcode
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setOption<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</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>_options<span style="color: #339933;">-&gt;</span><span style="color: #004000;">offsetSet</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</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 options.
     *
     * @return ArrayObject
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getOptions<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>_options<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Set the options.
     *
     * @param array $options
     * @return PPM_Shortcode
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setOptions<span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$options</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$name</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;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOption</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</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;">/**
     * Concrete excecution of the shortcode.
     *
     * @param array $attributes Attributes used in the call of the shortcode.
     * @param string $content The content of the shortcode. Default to null.
     * @return string
     */</span>
    abstract 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: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</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/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/developpement/photon-php-installer-mac-os-x-snow-leopard.html' title='Photon : guide d&#8217;installation sur Mac OS X Snow Leopard'>Photon&#160;: guide d&#8217;installation sur Mac OS X Snow Leopard</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/snippets/wordpress-create-shortcode-class.html/feed/</wfw:commentRss>
		<slash:comments>2</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>Shortcode WordPress&#160;: intégrer un flux RSS</title>
		<link>http://pioupioum.fr/developpement/shortcode-wordpress-integrer-flux-rss.html</link>
		<comments>http://pioupioum.fr/developpement/shortcode-wordpress-integrer-flux-rss.html#comments</comments>
		<pubDate>Fri, 17 Jul 2009 01:02:36 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Développement Web]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[shortcode]]></category>
		<category><![CDATA[WordPress]]></category>

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

Houston, on a un problème

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


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

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

<p>Reprenons le code donné dans l&#8217;article&#160;:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//This file is needed to be able to use the wp_rss() function.</span>
<span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span>ABSPATH<span style="color: #339933;">.</span>WPINC<span style="color: #339933;">.</span><span style="color: #0000ff;">'/rss.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> readRss<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">&quot;feed&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://'</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">&quot;num&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1'</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> wp_rss<span style="color: #009900;">&#40;</span><span style="color: #000088;">$feed</span><span style="color: #339933;">,</span> <span style="color: #000088;">$num</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rss'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'readRss'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


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

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

<h2>Solution</h2>

<p>On corrige le <a href="http://codex.wordpress.org/Shortcode_API" title="Shortcode API » WordPress Codex">shortcode</a> en capturant la sortie de la fonction <code>wp_rss()</code> à l&#8217;aide d&#8217;une <a href="http://fr.php.net/manual/fr/intro.outcontrol.php" title="PHP: Contrôle de l'affichage - Introduction - Manual">tamporisation de sortie</a>.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//This file is needed to be able to use the wp_rss() function.</span>
<span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span>ABSPATH<span style="color: #339933;">.</span>WPINC<span style="color: #339933;">.</span><span style="color: #0000ff;">'/rss.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> readRss<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">&quot;feed&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">&quot;num&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1'</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    wp_rss<span style="color: #009900;">&#40;</span><span style="color: #000088;">$feed</span><span style="color: #339933;">,</span> <span style="color: #000088;">$num</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">ob_get_clean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rss'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'readRss'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


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

<ul class='related_post'><li><a href='http://pioupioum.fr/outils-astuces/wordpress-smartypants-shortcode-caption.html' title='WordPress et SmartyPants : des légendes qui disparaissent'>WordPress et SmartyPants&#160;: des légendes qui disparaissent</a></li><li><a href='http://pioupioum.fr/outils-astuces/faille-wordpress-mot-passe-correctif.html' title='Correctif pour la faille WordPress de réinitialisation de mot de passe'>Correctif pour la faille WordPress de réinitialisation de mot de passe</a></li><li><a href='http://pioupioum.fr/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/developpement/shortcode-wordpress-integrer-flux-rss.html/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

