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

<channel>
	<title>piouPiouM&#039;s dev&#187; Archives de la catégorie Snippets &#8211; piouPiouM&#039;s dev</title>
	<atom:link href="http://pioupioum.fr/snippets/feed/" rel="self" type="application/rss+xml" />
	<link>http://pioupioum.fr</link>
	<description>Bloc-note d&#039;un développeur web</description>
	<lastBuildDate>Mon, 30 Apr 2012 09:42:02 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>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&#160;: forcer le chargement de jQuery en bas de page</title>
		<link>http://pioupioum.fr/snippets/wordpress-forcer-chargement-jquery-footer.html</link>
		<comments>http://pioupioum.fr/snippets/wordpress-forcer-chargement-jquery-footer.html#comments</comments>
		<pubDate>Thu, 09 Sep 2010 13:45:08 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=442</guid>
		<description><![CDATA[Le snippet qui suit ne se limite pas à forcer le chargement de jQuery en pied de page. Il permet également de remplacer la version locale à l&#8217;installion WordPress par une version équivalente, mais servie par le service Google Libraries API.

Si un script tierce remplace la version jQuery, son chargement sera forcé en bas de [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Le snippet qui suit ne se limite pas à forcer le <strong>chargement de jQuery</strong> en pied de page. Il permet également de remplacer la version locale à l&#8217;installion WordPress par une version équivalente, mais servie par le service <strong><a href="http://code.google.com/intl/fr-FR/apis/libraries/devguide.html#jquery" title="Google Libraries API - Developer&#39;s Guide - Google Libraries API - Google Code">Google Libraries API</a></strong>.</p>

<p>Si un script tierce remplace la version jQuery, son <strong>chargement</strong> sera <strong>forcé</strong> en <strong>bas de page</strong>.</p>

<p>Bien évidemment, il est aisé d&#8217;adapter ce snippet pour n&#8217;importe quel autre fichier JavaScript.
<span id="more-442"></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
</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;">/**
 * Force load jQuery in the footer.
 *
 * @param boolean $google Set to true for load jQuery from the
 *                        Google Libraries Api servers. Default to false.
 * @global WP_Scripts $wp_scripts
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> forcejQueryInFooter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$google</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: #666666; font-style: italic;">// Do not apply in the WordPress admin Panel.</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_admin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_scripts</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_a</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_scripts</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'WP_Scripts'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$wp_scripts</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Scripts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$jquery</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_scripts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'registered'</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;">$jquery</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$jquery_google</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://ajax.googleapis.com/ajax/libs/jquery/%s/jquery.min.js'</span><span style="color: #339933;">;</span>
        wp_deregister_script<span style="color: #009900;">&#40;</span><span style="color: #000088;">$jquery</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        wp_register_script<span style="color: #009900;">&#40;</span>
            <span style="color: #000088;">$jquery</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">handle</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#40;</span><span style="color: #000088;">$google</span><span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$jquery_google</span><span style="color: #339933;">,</span> <span style="color: #000088;">$jquery</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ver</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$jquery</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">src</span><span style="color: #339933;">,</span>
            <span style="color: #000088;">$jquery</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">deps</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#40;</span><span style="color: #000088;">$google</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$jquery</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ver</span><span style="color: #339933;">,</span>
            <span style="color: #009900; font-weight: bold;">true</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Force load jQuery in the footer from the Google Libraries Api servers.
 *
 * @see forcejQueryInFooter()
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> forcejQueryGoogleLibrariesApiInFooter<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    forcejQueryInFooter<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_enqueue_scripts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'forcejQueryGoogleLibrariesApiInFooter'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">101</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<p>Remplacez <code>forcejQueryGoogleLibrariesApiInFooter</code> par <code>forcejQueryInFooter</code> dans l&#8217;ajout d&#8217;action à <code>wp_enqueue_scripts</code> pour utiliser la version de jQuery livrée avec <strong>WordPress</strong>.</p>

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

<ul class='related_post'><li><a href='http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html' title='WordPress jQuery UI Effects'>WordPress jQuery UI Effects</a></li><li><a href='http://pioupioum.fr/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/developpement/javascript-array-intersection.html' title='JavaScript : optimiser le calcul de l&#8217;intersection de tableaux de grandes tailles'>JavaScript&#160;: optimiser le calcul de l&#8217;intersection de tableaux de grandes tailles</a></li><li><a href='http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html' title='Optimiser le chargement des AdSense'>Optimiser le chargement des AdSense</a></li></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/wordpress-forcer-chargement-jquery-footer.html/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>TextMate&#160;: commande &#8220;Export words&#8221;</title>
		<link>http://pioupioum.fr/snippets/textmate-commande-exporter-mots-word-wrap.html</link>
		<comments>http://pioupioum.fr/snippets/textmate-commande-exporter-mots-word-wrap.html#comments</comments>
		<pubDate>Sun, 16 May 2010 14:30:47 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[licence MIT]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[TextMate]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=380</guid>
		<description><![CDATA[À l&#8217;intérieur du code source d&#8217;une classe PHP, je souhaite stocker dans un tableau la liste des mots de la version populaire de l&#8217;incontournable texte Lorem ipsum. Jusque là rien de bien sorcier. Mais pour des raisons de lisibilité et de conventions de codage je veux obtenir des lignes formées par un maximum de 72 [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>À l&#8217;intérieur du code source d&#8217;une classe PHP, je souhaite stocker dans un tableau la liste des mots de la version populaire de l&#8217;incontournable texte <em><a href="http://fr.wikipedia.org/wiki/Faux-texte#Lorem_ipsum_.28version_populaire.29" title="Faux-texte - Wikipédia">Lorem ipsum</a></em>. Jusque là rien de bien sorcier. Mais pour des raisons de lisibilité et de conventions de codage je veux obtenir des lignes formées par un maximum de 72 caractères.</p>

<p>Certes je peux <em>m&#8217;amuser</em> à le faire à la main, mais pourquoi me fatiguer quand un langage de script tel que <strong>PHP</strong> me tend la main pour automatiser la procédure&#160;? Et, cerise sur le gâteau, si en plus je peux l&#8217;intégrer à mon éditeur préféré, <a href="http://pioupioum.fr/tag/textmate/" title="Archives pour le tag TextMate – piouPiouM&#039;s dev">TextMate</a>.</p>

<p><div id="attachment_386" class="wp-caption aligncenter" style="width: 458px"><a href="http://assets1.pioupioum.fr/uploads/2010/05/export-words.png"><img src="http://assets1.pioupioum.fr/uploads/2010/05/export-words-448x350.png" alt="Exemple d&#039;action de la commande TextMate Export words" title="TextMate Export words" width="448" height="350" class="size-medium wp-image-386" /></a><p class="wp-caption-text">Exemple d&#8217;action de la commande TextMate Export words</p></div><span id="more-380"></span></p>

<h2>Intégration dans Textmate</h2>

<ol>
<li>Allez dans le menu <span lang="en">Bundles</span> > <span lang="en">Bundle Editor</span> > <span lang="en">Show Bundle Editor</span> puis créez une nouvelle commande à l&#8217;aide de l&#8217;action <span lang="en">New Command</span>.</li>
<li>Donnez à la commande le nom <span lang="en">Export words</span>.</li>
<li>Veillez à ce que <span lang="en">Save</span> soit défini à <span lang="en">Nothing</span>.</li>
<li>Sélectionnez pour <span lang="en">Input</span> les options <span lang="en">Selected Text or Nothing</span>.</li>
<li>Placez <span lang="en">Output</span> à <span lang="en">Replace Selected Text</span>.</li>
<li>Choisissez une <span lang="en">Activation</span> de type <span lang="en">Key Equivalent</span> et définnez un raccourci. J&#8217;ai opté pour la séquence <kbd>⌥⇧W</kbd>.</li>
<li>Laissez vide le champ <span lang="en">Scope Selector</span> afin de pouvoir jouir de la commande depuis n&#8217;importe quel type de fichier et scope.</li>
<li>Enfin, copiez-collez le code ci-dessous dans le champ <span lang="en">Command(s)</span>.</li>
</ol>


<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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">#!/usr/bin/env php -n
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Export a wrapped representation of the words of a text.
 *
 * Optional parameters in a line that follows the text:
 *      l&lt;size&gt;. The column width. Default: 72.
 *      s&lt;characters&gt;. Characters to remove. Default: punctuation.
 *      o&lt;asc|desc&gt;. Sort order. Default: none.
 */</span>
<span style="color: #666666; font-style: italic;">/*
# ***** BEGIN LICENSE BLOCK *****
#
# Copyright (C) 2010 Mehdi Kabab &lt;http://pioupioum.fr/&gt;
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the &quot;Software&quot;), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# ***** END LICENSE BLOCK ***** */</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">version_compare</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">PHP_VERSION</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'5.0.0'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;'</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: #0000ff;">'You must have PHP &gt;= 5.0.0!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$lenght</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">72</span><span style="color: #339933;">;</span>      <span style="color: #666666; font-style: italic;">// the default column width.</span>
<span style="color: #000088;">$strip</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'\p{P}'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// removes the ponctuation</span>
<span style="color: #000088;">$sort</span>   <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// no sorting</span>
&nbsp;
<span style="color: #000088;">$raw</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'php://filter/read=string.tolower/resource=php://stdin'</span><span style="color: #339933;">,</span>
            FILE_IGNORE_NEW_LINES <span style="color: #339933;">|</span> FILE_SKIP_EMPTY_LINES<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$raw</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</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;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_pop</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$raw</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#^(?:\s{0,}(?:l(?&lt;lenght&gt;\d+)|s(?&lt;strip&gt;.*)|o(?&lt;sort&gt;asc|desc))\s{0,})+$#u'</span><span style="color: #339933;">,</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</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;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'lenght'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'lenght'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #000088;">$lenght</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'lenght'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</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;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'strip'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'strip'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #000088;">$strip</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'|'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'strip'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</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;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sort'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sort'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #000088;">$sort</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sort'</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: #990000;">array_push</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$raw</span><span style="color: #339933;">,</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$raw</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$raw</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Removes punctuation and user characters</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$strip</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$strip</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: #0000ff;">'\#'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$strip</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$raw</span>   <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#('</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$strip</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">')#u'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$raw</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;">// Estimating indent</span>
<span style="color: #000088;">$start_index</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</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;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TM_INPUT_START_LINE_INDEX'</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;">$start_index</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TM_INPUT_START_LINE_INDEX'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'YES'</span> <span style="color: #339933;">===</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TM_SOFT_TABS'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$tab</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_repeat</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TM_TAB_SIZE'</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;">$tab</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$tab_count</span>    <span style="color: #339933;">=</span> <span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$start_index</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TM_TAB_SIZE'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$extra_spaces</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$start_index</span> <span style="color: #339933;">%</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TM_TAB_SIZE'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$tabs</span>         <span style="color: #339933;">=</span> <span style="color: #990000;">str_repeat</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tab</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tab_count</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">str_repeat</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$extra_spaces</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$tabs_len</span>     <span style="color: #339933;">=</span> <span style="color: #000088;">$tab_count</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TM_TAB_SIZE'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$extra_spaces</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Extracting words now!</span>
<span style="color: #000088;">$words</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#\s+#'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$raw</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$words</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_map</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'trim'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$words</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$words</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_filter</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array_unique</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$words</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// removes empty fields</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$sort</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">natsort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$words</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: #0000ff;">'desc'</span> <span style="color: #339933;">===</span> <span style="color: #000088;">$sort</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$words</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_reverse</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$words</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$words</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%s\'%s\''</span><span style="color: #339933;">,</span>
                 <span style="color: #000088;">$tabs</span><span style="color: #339933;">,</span>
                 <span style="color: #990000;">wordwrap</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;', '&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$words</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lenght</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$tabs_len</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #006699; font-weight: bold;">$tabs</span>&quot;</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: #cc66cc;">0</span> <span style="color: #339933;">!==</span> <span style="color: #000088;">$start_index</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$words</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ltrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$words</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: #0000ff;">&quot;''&quot;</span> <span style="color: #339933;">===</span> <span style="color: #000088;">$words</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$words</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<h2>Utilisation de la commande TextMate <strong>Export words</strong></h2>

<p>Sélectionnez le texte à transformer. La transformation du texte se contrôle en ajoutant à la suite une ligne d&#8217;arguments <strong>optionnels</strong>&#160;:</p>

<ul>
<li><strong><code>l&lt;size&gt;</code></strong>. Ajuster la longueur de ligne. Exemple&#160;: <code>l80</code> pour effectuer une coupure à la colonne 80. Défaut&#160;: 72.</li>
<li><strong><code>s&lt;characters&gt;</code></strong>. Exemple&#160;: <code>slorem|ipsum</code> pour exclure les mots <em>lorem</em> et <em>ipsum</em>. Défaut&#160;: toute ponctuation.</li>
<li><strong><code>o&lt;asc|desc&gt;</code></strong>. Trier la sortie selon les ordres <code>asc</code>endant et <code>desc</code>endant. Défaut&#160;: aucun tri n&#8217;est réalisé.</li>
</ul>

<p>Notez que si votre sélection est précédée par une indentation, alors le script va appliquer cette dernière à chacune des lignes générées en se conformant aux options courantes de TextMate&#160;: il générera des espaces si le mode <span lang="en">Soft Tabs</span> est activé. Sinon des tabulations complétées d&#8217;éventuels espaces.</p>

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

<ul class='related_post'><li><a href='http://pioupioum.fr/outils-astuces/license-helper-textmate-bundle.html' title='Bundle License Helper pour TextMate'>Bundle License Helper pour TextMate</a></li><li><a href='http://pioupioum.fr/outils-astuces/textmate-convertir-couleur-hexadecimale-html-rgba.html' title='TextMate : convertir une couleur hexadécimale en notation RGBA'>TextMate&#160;: convertir une couleur hexadécimale en notation RGBA</a></li><li><a href='http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html' title='PHP : convertir un DATETIME en un timestamp UNIX'>PHP&#160;: convertir un DATETIME en un timestamp UNIX</a></li><li><a href='http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html' title='PHP : fonction uncamel() pour inverser une notation en CamelCase'>PHP&#160;: fonction uncamel() pour inverser une notation en CamelCase</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></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/textmate-commande-exporter-mots-word-wrap.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP&#160;: installer APC sous Mac OS X Leopard</title>
		<link>http://pioupioum.fr/snippets/php-installer-apc-macosx.html</link>
		<comments>http://pioupioum.fr/snippets/php-installer-apc-macosx.html#comments</comments>
		<pubDate>Thu, 06 May 2010 18:47:30 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[APC]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=376</guid>
		<description><![CDATA[Sous Mac OS X Leopard, l&#8217;installation du système de cache APC via PECL est en carton. Pour faire simple, l&#8217;extension n&#8217;est disponible que pour la version CLI de PHP.

Il est cependant possible d&#8217;y remédier1 et ainsi disposer d&#8217;APC avec la configuration de base fourni par Apple.

Récupérer la dernière version d&#8217;APC

$ curl http://pecl.php.net/get/APC -o ~/Downloads/APC-latest.tgz
$ tar [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Sous Mac OS X Leopard, l&#8217;installation du système de cache <a href="http://php.net/manual/fr/book.apc.php" title="PHP: APC - Manual">APC</a> <em>via</em> <a href="http://pecl.php.net/" title="PECL :: The PHP Extension Community Library">PECL</a> est en carton. Pour faire simple, l&#8217;extension n&#8217;est disponible que pour la version CLI de PHP.</p>

<p>Il est cependant possible d&#8217;y remédier<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> et ainsi disposer d&#8217;<strong>APC</strong> avec la configuration de base fourni par Apple.</p>

<h2>Récupérer la dernière version d&#8217;APC</h2>

<pre>$ curl http://pecl.php.net/get/APC -o ~/Downloads/APC-latest.tgz
$ tar -zxf !$ -C ~/Downloads/
$ cd ~/Downloads/APC-3.1.3p1/</pre>

<p>La version utilisée ici est la 3.1.3p1.</p>

<h2>Préparer l&#8217;environnement de compilation</h2>

<pre>$ /usr/bin/phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519</pre>

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

<h2>Lancer la compilation</h2>

<p>Copier-coller dans la commande qui suit dans son intégralité. Attention à ne pas inclure de retours à la ligne.</p>

<pre>MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load" ./configure</pre>

<p>Puis un coup de <code>make</code>&#160;:</p>

<pre>$ make
...
----------------------------------------------------------------------
Libraries have been installed in:
   /Users/mehdi/Downloads/APC-3.1.3p1/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
     during execution

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.</pre>

<p>Et pour finir, on installe l&#8217;extension APC.</p>

<pre>$ sudo make install
Installing shared extensions:     /usr/lib/php/extensions/no-debug-non-zts-20060613/</pre>

<h2>Activer l&#8217;extension APC pour PHP</h2>

<p>Éditer le fichier <code>php.ini</code> pour ajouter la configuration qui suit&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000099;">extension</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> apc.so</span>
apc.enabled <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 1</span>
apc.enable_cli <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 1</span>
apc.mmap_file_mask <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> /tmp/apc.XXXXXX</span>
apc.num_files_hint <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 1024</span>
apc.shm_segments <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 1</span>
apc.shm_size <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 128</span>
apc.ttl <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 7200</span>
apc.user_ttl <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 7200</span></pre></div></div>


<p>Relancer Apache pour qu&#8217;il prenne en compte la nouvelle extension.</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/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/developpement/compass-rvm-multiple-instances.html' title='Instances multiples de Compass avec Ruby Version Manager (rvm)'>Instances multiples de Compass avec Ruby Version Manager (rvm)</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/textmate-commande-exporter-mots-word-wrap.html' title='TextMate : commande &laquo;&nbsp;Export words&nbsp;&raquo;'>TextMate&#160;: commande &laquo;&nbsp;Export words&nbsp;&raquo;</a></li><li><a href='http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html' title='PHP : convertir un DATETIME en un timestamp UNIX'>PHP&#160;: convertir un DATETIME en un timestamp UNIX</a></li></ul>

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

<li id="fn:1">
<p>Source&#160;: <a href="http://discussions.apple.com/thread.jspa?threadID=1578979" title="Apple - Support - Discussions - Entropy php5 with GD support and APC ...">Forum du support Apple</a>.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/php-installer-apc-macosx.html/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>PHP&#160;: convertir un DATETIME en un timestamp UNIX</title>
		<link>http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html</link>
		<comments>http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html#comments</comments>
		<pubDate>Tue, 09 Mar 2010 23:28:01 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[convertir]]></category>
		<category><![CDATA[licence MIT]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=346</guid>
		<description><![CDATA[Mise à jour à 10:57
Plus simple, rapide, intégré, toussa&#160;: utiliser strtotime tout simplement.
Merci à Éric Daspet et à Oncle Tom pour le rappel.

Une fonction utilitaire1 pour convertir une chaîne de type DATETIME ou DATE en un timestamp UNIX.
Les formats pris en charges en entrée sont AAAA-MM-JJ HH:MM:SS et AA-MM-JJ HH:MM:SS. L&#8217;heure étant optionnelle dans le [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p><strong>Mise à jour à 10:57</strong><br />
Plus simple, rapide, intégré, toussa&#160;: utiliser <a href="http://php.net/manual/fr/function.strtotime.php">strtotime</a> tout simplement.<br />
Merci à <a href="http://twitter.com/edasfr/status/10264669320" title="réaction sur twitter">Éric Daspet</a> et à <a href="http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html#comment-1187" title="réaction dans les commentaires">Oncle Tom</a> pour le rappel.</p>

<p>Une fonction utilitaire<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> pour convertir une chaîne de type <strong>DATETIME</strong> ou <strong>DATE</strong> en un <strong>timestamp UNIX</strong>.<br />
Les formats pris en charges en entrée sont <code>AAAA-MM-JJ HH:MM:SS</code> et <code>AA-MM-JJ HH:MM:SS</code>. L&#8217;heure étant optionnelle dans le cas de la conversion d&#8217;une date.</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
</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;">/**
 * Get UNIX timestamp for a date or date time.
 *
 * Example:
 * &lt;code&gt;
 * &lt;?php
 * unix_timestamp('2010-03-09 22:43:46'); # 1268171026
 * unix_timestamp('10-03-09 22:43:46');   # 1268171026
 * unix_timestamp('2010-03-09');          # 1268089200
 * ?&gt;
 * &lt;/code&gt;
 *
 * @author    Mehdi Kabab &lt;http://pioupioum.fr/&gt;
 * @copyright 2010 Mehdi Kabab
 * @license   http://www.opensource.org/licenses/mit-license.html MIT License
 * @link      http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html
 *
 * @param string The date or datetime to convert.
 * @return int The UNIX timestamp corresponding to the datetime.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> unix_timestamp<span style="color: #009900;">&#40;</span><span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</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: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$c</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;">$date</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$c</span>    <span style="color: #339933;">=</span> <span style="color: #990000;">array_pad</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">array_walk</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'intval'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</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: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


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

<ul class='related_post'><li><a href='http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html' title='PHP : fonction uncamel() pour inverser une notation en CamelCase'>PHP&#160;: fonction uncamel() pour inverser une notation en CamelCase</a></li><li><a href='http://pioupioum.fr/snippets/textmate-commande-exporter-mots-word-wrap.html' title='TextMate : commande &laquo;&nbsp;Export words&nbsp;&raquo;'>TextMate&#160;: commande &laquo;&nbsp;Export words&nbsp;&raquo;</a></li><li><a href='http://pioupioum.fr/outils-astuces/textmate-convertir-couleur-hexadecimale-html-rgba.html' title='TextMate : convertir une couleur hexadécimale en notation RGBA'>TextMate&#160;: convertir une couleur hexadécimale en notation RGBA</a></li><li><a href='http://pioupioum.fr/developpement/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-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></ul>

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

<li id="fn:1">
<p>vous allez dire qu&#8217;il en existe pléthore, mais je les trouve toutes trop lourdes (conditions, strlen, multiples explode, etc) pour le peu à faire. Sans parler du fait qu&#8217;elles ne supportent uniquement que le format DATETIME.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Bash&#160;: convertir un string en entier</title>
		<link>http://pioupioum.fr/snippets/bash-convertir-string-to-integer.html</link>
		<comments>http://pioupioum.fr/snippets/bash-convertir-string-to-integer.html#comments</comments>
		<pubDate>Sat, 06 Mar 2010 19:06:25 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[convertir]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=340</guid>
		<description><![CDATA[Bash n&#8217;offre pas de fonction pour convertir une chaîne de caractères ou un nombre flottant en un entier.
Cela n&#8217;est toute fois pas impossible, il suffit de faire appel à printf1 et le tour est joué&#160;!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash
# string_to_int.sh - Shell script to convert a string or float number
# to an integer.
&#160;
function string_to_int &#40;&#41;
&#123;
    [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p><a href="http://fr.wikipedia.org/wiki/Bourne-Again_shell" title="Bourne-Again shell - Wikipédia">Bash</a> n&#8217;offre pas de fonction pour convertir une chaîne de caractères ou un nombre flottant en un entier.<br />
Cela n&#8217;est toute fois pas impossible, il suffit de faire appel à <code>printf</code><sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> et le tour est joué&#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
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/env bash</span>
<span style="color: #666666; font-style: italic;"># string_to_int.sh - Shell script to convert a string or float number</span>
<span style="color: #666666; font-style: italic;"># to an integer.</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> string_to_int <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #007800;">LANG</span>=C
    <span style="color: #007800;">d</span>=<span style="color: #800000;">${1##*.}</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${#1}</span> <span style="color: #660033;">-eq</span> <span style="color: #800000;">${#d}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">d</span>=<span style="color: #000000;">0</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #007800;">e</span>=<span style="color: #800000;">${1%.*}</span>
    <span style="color: #007800;">e</span>=<span style="color: #800000;">${e//,/}</span>
    <span style="color: #7a0874; font-weight: bold;">printf</span> <span style="color: #000000; font-weight: bold;">%</span>.0f <span style="color: #ff0000;">&quot;<span style="color: #007800;">$e</span>.<span style="color: #007800;">$d</span>&quot;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #007800;">not_int</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;12.652&quot;</span> <span style="color: #ff0000;">&quot;-12.652&quot;</span> <span style="color: #000000;">12.652</span> <span style="color: #000000;">14</span> <span style="color: #ff0000;">&quot;12,652&quot;</span> foo <span style="color: #ff0000;">&quot;1,254.8&quot;</span> <span style="color: #000000;">1</span>,<span style="color: #000000;">254.8</span> <span style="color: #ff0000;">&quot;125,160,254.8&quot;</span> <span style="color: #ff0000;">&quot;125,160,254&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> value <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${not_int[@]}</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Convert <span style="color: #007800;">$value</span> to int: <span style="color: #007800;">$(string_to_int $value)</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>


<p>Ce qui nous donne&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ .<span style="color: #000000; font-weight: bold;">/</span>string_to_int.sh 
Convert <span style="color: #000000;">12.652</span> to int: <span style="color: #000000;">13</span>
Convert -<span style="color: #000000;">12.652</span> to int: <span style="color: #660033;">-13</span>
Convert <span style="color: #000000;">12.652</span> to int: <span style="color: #000000;">13</span>
Convert <span style="color: #000000;">14</span> to int: <span style="color: #000000;">14</span>
Convert <span style="color: #000000;">12</span>,<span style="color: #000000;">652</span> to int: <span style="color: #000000;">12652</span>
Convert foo to int: <span style="color: #000000;">0</span>
Convert <span style="color: #000000;">1</span>,<span style="color: #000000;">254.8</span> to int: <span style="color: #000000;">1255</span>
Convert <span style="color: #000000;">1</span>,<span style="color: #000000;">254.8</span> to int: <span style="color: #000000;">1255</span>
Convert <span style="color: #000000;">125</span>,<span style="color: #000000;">160</span>,<span style="color: #000000;">254.8</span> to int: <span style="color: #000000;">125160255</span>
Convert <span style="color: #000000;">125</span>,<span style="color: #000000;">160</span>,<span style="color: #000000;">254</span> to int: <span style="color: #000000;">125160254</span></pre></div></div>


<p>Voir <a href="http://gist.github.com/324313">sur Github</a>.</p>

<p><strong>Mis à jour le 7 mars 2010</strong><br />
Prise en charge de la notation US. Merci à <a href="http://pioupioum.fr/snippets/bash-convertir-string-to-integer.html#comment-1159">patpro</a>.</p>

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

<ul class='related_post'><li><a href='http://pioupioum.fr/outils-astuces/textmate-convertir-couleur-hexadecimale-html-rgba.html' title='TextMate : convertir une couleur hexadécimale en notation RGBA'>TextMate&#160;: convertir une couleur hexadécimale en notation RGBA</a></li><li><a href='http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html' title='PHP : convertir un DATETIME en un timestamp UNIX'>PHP&#160;: convertir un DATETIME en un timestamp UNIX</a></li><li><a href='http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html' title='PHP : fonction uncamel() pour inverser une notation en CamelCase'>PHP&#160;: fonction uncamel() pour inverser une notation en CamelCase</a></li><li><a href='http://pioupioum.fr/snippets/convertir-icone-icns-png.html' title='Convertir une icône ICNS en une image PNG'>Convertir une icône ICNS en une image PNG</a></li><li><a href='http://pioupioum.fr/snippets/leopard-rechercher-nom-reel-utilisateur.html' title='Rechercher le nom réel d&#8217;un utilisateur sous Leopard'>Rechercher le nom réel d&#8217;un utilisateur sous Leopard</a></li></ul>

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

<li id="fn:1">
<p>une substitution du séparateur des décimals <code>.</code> en <code>,</code> est nécessaire avant de faire appel à <code>printf</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/snippets/bash-convertir-string-to-integer.html/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP&#160;: fonction uncamel() pour inverser une notation en CamelCase</title>
		<link>http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html</link>
		<comments>http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html#comments</comments>
		<pubDate>Sun, 28 Feb 2010 18:17:12 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[convertir]]></category>
		<category><![CDATA[gist]]></category>
		<category><![CDATA[licence MIT]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=336</guid>
		<description><![CDATA[Une fonction PHP utilitaire pour convertir une chaîne en notation CamelCase en mots réunis par un séparateur (par défaut, le caractère underscore _).

La fonction uncamel() supporte indifféremment, en entrée, les notations lowerCamelCase et UpperCamelCase.


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
&#60;?php
/**
 * Reverse a CamelCase string.
 *
 * Examples:
 *     uncamel('lowerCamelCase') === 'lower_camel_case'
 *     [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Une fonction <strong><a href="http://fr.wikipedia.org/wiki/PHP" title="PHP: Hypertext Preprocessor - Wikipédia">PHP</a></strong> utilitaire pour convertir une chaîne en notation <strong><a href="http://fr.wikipedia.org/wiki/CamelCase" title="CamelCase - Wikipédia">CamelCase</a></strong> en mots réunis par un séparateur (par défaut, le caractère <em>underscore</em> <code>_</code>).</p>

<p>La fonction <strong><code>uncamel()</code></strong> supporte indifféremment, en entrée, les notations <strong>lowerCamelCase</strong> et <strong>UpperCamelCase</strong>.</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
</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;">/**
 * Reverse a CamelCase string.
 *
 * Examples:
 *     uncamel('lowerCamelCase') === 'lower_camel_case'
 *     uncamel('UpperCamelCase') === 'upper_camel_case'
 *     uncamel('ThisIsAString') === 'this_is_a_string'
 *     uncamel('notcamelcase') === 'notcamelcase'
 *     uncamel('lowerCamelCase', ' | ') === 'lower | camel | case'
 *
 * @author    Mehdi Kabab &lt;http://pioupioum.fr/&gt;
 * @copyright 2010 Mehdi Kabab
 * @license   http://www.opensource.org/licenses/mit-license.html MIT License
 * @link      http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html
 *
 * @param  string $content The CamelCase string.
 * @param  string $separator The glue for the compound words. Defaults to '_'.
 * @return string
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> uncamel<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$separator</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'_'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#(?&lt;=[a-zA-Z])([A-Z])(?=[a-zA-Z])#e'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;'<span style="color: #006699; font-weight: bold;">$separator</span>' . strtolower('<span style="color: #006699; font-weight: bold;">$1</span>')&quot;</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: #000088;">$content</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<p>Le <a href="http://gist.github.com/317702" title="gist: 317702 -  GitHub">forker (gist)</a>.</p>

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

<ul class='related_post'><li><a href='http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html' title='PHP : convertir un DATETIME en un timestamp UNIX'>PHP&#160;: convertir un DATETIME en un timestamp UNIX</a></li><li><a href='http://pioupioum.fr/snippets/textmate-commande-exporter-mots-word-wrap.html' title='TextMate : commande &laquo;&nbsp;Export words&nbsp;&raquo;'>TextMate&#160;: commande &laquo;&nbsp;Export words&nbsp;&raquo;</a></li><li><a href='http://pioupioum.fr/outils-astuces/textmate-convertir-couleur-hexadecimale-html-rgba.html' title='TextMate : convertir une couleur hexadécimale en notation RGBA'>TextMate&#160;: convertir une couleur hexadécimale en notation RGBA</a></li><li><a href='http://pioupioum.fr/developpement/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-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></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</title>
		<link>http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html</link>
		<comments>http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html#comments</comments>
		<pubDate>Tue, 09 Feb 2010 14:50:30 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[upload]]></category>
		<category><![CDATA[WordPress]]></category>

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


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
&#60;?php
// Add the new filter
add_filter&#40;'upload_mimes', 'addUploadMimes'&#41;;
&#160;
/**
 * Adds new supported media types for upload.
 *
 [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>WordPress ne supporte en upload qu&#8217;une liste exhaustive de formats de fichiers. Si comme moi vous souhaitez uploader<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> des fichiers issus de <a href="http://macromates.com/" title="TextMate — The Missing Editor for Mac OS X">TextMate</a>, comme les <code>.tmCommand</code> et autres <code>.tmSnippet</code>, ajoutez le code qui suit dans le fichier <code>functions.php</code> de votre thème<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Add the new filter</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'upload_mimes'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'addUploadMimes'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Adds new supported media types for upload.
 *
 * @see wp_check_filetype() or get_allowed_mime_types()
 * @param array $mimes Array of mime types keyed by the file extension regex corresponding to those types.
 * @return array
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> addUploadMimes<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mimes</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$mimes</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mimes</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'tmbundle|tmCommand|tmDragCommand|tmSnippet|tmLanguage|tmPreferences'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'application/octet-stream'</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$mimes</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


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

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

<ul class='related_post'><li><a href='http://pioupioum.fr/outils-astuces/wordpress-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-recuperation-avancee-images-article.html' title='WordPress : récupération avancée des images d&#8217;un article'>WordPress&#160;: récupération avancée des images d&#8217;un article</a></li><li><a href='http://pioupioum.fr/outils-astuces/afficher-images-article-page-media.html' title='WordPress : lister les images d&#8217;un article sur une page media'>WordPress&#160;: lister les images d&#8217;un article sur une page media</a></li><li><a href='http://pioupioum.fr/developpement/compass-usage-quotidien-cheatsheet.html' title='Compass au quotidien'>Compass au quotidien</a></li><li><a href='http://pioupioum.fr/developpement/compass-sprites-supprimer-cache-buster.html' title='Compass : supprimer le cache buster des sprites'>Compass&#160;: supprimer le cache buster des sprites</a></li></ul>

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

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

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

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Git ignore pour un projet Flex Builder</title>
		<link>http://pioupioum.fr/snippets/git-ignore-projet-flex-builder.html</link>
		<comments>http://pioupioum.fr/snippets/git-ignore-projet-flex-builder.html#comments</comments>
		<pubDate>Fri, 22 Jan 2010 07:57:41 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=311</guid>
		<description><![CDATA[Contenu type d&#8217;un fichier .gitignore pour un projet Flex Builder&#160;:

bin-debug
html-template
.actionScriptProperties
.flexProperties
.project
.settings
.DS_Store


Continuez votre lecture sur des sujets similaires

Git&#160;: des alias pour aller plus viteGit&#160;: 10 commandes utiles
]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Contenu type d&#8217;un fichier <code>.gitignore</code> pour un projet <strong>Flex Builder</strong>&#160;:</p>

<pre><code>bin-debug
html-template
.actionScriptProperties
.flexProperties
.project
.settings
.DS_Store
</code></pre>

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

<ul class='related_post'><li><a href='http://pioupioum.fr/developpement/git-alias-productivite.html' title='Git : des alias pour aller plus vite'>Git&#160;: des alias pour aller plus vite</a></li><li><a href='http://pioupioum.fr/developpement/git-10-commandes-utiles.html' title='Git : 10 commandes utiles'>Git&#160;: 10 commandes utiles</a></li></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/git-ignore-projet-flex-builder.html/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rotation des logs Apache</title>
		<link>http://pioupioum.fr/snippets/apache-rotation-logs.html</link>
		<comments>http://pioupioum.fr/snippets/apache-rotation-logs.html#comments</comments>
		<pubDate>Wed, 20 Jan 2010 09:14:46 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=306</guid>
		<description><![CDATA[Effectuer une rotation de ses logs Apache chaque semaine à l&#8217;aide de rotatelogs&#160;:

CustomLog "&#124;/usr/sbin/rotatelogs /var/log/www/mondomaine.tld/mondomaine.tld-access_log 604800" "combined"


Notez le pipe au début d&#8217;argument qui permet la redirection du logfile vers rotatelogs.
Merci à patpro pour l&#8217;astuce.

Continuez votre lecture sur des sujets similaires

Compass au quotidienCompass&#160;: supprimer le cache buster des spritesDrupal 6&#160;: utiliser une iframe comme contenu de [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Effectuer une <strong>rotation de ses logs Apache</strong> chaque semaine à l&#8217;aide de <strong><a href="http://httpd.apache.org/docs/2.0/programs/rotatelogs.html" title="rotatelogs - Piped logging program to rotate Apache logs - Apache HTTP Server">rotatelogs</a></strong>&#160;:</p>

<pre><code>CustomLog "|/usr/sbin/rotatelogs /var/log/www/mondomaine.tld/mondomaine.tld-access_log 604800" "combined"
</code></pre>

<p>Notez le <em>pipe</em> au début d&#8217;argument qui permet la redirection du logfile vers rotatelogs.<br />
Merci à <a href="http://www.patpro.net/" title="Je pensais qu'il était avec vous... | patpro.net">patpro</a> pour l&#8217;astuce.</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/compass-usage-quotidien-cheatsheet.html' title='Compass au quotidien'>Compass au quotidien</a></li><li><a href='http://pioupioum.fr/developpement/compass-sprites-supprimer-cache-buster.html' title='Compass : supprimer le cache buster des sprites'>Compass&#160;: supprimer le cache buster des sprites</a></li><li><a href='http://pioupioum.fr/developpement/drupal-iframe-page.html' title='Drupal 6 : utiliser une iframe comme contenu de page'>Drupal 6&#160;: utiliser une iframe comme contenu de page</a></li><li><a href='http://pioupioum.fr/developpement/compass-rvm-multiple-instances.html' title='Instances multiples de Compass avec Ruby Version Manager (rvm)'>Instances multiples de Compass avec Ruby Version Manager (rvm)</a></li><li><a href='http://pioupioum.fr/snippets/php-installer-apc-macosx.html' title='PHP : installer APC sous Mac OS X Leopard'>PHP&#160;: installer APC sous Mac OS X Leopard</a></li></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/apache-rotation-logs.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

