<?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>Pense-bête technique Wordpress</title>
	<atom:link href="http://blog.djudorange.fr/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.djudorange.fr</link>
	<description>pense-bête technique à propos de Wordpress</description>
	<lastBuildDate>Tue, 10 May 2011 08:40:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Changer la version de Jquery</title>
		<link>http://blog.djudorange.fr/2011/05/10/changer-la-version-de-jquery/</link>
		<comments>http://blog.djudorange.fr/2011/05/10/changer-la-version-de-jquery/#comments</comments>
		<pubDate>Tue, 10 May 2011 08:40:32 +0000</pubDate>
		<dc:creator>djudorange</dc:creator>
				<category><![CDATA[Fontions WordPress]]></category>
		<category><![CDATA[Thème Wordpress]]></category>
		<category><![CDATA[Versions Wordpress]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[version]]></category>
		<category><![CDATA[wordpress 3.1]]></category>

		<guid isPermaLink="false">http://blog.djudorange.fr/?p=138</guid>
		<description><![CDATA[Malheureusement, ceci n&#8217;est disponible qu&#8217;en front. Ceci est valable et tester pour WordPress 3.1. Je ne suis pas sur que cela fonctionne sur les anciennes versions. Le nouveau fichier se trouve dans le thème dans le dossier js. function my_default_scripts&#40; &#38;$scripts &#41;&#123; $scripts-&#62;registered&#91;'jquery'&#93; = new _WP_Dependency&#40; 'jquery', get_template_directory_uri&#40;&#41;.'/js/jquery-1.5.2.min.js', false, '1.5.2' &#41;; &#125; add_action&#40; 'wp_default_scripts', 'my_default_scripts', [...]]]></description>
			<content:encoded><![CDATA[<p>Malheureusement, ceci n&#8217;est disponible qu&#8217;en front.<br />
Ceci est valable et tester pour WordPress 3.1. Je ne suis pas sur que cela fonctionne sur les anciennes versions.<br />
Le nouveau fichier se trouve dans le thème dans le dossier js.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> my_default_scripts<span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$scripts</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$scripts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">registered</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> _WP_Dependency<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'jquery'</span><span style="color: #339933;">,</span> get_template_directory_uri<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/js/jquery-1.5.2.min.js'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'1.5.2'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_default_scripts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_default_scripts'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">999</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.djudorange.fr/2011/05/10/changer-la-version-de-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 3.1 : Utiliser l&#8217;API des commentaires</title>
		<link>http://blog.djudorange.fr/2010/12/07/wordpress-3-1-utiliser-lapi-des-commentaires/</link>
		<comments>http://blog.djudorange.fr/2010/12/07/wordpress-3-1-utiliser-lapi-des-commentaires/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 13:29:25 +0000</pubDate>
		<dc:creator>djudorange</dc:creator>
				<category><![CDATA[Fontions WordPress]]></category>
		<category><![CDATA[Versions Wordpress]]></category>
		<category><![CDATA[commentaires]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[get_comments]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[wordpress 3.1]]></category>
		<category><![CDATA[WP_Comment_Query]]></category>

		<guid isPermaLink="false">http://blog.djudorange.fr/?p=125</guid>
		<description><![CDATA[Comme get_posts(), get_users(), il existe dès maintenant un get_comments() utilisable comme une API: La classe utilisée est WP_Comment_Query . Elles acceptent le tableau d&#8217;argument suivant: &#8216;author_email&#8217; : email de l&#8217;utilisateur, &#8216;ID&#8216; : id du commentaire, &#8216;karma&#8217; : non utilisé, &#8216;number&#8217; : nombre de commentaire, &#8216;offset&#8217; : nombre de commentaire qu&#8217;il faut passer avant l&#8217;affichage, &#8216;orderby&#8217; : nom du [...]]]></description>
			<content:encoded><![CDATA[<p>Comme get_posts(), get_users(), il existe dès maintenant un <strong>get_comments()</strong> utilisable comme une API:</p>
<p>La classe utilisée est <strong>WP_Comment_Query</strong> . Elles acceptent le tableau d&#8217;argument suivant:</p>
<ul>
<li><em>&#8216;author_email&#8217;</em> : email de l&#8217;utilisateur,</li>
<li><em>&#8216;ID</em>&#8216; : id du commentaire,</li>
<li><em>&#8216;karma&#8217;</em> : non utilisé,</li>
<li><em>&#8216;number&#8217;</em> : nombre de commentaire,</li>
<li><em>&#8216;offset&#8217;</em> : nombre de commentaire qu&#8217;il faut passer avant l&#8217;affichage,</li>
<li><em>&#8216;orderby&#8217;</em> : nom du champ pour trier,</li>
<li><em>&#8216;order&#8217;</em> : &#8216;ASC&#8217; ou &#8216;DESC&#8217;,</li>
<li><em>&#8216;parent&#8217;</em> : id du commentaire parent,</li>
<li><em>&#8216;post_ID&#8217;</em> : id de l&#8217;article,</li>
<li><em>&#8216;status&#8217;</em> : statut des commentaires (approved, ..) ,</li>
<li><em>&#8216;type&#8217;</em> : type de commentaire (trackback, &#8230;),</li>
<li><em>&#8216;user_id&#8217; </em>: id de l&#8217;utilisateur,</li>
<li><em>&#8216;search&#8217; </em>: chaine de caractère à chercher dans les commentaires,</li>
<li><em>&#8216;count&#8217;</em> : retourne le nombre de commentaires</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.djudorange.fr/2010/12/07/wordpress-3-1-utiliser-lapi-des-commentaires/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 3.1 : Utiliser l&#8217;API des users</title>
		<link>http://blog.djudorange.fr/2010/12/07/wordpress-3-1-utiliser-lapi-des-users/</link>
		<comments>http://blog.djudorange.fr/2010/12/07/wordpress-3-1-utiliser-lapi-des-users/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 13:25:23 +0000</pubDate>
		<dc:creator>djudorange</dc:creator>
				<category><![CDATA[Fontions WordPress]]></category>
		<category><![CDATA[Versions Wordpress]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[get_users]]></category>
		<category><![CDATA[get_users_of_blog]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[users]]></category>
		<category><![CDATA[wordpress 3.1]]></category>
		<category><![CDATA[WP_User_Query]]></category>

		<guid isPermaLink="false">http://blog.djudorange.fr/?p=123</guid>
		<description><![CDATA[Nous avons &#171;&#160;enfin&#160;&#187; une API dans la version 3.1 de WordPress pour gérer les utilisateurs, certes pas forcément évolué mais surement très évolutive. Celle-ci reprend le même système que le get_posts avec &#171;&#160;get_users&#171;&#160;. Ainsi comme get_posts utilise la classe WP_Query, get_users utilise la classe WP_User_Query. Le tableau d&#8217;arguments que prend la fonction &#171;&#160;get_users&#160;&#187; et la classe &#171;&#160;WP_User_Query&#160;&#187; est celui ci dessous: &#8216;blog_id&#8217; : [...]]]></description>
			<content:encoded><![CDATA[<h2><span style="font-weight: normal; font-size: 13px;">Nous avons &laquo;&nbsp;enfin&nbsp;&raquo; une API dans la version 3.1 de WordPress pour gérer les utilisateurs, certes pas forcément évolué mais surement très évolutive.</span></h2>
<p>Celle-ci reprend le même système que le get_posts avec &laquo;&nbsp;<strong>get_users</strong>&laquo;&nbsp;. Ainsi comme get_posts utilise la classe WP_Query, get_users utilise la classe <strong>WP_User_Query</strong>.</p>
<p>Le tableau d&#8217;arguments que prend la fonction <em>&laquo;&nbsp;get_users&nbsp;&raquo;</em> et la classe <em>&laquo;&nbsp;WP_User_Query&nbsp;&raquo;</em> est celui ci dessous:</p>
<ul>
<li><em>&#8216;blog_id&#8217;</em> : Id du blog (valide qu&#8217;en multisite)(integer),</li>
<li><em>&#8216;role&#8217;</em> : rôle des utilisateurs(string),</li>
<li><em>&#8216;meta_key</em>&#8216; : clé du champ méta (string),</li>
<li><em>&#8216;meta_value</em>&#8216; : valeur du champ méta(string),</li>
<li><em>&#8216;meta_compare&#8217;</em> : opérateur de comparaison du champ méta(string),</li>
<li><em>&#8216;include</em>&#8216; : tableau de user id à inclure (array),</li>
<li><em>&#8216;exclude</em>&#8216; : tableau de user id à exclure (array),</li>
<li><em>&#8216;search&#8217;</em> : chaine de caractère à chercher dans les users (string),</li>
<li><em>&#8216;orderby&#8217;</em> : champ utiliser pour le tri(string),</li>
<li><em>&#8216;order&#8217;</em> : &#8216;ASC&#8217; ou &#8216;DESC&#8217;,</li>
<li><em>&#8216;offset&#8217;</em> : nombre de user à passer avant affichage(int),</li>
<li><em>&#8216;number&#8217;</em> : nombre de user à retourner(int),</li>
<li><em>&#8216;count_total&#8217;</em> : retourne de nombre d&#8217;utilisateur (boolean),</li>
<li><em>&#8216;fields&#8217;</em> (string // &#8216;all&#8217;),</li>
</ul>
<p>Vous pouvez donc récupérer la liste des utilisateurs du site par rôle, par clé, etc. Cette fonction était jusqu&#8217;alors inexistante sur la version 3.0 ou antérieur de WordPress. La seule façon était de récupérer la liste avec un get_users_of_blog() et faire le filtrage via PHP.</p>
<p>Cette fonction retourne un tableau d&#8217;objets de type user.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.djudorange.fr/2010/12/07/wordpress-3-1-utiliser-lapi-des-users/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress en un graphique</title>
		<link>http://blog.djudorange.fr/2010/12/02/wordpress-en-un-graphique/</link>
		<comments>http://blog.djudorange.fr/2010/12/02/wordpress-en-un-graphique/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 11:17:47 +0000</pubDate>
		<dc:creator>djudorange</dc:creator>
				<category><![CDATA[Communauté Wordpress]]></category>
		<category><![CDATA[graphique]]></category>
		<category><![CDATA[infographie]]></category>
		<category><![CDATA[the power of wordpress]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.djudorange.fr/?p=103</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.djudorange.fr/wp-content/uploads/2010/12/POWPv4600.jpg"><img class="alignnone size-full wp-image-119" title="POWPv4600" src="http://blog.djudorange.fr/wp-content/uploads/2010/12/POWPv4600.jpg" alt="" width="480" height="2510" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.djudorange.fr/2010/12/02/wordpress-en-un-graphique/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 3.1 Beta 1: Les nouveautés</title>
		<link>http://blog.djudorange.fr/2010/12/01/wordpress-3-1-les-nouveautes/</link>
		<comments>http://blog.djudorange.fr/2010/12/01/wordpress-3-1-les-nouveautes/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 11:18:03 +0000</pubDate>
		<dc:creator>djudorange</dc:creator>
				<category><![CDATA[Versions Wordpress]]></category>
		<category><![CDATA[adminbar]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Liens interne]]></category>
		<category><![CDATA[nouveauté]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[tri]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress 3.1]]></category>

		<guid isPermaLink="false">http://blog.djudorange.fr/?p=78</guid>
		<description><![CDATA[Cet article est basé sur l’article de Jane Wells publié sur le blog de développement de WordPress. Ce n&#8217;est pas une traduction stricte, mais une adaptation enrichie de ma part. C&#8217;est donc avec enthousiasme que je vous présente les nouveautés en terme de fonctionnalité de WordPress 3.1 (Bêta 1). Liens internes Le but est de [...]]]></description>
			<content:encoded><![CDATA[<p><em>Cet article est basé sur l’article de Jane Wells publié sur le blog de développement de WordPress. Ce n&#8217;est pas une traduction stricte, mais une adaptation enrichie de ma part.<br />
</em></p>
<p>C&#8217;est donc avec enthousiasme que je vous présente les nouveautés en terme de fonctionnalité de <a href="http://wordpress.org/wordpress-3.1-beta1.zip" target="_blank">WordPress 3.1 (Bêta 1)</a>.</p>
<h2>Liens internes</h2>
<p>Le but est de créer des liens entre vos articles dans le blog.</p>
<p>En situation: Vous écrivez un message (ou une page) dans WordPress. Vous  parlez de quelque chose que vous avez écrit dans l&#8217;article d&#8217;avant, et vous  pensez: &laquo;&nbsp;Je vais faire un lien vers ce dernier article!&nbsp;&raquo; Que  faites-vous? Vous pouvez ouvrir un nouvel  onglet et vous faîtes la recherche de l&#8217; article souhaité dans la liste des articles, ou vous pouvez aller sur votre blog et le trouver. Quoi  qu&#8217;il en soit, vous devez trouver que l&#8217;article et l&#8217;URL, de sorte que  lorsque vous cliquez sur le bouton de lien dans l&#8217;éditeur de message,  vous pouvez l&#8217;insérer.</p>
<div class="wp-caption aligncenter" style="width: 498px"><img title="insert/edit Link" src="http://en.blog.wordpress.com/files/2010/11/dotcom-internal-linking.png" alt="" width="488" height="451" /><p class="wp-caption-text">Les pages et les articles existant peuvent être trouvé et vous pouvez créer le lien en utilisant la recherche dynamique.</p></div>
<p>Grâce à la nouvelle fonctionnalité de liaison internes, vous pouvez  créer un lien comme d&#8217;habitude, ou vous pouvez  rechercher vos pages et articles existants dans la popup. Une combinaison  de pré-chargement, saisie semi-automatique, et ajax afin de  rendre l&#8217;outil de création de liens agréable à utiliser (et tellement plus rapide!). Nous  espérons que cet nouvelle fonctionnalité vous permettera de créer de multiples liens entre les éléments de contenu de votre site, et ce qui rendra plus facile pour vos  visiteurs de trouver des contenus similaires.</p>
<h2>Tri par colonne</h2>
<p><img class="alignleft" title="sort column" src="http://en.blog.wordpress.com/files/2010/11/dotcom-column-sort.png" alt="" width="127" height="128" />Lorsque  vous êtes dans l&#8217;administration de votre site et vous cliquez sur l&#8217;onglet des articles (ou des pages, ou des médias, ou sur un onglet du même type), avez-vous jamais souhaité que vous puissiez cliquez sur un en-tête  de colonne pour modifier l&#8217;affichage, comme pour arranger les choses  par date, par ordre alphabétique, par auteur, ou d&#8217;autres critères? Je sais que je le souhaitais depuis longtemps. Et maintenant, nous l&#8217;avons! Cette  fonction est le résultat de &laquo;&nbsp;Google Summer of Code student project&nbsp;&raquo;,  la preuve que le programme est une excellente façon de s&#8217;impliquer dans  le développement de WordPress. La petite  flèche à côté de la tête de colonne (dans ma capture d&#8217;écran par  exemple, la colonne Date) vous indique la colonne de tri, et si elle est ascendante ou  descendante. Il suffit de cliquer sur l&#8217;en-tête de colonne pour trier selon cette colonne, ou d&#8217;inverser l&#8217;ordre.</p>
<h2>Une meilleure pagination !</h2>
<p><img class="alignleft" title="Pagination" src="http://en.blog.wordpress.com/files/2010/11/dotcom-pagination.png" alt="Pagination" width="209" height="118" />Si vous  avez beaucoup de contenu, vous devrez avoir une expérience  légèrement ennuyeuse lors de la pagination dans les différents onglets et les listes d&#8217;article, de média, etc. Cliquer pour avancer et pour reculer est assez  facile, comme d&#8217;aller à la première ou le dernière page, mais qu&#8217;en est-il du milieu? Dites  vous que vous avez 23 pages dans la liste d&#8217;article, que vous êtes sur la page 6, et dans l&#8217;ordre des dates, vous pensez que celui que vous cherchez  peut-être autour de la page 15 ou plus. Vous  auriez eu à cliquer plusieurs fois pour faire avancer quelques pages jusqu&#8217;à ce que vous atteignez  a page que vous vouliez. Plus maintenant! Grâce  à au style de notre nouvelle pagination, les avance rapide / recul et le  premier / dernier liens sont toujours là, mais maintenant vous pouvez  passer directement à n&#8217;importe quelle page en changeant juste le numéro  modifiable qui s&#8217;affiche dans la zone de pagination (et en appuyant sur  entrée). Super!</p>
<h2>Une recherche dynamique (AJAX)</h2>
<p>Voir les résultats de recherche sera plus rapide et il n&#8217;y a plus besoin de  rafraîchir l&#8217;écran dans l&#8217;administration, grâce à l&#8217;ajout d&#8217;Ajax sur la page des résultats de recherche. Aller Speed Racer!</p>
<h2>Le thème bleu mis à jour</h2>
<p>Dans  les options personnelles dans votre profil, vous avez le choix entre  gris et bleu pour la couleur de l&#8217;administratrion (la valeur par défaut est la  couleur grise). Nous avions actualisé le thème gris, mais nous avions pas mis à jour le bleu. (Rappelez-vous  quand nous sommes passés de l&#8217;en-tête sombre à l&#8217;en-tête plus clair?) Le nouveau thème bleu est plus léger, plus propre, et  basé sur les même nuances que le thème gris, mais avec une  teinte bleue de sorte que vous resteriez focalisé sur la création de votre contenu, sans distraction. Si  vous n&#8217;avez jamais essayé le thème bleu, ce serait le moment  idéal pour lui donner une chance et de voir comment vous l&#8217;aimez! Y at-il d&#8217;autres couleurs que vous aimeriez avoir comme options? Faites-nous savoir dans les commentaires!</p>
<h2>Prise en charge d&#8217;IE9</h2>
<p>Si vous  avez eu des problèmes en utilisant des fonctionnalités de  glisser-déposer (drag&amp;drop) dans l&#8217;administration ou avez eu des problèmes avec  l&#8217;éditeur riche sur la page de création d&#8217;article lorsque vous utilisez  Internet Explorer 9, désolé! Des  améliorations ont été faites pour rendre fonctionnel ces fonctions de  manière régulière dans le dernier navigateur de Microsoft.</p>
<h2>Barre d&#8217;administration</h2>
<p style="text-align: center;"><a href="http://blog.djudorange.fr/wp-content/uploads/2010/12/adminbar.png"><img class="size-full wp-image-85 aligncenter" title="Barre d'administration" src="http://blog.djudorange.fr/wp-content/uploads/2010/12/adminbar.png" alt="" width="392" height="29" /></a></p>
<p style="text-align: left;"><a href="http://blog.djudorange.fr/wp-content/uploads/2010/12/adminbar.png"></a>Une barre d&#8217;administration a été implémenté, pour que vous puissiez accéder aux onglets de l&#8217;administration du côté front. Vous pouvez donc avoir un accès rapide sur l&#8217;édition de votre profil (à la façon de buddypress) et la liste des utilisateurs.Vous pouvez aussi accéder à la page de création pour les différents type de contenu (articles, pages), accéder à la liste des commentaires et accéder à l&#8217;administration des widgets et des menus.Un champ de recherche est aussi disponible. Cela fait juste une recherche en front.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.djudorange.fr/2010/12/01/wordpress-3-1-les-nouveautes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ajouter une action lorsque l&#8217;article est publié</title>
		<link>http://blog.djudorange.fr/2010/10/21/ajouter-une-action-lorsque-larticle-est-publie/</link>
		<comments>http://blog.djudorange.fr/2010/10/21/ajouter-une-action-lorsque-larticle-est-publie/#comments</comments>
		<pubDate>Thu, 21 Oct 2010 07:46:22 +0000</pubDate>
		<dc:creator>djudorange</dc:creator>
				<category><![CDATA[Fontions WordPress]]></category>
		<category><![CDATA[add_action]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[do_action]]></category>
		<category><![CDATA[nouvel article]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[publié]]></category>
		<category><![CDATA[publier]]></category>

		<guid isPermaLink="false">http://blog.djudorange.fr/?p=75</guid>
		<description><![CDATA[Dans wordpress, il manque cruellement une action qui est activé lorsque l&#8217;on publie un article mais pas lorsqu&#8217;on l&#8217;édite. add_action&#40;'transition_post_status', 'action_new_post', 10, 3&#41;; &#160; function action_new_post&#40; $new_status, $old_status, $post &#41;&#123; if&#40; $old_status != 'publish' &#38;&#38; $new_status == 'publish' &#41;&#123; do_action&#40;'publish_new_post', $post&#41;; &#125; &#125; Vous pouvez ensuite utiliser l&#8217;action &#8216;publish_new_post&#8217; pour lancer une fonction que au [...]]]></description>
			<content:encoded><![CDATA[<p>Dans wordpress, il manque cruellement une action qui est activé lorsque l&#8217;on publie un article mais pas lorsqu&#8217;on l&#8217;édite.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'transition_post_status'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'action_new_post'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> action_new_post<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$new_status</span><span style="color: #339933;">,</span> <span style="color: #000088;">$old_status</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</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;">$old_status</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'publish'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$new_status</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'publish'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
do_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'publish_new_post'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Vous pouvez ensuite utiliser l&#8217;action <strong>&#8216;publish_new_post&#8217;</strong> pour lancer une fonction que au moment où le post est publié</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.djudorange.fr/2010/10/21/ajouter-une-action-lorsque-larticle-est-publie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gérer les miniatures dans WordPress 3.0</title>
		<link>http://blog.djudorange.fr/2010/05/31/gerer-les-miniatures-dans-wordpress-3-0/</link>
		<comments>http://blog.djudorange.fr/2010/05/31/gerer-les-miniatures-dans-wordpress-3-0/#comments</comments>
		<pubDate>Mon, 31 May 2010 12:25:49 +0000</pubDate>
		<dc:creator>djudorange</dc:creator>
				<category><![CDATA[Fontions WordPress]]></category>
		<category><![CDATA[add_image_size]]></category>
		<category><![CDATA[add_theme_support]]></category>
		<category><![CDATA[gestion de miniature]]></category>
		<category><![CDATA[miniature]]></category>
		<category><![CDATA[plusieurs miniatures]]></category>
		<category><![CDATA[post types]]></category>
		<category><![CDATA[post_types]]></category>
		<category><![CDATA[the_post_thumbnail]]></category>
		<category><![CDATA[thumbnail]]></category>
		<category><![CDATA[types]]></category>
		<category><![CDATA[wordpress 3.0]]></category>

		<guid isPermaLink="false">http://blog.djudorange.fr/?p=56</guid>
		<description><![CDATA[Dans les features de WordPress 3.0, nous avons la gestion des miniatures. Ce qui nous intéresse ici c&#8217;est de pouvoir générer plusieurs formats de miniatures. Dans le fichier functions.php du thème: add_action&#40; 'after_setup_theme', 'ma_fonction' &#41;; function ma_fonction&#40;&#41; &#123; add_theme_support&#40; 'post-thumbnails' &#41;; add_image_size&#40; 'list-normal', 196, 132, true &#41;; &#125; Explications: Le &#171;&#160;add_theme_support&#160;&#187; authorise dans l&#8217;admin la [...]]]></description>
			<content:encoded><![CDATA[<p>Dans les features de WordPress 3.0, nous avons la gestion des miniatures. Ce qui nous intéresse ici c&#8217;est de pouvoir générer plusieurs formats de miniatures.<br />
Dans le fichier functions.php du thème:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'after_setup_theme'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ma_fonction'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> ma_fonction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	add_theme_support<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post-thumbnails'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	add_image_size<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'list-normal'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">196</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">132</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></pre></div></div>

<p><strong>Explications:</strong></p>
<ul>
<li>Le &laquo;&nbsp;add_theme_support&nbsp;&raquo; authorise dans l&#8217;admin la gestion des miniatures. Ceci est obligatoire pour utiliser les miniatures</li>
<li>Le &laquo;&nbsp;add_image_size&nbsp;&raquo; est la fonction qui va rajouter un format de miniature. </li>
<li>En paramètre, il faut passer en premier l&#8217;identifiant de la taille de miniature, en deuxième la largeur, en troixième la hauteur et en 4ème si oui ou non la miniature peut être coupée.</li>
</ul>
<p>Ensuite, lors de la création d&#8217;un article, lors de l&#8217;ajout d&#8217;un photo, il faut la déclarer comme &laquo;&nbsp;featured image&nbsp;&raquo; ou &laquo;&nbsp;miniature de l&#8217;article&nbsp;&raquo;. Ceci indique que c&#8217;est cette image qui correspondra à l&#8217;article.<br/><br />
Dans le template, dans le single.php ou lors du listage (index.php, category.php, search.php, tag.php , etc..), on affichera l&#8217;image avec ce qui suit:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'list-normal'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'alignleft'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>Explications:</strong></p>
<ul>
<li>Cette fonction retourne une balise img.</li>
<li>En paramètre, il y a en premier, l&#8217;identifiant de la taille de miniature que j&#8217;ai indiquer dans mon fichier functions.php du thème.</li>
<li>En deuxième, ce sont les arguments que l&#8217;on peut ajouter comme une classe ou un id. Ici je rajoute la classe &#8216;alignleft&#8217;.</li>
</ul>
<p>
Edit: pour gérer les miniatures pour différents types de contenu, il faut utiliser cela:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_theme_support<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post-thumbnails'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'typedecontenu1'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'typedecontenu2'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>
</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.djudorange.fr/2010/05/31/gerer-les-miniatures-dans-wordpress-3-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comment faire du Ajax avec WordPress ?</title>
		<link>http://blog.djudorange.fr/2010/05/26/comment-faire-du-ajax-avec-wordpress/</link>
		<comments>http://blog.djudorange.fr/2010/05/26/comment-faire-du-ajax-avec-wordpress/#comments</comments>
		<pubDate>Wed, 26 May 2010 17:21:57 +0000</pubDate>
		<dc:creator>djudorange</dc:creator>
				<category><![CDATA[Fontions WordPress]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[web2.0]]></category>

		<guid isPermaLink="false">http://blog.djudorange.fr/?p=50</guid>
		<description><![CDATA[Pour le front ! Ceci est très simple. Dans le plugin, il suffit de rajouter 2 actions. une lorsque que l&#8217;on est loggué et l&#8217;autre pour le public: add_action&#40;'wp_ajax_mon_action', 'ajax_sort_tags' &#41;; add_action&#40;'wp_ajax_nopriv_mon_action', 'ajax_sort_tags' &#41;; Dans la fonction appelée, on va retourner le bloc avec les données chargées avec un die($donnees_retournee). Si on a besoin de [...]]]></description>
			<content:encoded><![CDATA[<p>Pour le front ! Ceci est très simple. </p>
<p>Dans le plugin, il suffit de rajouter 2 actions. une lorsque que l&#8217;on est loggué et l&#8217;autre pour le public:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_ajax_mon_action'</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">'ajax_sort_tags'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_ajax_nopriv_mon_action'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ajax_sort_tags'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Dans la fonction appelée, on va retourner le bloc avec les données chargées avec un die($donnees_retournee). Si on a besoin de paramètres, on pourra les récupérer par $_REQUEST['ma_variables'].</p>
<p>Dans le template, on va faire l&#8217;appel ajax comme suit:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.ma_class_bouton&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> variable <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
		jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.ma_class_block&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;?php echo  get_bloginfo( 'wpurl' ) . '/wp-admin/admin-ajax.php'; ?&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;action&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;mon_action&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;variable&quot;</span> <span style="color: #339933;">:</span> variable<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>J&#8217;appelle donc mon action avec en plus la valeur 1 en parametre que l&#8217;on va pouvoir récupérer avec le $_REQUEST['variable']</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.djudorange.fr/2010/05/26/comment-faire-du-ajax-avec-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Insérer un script Javascript proprement</title>
		<link>http://blog.djudorange.fr/2010/05/26/inserer-un-script-javascript-proprement/</link>
		<comments>http://blog.djudorange.fr/2010/05/26/inserer-un-script-javascript-proprement/#comments</comments>
		<pubDate>Wed, 26 May 2010 17:04:20 +0000</pubDate>
		<dc:creator>djudorange</dc:creator>
				<category><![CDATA[Fontions WordPress]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[theme]]></category>

		<guid isPermaLink="false">http://blog.djudorange.fr/?p=48</guid>
		<description><![CDATA[Le plus souvent, on fait appel à un script Js dans le code. Le mieux étant d&#8217;utiliser les fonctions de WordPress afin d&#8217;insérer ce code proprement. Dans le thèmes, dans la page functions.php: add_action&#40; 'init', 'load_js' &#41;; // Add js to use this theme function load_js&#40;&#41; &#123; wp_enqueue_script&#40; 'mon-script', get_bloginfo&#40;'stylesheet_directory'&#41; . '/js/mon-script.js', array&#40;'jquery'&#41;, '0.1', false&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>Le plus souvent, on fait appel à un script Js dans le code. Le mieux étant d&#8217;utiliser les fonctions de WordPress afin d&#8217;insérer ce code proprement.<br />
Dans le thèmes, dans la page functions.php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'load_js'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Add js to use this theme</span>
<span style="color: #000000; font-weight: bold;">function</span> load_js<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_enqueue_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'mon-script'</span><span style="color: #339933;">,</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'stylesheet_directory'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/js/mon-script.js'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'0.1'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>
<strong>Explications:</strong></p>
<ul>
<li>le premier paramètre &#8216;mon-script&#8217; est l&#8217;identifiant du script</li>
<li>le deuxième paramètre get_bloginfo(&#8216;stylesheet_directory&#8217;) . &#8216;/js/mon-script.js&#8217; est l&#8217;adresse du script</li>
<li>le troisième paramètre array(&#8216;jquery&#8217;) est le tableau des dépendances du script. ici le script &#8216;mon-script.js&#8217; à besoin de jquery pour fonctionner</li>
<li>le quatrième paramètre &#8217;0.1&#8242; est la version du script</li>
<li>le cinquième paramètre false est false si le script est chargé dans le header (wp_head) ou true si le script doit être chargé dans le footer (wp_footer)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.djudorange.fr/2010/05/26/inserer-un-script-javascript-proprement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Réécriture d&#8217;URL ou url rewriting</title>
		<link>http://blog.djudorange.fr/2010/05/21/reecriture-durl-ou-url-rewriting/</link>
		<comments>http://blog.djudorange.fr/2010/05/21/reecriture-durl-ou-url-rewriting/#comments</comments>
		<pubDate>Fri, 21 May 2010 08:46:13 +0000</pubDate>
		<dc:creator>djudorange</dc:creator>
				<category><![CDATA[Fontions WordPress]]></category>
		<category><![CDATA[catégories]]></category>
		<category><![CDATA[catégory]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[parseQuery]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[query_vars]]></category>
		<category><![CDATA[réécriture d'url]]></category>
		<category><![CDATA[rewriting]]></category>
		<category><![CDATA[taxinomie]]></category>
		<category><![CDATA[taxonomy]]></category>
		<category><![CDATA[template_redirect]]></category>
		<category><![CDATA[term]]></category>

		<guid isPermaLink="false">http://blog.djudorange.fr/?p=43</guid>
		<description><![CDATA[Lorsque vous travaillez avec les taxinomies et les catégories, on peut avoir besoin de réécrire l&#8217;url afin d&#8217;atteindre la taxonomie et la catégorie en même temps. Exemple : dans la taxinomie &#171;&#160;genre&#160;&#187;, les terms &#171;&#160;hommes&#160;&#187; et &#171;&#160;femmes&#160;&#187;. Mais tous les deux ont les catégories &#171;&#160;habillements&#160;&#187; et &#171;&#160;accessoires&#160;&#187; mais avec des articles différents. Le mieux étant [...]]]></description>
			<content:encoded><![CDATA[<p>Lorsque vous travaillez avec les taxinomies et les catégories, on peut avoir besoin de réécrire l&#8217;url afin d&#8217;atteindre la taxonomie et la catégorie en même temps.</p>
<p>Exemple : dans la taxinomie &laquo;&nbsp;genre&nbsp;&raquo;, les terms &laquo;&nbsp;hommes&nbsp;&raquo; et &laquo;&nbsp;femmes&nbsp;&raquo;. Mais tous les deux ont les catégories &laquo;&nbsp;habillements&nbsp;&raquo; et &laquo;&nbsp;accessoires&nbsp;&raquo; mais avec des articles différents. Le mieux étant d&#8217;encodé l&#8217;url en site.com/genre/[hommes ou femmes]/category/[habillements ou accessoires].</p>
<p>Pour cela, il faut dans un plugin réécrire l&#8217;url:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'generate_rewrite_rules'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'addRewriteRules'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> addRewriteRules<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$wp_rewrite</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$new_rules</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'genre/([^/]+)/category/([^/]+)/?$'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'index.php?ge='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;ca='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rules</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$new_rules</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rules</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'query_vars'</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">'addQueryVar'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> addQueryVar<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$qvars</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	  <span style="color: #000088;">$qvars</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ge'</span><span style="color: #339933;">;</span>
	  <span style="color: #000088;">$qvars</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ca'</span><span style="color: #339933;">;</span>
	  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$qvars</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;">'parse_query'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'parseQuery'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// To parse query and add the cible taxo + category</span>
<span style="color: #000000; font-weight: bold;">function</span> parseQuery<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$query</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	remove_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'parse_query'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'parseQuery'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Options date</span>
	<span style="color: #000088;">$genre</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span>get_query_var<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ge'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$category</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span>get_query_var<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ca'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$genre</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span>  <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Add post_type on Query</span>
		<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">is_tax</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">is_category</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">is_home</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'taxonomy'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'genre'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'genre'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$genre</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'term'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$genre</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$cat</span> <span style="color: #339933;">=</span> get_category_by_slug<span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cat'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cat</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">term_id</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'category__in'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cat</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">term_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Explications:</strong></p>
<ul>
<li>la fonction <b>addRewriteRules</b> va ajouter la réécriture d&#8217;url qu&#8217;il faut. Elle va transformer le &laquo;&nbsp;/genre/hommes/category/habillements&nbsp;&raquo; en &laquo;&nbsp;index.php?ge=homme&#038;ca=category&nbsp;&raquo;. Elle fonctionne avec les posix comme type de regex</li>
<li>la fonction <b>addQueryVar</b> va rajouter dans le query les clés &laquo;&nbsp;ge&nbsp;&raquo; et &laquo;&nbsp;ca&nbsp;&raquo;.</li>
<li>la fonction <b>parseQuery</b> va parser le query pour insérer les valeurs qu&#8217;il faut pour afficher les articles que l&#8217;on souhaite</li>
<li>Enfin vous pouvez toujours utiliser l&#8217;action &#8216;template_redirect&#8217; pour rediriger vers le template de votre choix. Voire l&#8217;article associé à cette fonction</li>
</ul>
<p>
<i>Edit du 27 août 2010</i><br />
<br/><br />
Lorsque l&#8217;on rajoute une règle de réécriture, il est préférable de rajouter la possibilité de pagination ainsi que les flux xml. Pour cela vous pouvez rajouter ces règles (je prends le même contexte que avant):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> addRewriteRules<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$wp_rewrite</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$new_rules</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'genre/([^/]+)/category/([^/]+)/?$'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'index.php?ge='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;ca='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rules</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$new_rules</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rules</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$new_rules</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'genre/([^/]+)/category/([^/]+)/page/page/?([0-9]{1,})/?$'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'index.php?ge='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;ca='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;paged='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</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;">// Pour la pagination</span>
		<span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rules</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$new_rules</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rules</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$new_rules</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'genre/([^/]+)/category/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'index.php?ge='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;ca='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;feed='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</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;">// Pour le feed</span>
		<span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rules</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$new_rules</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rules</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$new_rules</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'genre/([^/]+)/category/([^/]+)/(feed|rdf|rss|rss2|atom)/?$'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'index.php?ge='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;ca='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;feed='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</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;">// Pour le feed</span>
		<span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rules</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$new_rules</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rules</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Voilà la pagination et le feed supportés.<br />
<strong>Attention, si vous utiliser template_redirect pour charger votre template de votre choix, il faut rajouter ce qui suit afin que WordPress affiche les xml</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> is_feed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
     <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span></pre></div></div>
</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.djudorange.fr/2010/05/21/reecriture-durl-ou-url-rewriting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

