<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Tisseur de toile</title>
	
	<link>http://www.tisseur-de-toile.fr</link>
	<description>Wordpress expert, Backend and Fronted web developer in Strasbourg France</description>
	<lastBuildDate>Mon, 16 May 2011 07:20:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/TisseurDeToile" /><feedburner:info uri="tisseurdetoile" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Just a question of methods…</title>
		<link>http://feedproxy.google.com/~r/TisseurDeToile/~3/XSmpQ7oXwRs/just-a-question-of-methods.html</link>
		<comments>http://www.tisseur-de-toile.fr/general-information/just-a-question-of-methods.html#comments</comments>
		<pubDate>Wed, 30 Mar 2011 10:40:31 +0000</pubDate>
		<dc:creator>jeFFF</dc:creator>
				<category><![CDATA[General information]]></category>

		<guid isPermaLink="false">http://www.tisseur-de-toile.fr/?p=279</guid>
		<description><![CDATA[As you could imagine, today's post will not be about Object Oriented Programming but just an expression of few ideas about web sites development methodology.]]></description>
			<content:encoded><![CDATA[<p>As I said earlier to <a href="http://www.tresadenn.com/" target="_blank">Tresadenn</a>, blogging in english is a bit difficult, especially when you want to post quite often.<br />
You&#8217;ve got ideas, start writing, do something else and just let the post going to dust because you just forgot what you wanted to talk about in the first place.</p>
<p>Today, I&#8217;m trying a new technique (should i say method ? <img src='http://www.tisseur-de-toile.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> )&#8230; I just set a big white page on my 24&#8243; screen and I&#8217;m writing with the zoom at maximum, it&#8217;s quite a good way to dive in your text and your thoughts.</p>
<p>Well, that&#8217;s enough for the pseudo philosophy, let&#8217;s go straight to the main topic : <strong>Web site development methodology</strong></p>
<h3>1. a matter of content !</h3>
<p>People starting to have real bad habits about creating and gathering content for a website.<br />
When you start speaking with your client (or whatever you call him) you quickly find out that behind the idea of creating a website, he didn&#8217;t think about the content itself.<br />
It should be the starting point of your website, even google found out that the keywords and short descriptions could lead to a bunch of nonsense and started to think of indexing content itself rather than stuff you could cheat with !</p>
<p>This content have actually two major impacts on the rest of the develoment regarding the graphics and the final cost of the site.<br />
How many times I had to re-think or adapt the graphics with the designer because we needed more space to put all the client&#8217;s content. <br />
To take a shorcut, it&#8217;s just nonsense to think that you can put 15 people in a Ferarri !<br />
The graphic design should be tailored with your content, not the other way, it&#8217;s really important to have a major part of it at the very beginning of the project.<br />
As I said above, it can also have an impact on the final cost. If you&#8217;re start the project, and discover in the middle of it that you need to add powerful import filters and change the structure of the database you can expect unsatisfaction for customer, it&#8217;s a big risk.</p>
<h3>2. I&#8217;m a developer, not a copy machine !</h3>
<p>A few years back, Web Development was just about creating HTML structures and fill it with content. All you needed was a solid knowledge of this markup system.<br />
With the evolution of tools and the development of CMS, customers wanted more control on the edition tool. The developers&#8217; job evolved as well to create powerful, but user-friendly, tools for masses.</p>
<p>Great, but that&#8217;s the point ?<br />
Fairly simple, developers are not copy machine in two ways, first of all, web site coding can not be sum up as « take this portion of code from this site, you will save time and our money as well! »<br />
If it&#8217;s obvious for some, how many developers heard that kind of sentence which leads to tools full of bugs. To save time, you create new bugs by patching old lines of codes without thinking of what might happen in other portions of the site, maybe the function you updated is used somewhere else you know&#8230; you then create coders nightmares which will in the end cost more money to maintain and update.</p>
<p>It&#8217;s also a waste of time to take a developer and make him fill the content for the client.<br />
Let&#8217;s put it this way, if you create the tool and noone except you is using it, what&#8217;s the point ? Let&#8217;s just go back in the 90&#8242;s, HTML is real good you know <img src='http://www.tisseur-de-toile.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  <br />
The project manager should be the first one to use it in order to adjust your development. He knows the client (or at least he should) and should be able to know what&#8217;s best for the administrator, or editor, of the web site.</p>
<p>Well, that&#8217;s all for now, once again what is expressed on this post his just a few personnal ideas about web site development.<br />
Feel free to express you opinion, this is not a closed subject.</p>
<p>See ya,<br />
jeFFF</p>
<p><em>[UPDATE] Really interesting article about content @ Web Designer Depot, It really worth reading : <<a href="http://www.webdesignerdepot.com/2011/03/how-to-spot-and-avoid-web-copy-that-kills-websites">www.webdesignerdepot.com/2011/03/how-to-spot-and-avoid-web-copy-that-kills-websites</a>></em></p>
<img src="http://feeds.feedburner.com/~r/TisseurDeToile/~4/XSmpQ7oXwRs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tisseur-de-toile.fr/general-information/just-a-question-of-methods.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.tisseur-de-toile.fr/general-information/just-a-question-of-methods.html</feedburner:origLink></item>
		<item>
		<title>Blogging is not only about WordPress…</title>
		<link>http://feedproxy.google.com/~r/TisseurDeToile/~3/Rpf6aA1UrXI/blogging-is-not-only-about-wordpress.html</link>
		<comments>http://www.tisseur-de-toile.fr/comics-place/blogging-is-not-only-about-wordpress.html#comments</comments>
		<pubDate>Mon, 21 Feb 2011 12:33:46 +0000</pubDate>
		<dc:creator>jeFFF</dc:creator>
				<category><![CDATA[Comics Place]]></category>

		<guid isPermaLink="false">http://www.tisseur-de-toile.fr/?p=263</guid>
		<description><![CDATA[... It's also about COMICS !!! <br />
A really quick update with thoughts about Fantastic Four #587 by Jonathan Hickman and Steve Epting.]]></description>
			<content:encoded><![CDATA[<p>I finally received the last issue of Fantastic Four a few days ago and I was thinking about it while cycling to work.</p>
<p>Another death in the Marvel Universe ! and not in a underground series with second range heroes but in the more important one of the editor.<br />
So this is it, the Torch is dead, his foolish behavior, commitment to the team and sense of friendship succeeded where Doom failed so many times.<br />
But can I really believe in this death ? I&#8217;m pretty sure Johnny Storm will come back later this year.</p>
<p>Since the beginning of the 2000s&#8217; the editorial line of Marvel is based on big events chain together.<br />
House of M was pretty good ( Avengers disassembled as well) and Civil War was, as fars as i&#8217;m concerned, the best event Marvel ever did so far.<br />
During this period, the FF were badly compromised without any death. The events and decisions of the members was tearing the family apart and finally led to the best disband in the comic book industry. But it was maybe nothing compared to the epic conclusion with the death of Captain America itself !</p>
<p>Speaking about that, the death of the torch and Captain America have something in common, I was spoiled for both of them by people who are absolutely not interested in Super Hero comic books.<br />
This is one of Marvel&#8217;s victory, with these big marketing &#8220;coups&#8221;, they attract attention of people and media who normally don&#8217;t care about them.</p>
<p>But let&#8217;s get back to FF #587, when I received it I fell like I&#8217;ve seen this kind of trick before. The comic book was wrapped up in a Plastic bag with a big 3 on it, which immediately reminded me the death of superman (another big coup from the other side <img src='http://www.tisseur-de-toile.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ). <br />
After looking at this packaging, you take your best cutter and open it very gently because you never know if someday this kind of issue will worth a million bucks if you kept it in one piece ! <img src='http://www.tisseur-de-toile.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> <br />
I read it pretty quickly and was a bit disappointed by the conclusion. I really like Jonathan Hickman, I knew his work reading <a href="http://en.wikipedia.org/wiki/The_Nightly_News" target="_blank">the nightly news</a>, visited <a href="http://pronea.com/" target="_blank">pronea.com</a> a few times already and was really excited when I heard that he was the new writer of the FF a few issues back.<br />
The beginning of this run penciled by Dave Eaglesham (who did a great job on the new JSA) was very interesting, following the rebirth of the team and the end of the civil war, Reed finally let down the &#8220;solve everything&#8221; idea, this was good !<br />
The following issues, on the contrary where kind of boring, they were not really linked together so what you would expect at the end of an issue was not matching the actual content.</p>
<p>I particularly appreciate the drama tension at the end of the issue, which rely a lots on Steve Epting&#8217;s artwork. I think it&#8217;s the best choice marvel ever made after Eaglesham.<br />
But if the pitch of the countdown was pretty good, the end let just think that the Torch will popup again later this year or maybe next, who really die in the Marvel Universe these days ?</p>
<p>Come on Marvel, who will believe that you really kill a FF the year of their 50th anniversary for Christ sakes ! <img src='http://www.tisseur-de-toile.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> <br />
If you really want us to believe that please kill Steve rogers once again and show us corpses and blood !!! you&#8217;re no longer attached to the Comics Code remember ? <img src='http://www.tisseur-de-toile.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Anyway, and to conclude, the FF is still a really good entertainment after a day at work.</p>
<p>See you around Johnny,<br />
jeFFF </p>
<p><em>credits &#8211; &#8220;Minimal human Torch&#8221;  © biotwist  : <a href="http://biotwist.deviantart.com/" target="_blank">biotwist.deviantart.com</a></em></p>
<img src="http://feeds.feedburner.com/~r/TisseurDeToile/~4/Rpf6aA1UrXI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tisseur-de-toile.fr/comics-place/blogging-is-not-only-about-wordpress.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.tisseur-de-toile.fr/comics-place/blogging-is-not-only-about-wordpress.html</feedburner:origLink></item>
		<item>
		<title>[UP] Pimp my WordPress menu part 2 :access granted to authorized personnel only !</title>
		<link>http://feedproxy.google.com/~r/TisseurDeToile/~3/TR4B4-mjFOM/pimp-my-wordpress-menu-part-2-access-granted-to-authorized-personnel-only.html</link>
		<comments>http://www.tisseur-de-toile.fr/wordpress-tricks/pimp-my-wordpress-menu-part-2-access-granted-to-authorized-personnel-only.html#comments</comments>
		<pubDate>Sat, 12 Feb 2011 21:26:35 +0000</pubDate>
		<dc:creator>jeFFF</dc:creator>
				<category><![CDATA[Wordpress tricks]]></category>

		<guid isPermaLink="false">http://www.tisseur-de-toile.fr/?p=201</guid>
		<description><![CDATA[This is another exemple of what you can achieve when you extend the menu walker.<br />Here, we will display menu items depending of your Wordpress user role.]]></description>
			<content:encoded><![CDATA[<p>Today’s goal is to hide specific menus and grant an access only if the user have the correct WordPress user role.<br />
This is quite useful if you want to restrict a part of your site and make it an extranet.<br />
As we saw <a href="http://www.tisseur-de-toile.fr/wordpress-tricks/fixing-the-menu-wordpress-menu-tricks-part-1.html" target="_blank">in the previous article</a>, we can add this kind of capabilities by creating a new set of functions for the walker class and go further in the menu enhancement.<br />
I strongly advise you to have a look at &#8220;<a href="http://www.tisseur-de-toile.fr/wordpress-tricks/fixing-the-menu-wordpress-menu-tricks-part-1.html" target="_blank">fixing the menu</a>&#8221; as I Will use somes techniques described there.<br />
I also invite you to use the Twenty ten Theme and <a href="#source">download the source code</a> at the bottom of this page to have a look at the code.</p>
<p>Finally, this method is totally open to discussion, you know what to do <img src='http://www.tisseur-de-toile.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>1. setting up the engine</h3>
<p>First of all, you have to create a menu and pages attached to it.<br />
As an example I created 3 pages : About, Events and sample and create a &#8220;main menu&#8221; zone in my header.php file.<br />
To set up the access we need 2 kinds of data, a trigger which will allow us to easily deactivate the restrictions and an array which will store all the pages ID we want to restrict (sorted by WP role).<br />
You will find something like this in the source code :<br />
[php]<br />
define(&quot;_USE_RESTRICTED_ACCESS&quot;, true); // main trigger<br />
$menu_restricted_access_array['subscriber'] = array( &#8217;23&#8242;, &#8217;21&#8242;); // restriction for subscribers<br />
$menu_restricted_access_array['contributor'] = array( &#8217;2&#8242;,&#8217;23&#8242; ); // restriction for constributors<br />
[/php]<br />
<em>Note : you can look at your status bar to find the pages ID.</em><br />
In this example, only the subscribers can access the About and Events pages.<br />
The contributors, on the other hand, will have access to the Events and Sample page.<br />
Which leave absolutely no menu item to display in the header.<br />
As far as the administrator is concerned, he will have access to everything ! <img src='http://www.tisseur-de-toile.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>2. adding few functions</h3>
<p>As part of the menu walker extension I will create 4 new functions.<br />
The name should be speaking by itself but I will explain how they work.</p>
<ul>
<li><strong><em>getCurrentUserRole</em></strong> will access the current user object to get his role, the result wil be stored in a private role of the object :<br />
[php]<br />
private function getCurrentUserRole()<br />
{<br />
    global $current_user;</p>
<p>    if ( $this-&gt;current_user_role == &quot;&quot; )<br />
    {<br />
        $this-&gt;current_user_role = $current_user-&gt;roles[0];<br />
    }<br />
    return $this-&gt;current_user_role;<br />
}<br />
[/php]
</li>
<li><strong><em>isAdmin</em></strong> will just check if we can grant access to everything :<br />
[php]<br />
private function isAdmin()<br />
{<br />
    $current_role = $this-&gt;getCurrentUserRole();</p>
<p>    if ( $current_role == &quot;administrator&quot; )<br />
    {<br />
        return true;<br />
    }<br />
    else<br />
    {<br />
        return false;<br />
    }<br />
}[/php]
</li>
<li><strong><em>getAllRestrictions</em></strong> will examine the entire restrictions array, merge all IDs and return the result to provide a way to hide all restricted menus :<br />
[php]<br />
private function getAllRestrictions()<br />
{<br />
    global $menu_restricted_access_array;</p>
<p>    $all_restrictions_array = array();</p>
<p>    foreach ( $menu_restricted_access_array as $one_restriction )<br />
    {<br />
        $all_restrictions_array = array_merge($all_restrictions_array, $one_restriction);<br />
    }<br />
    $all_restrictions_array = array_unique($all_restrictions_array);</p>
<p>    return $all_restrictions_array;<br />
}[/php]
</li</p>
<li><strong><em>isAccessGranted</em></strong> will analyze the restriction array to allow acces (or not).<br />
This one needs a little more explanation as its the core function of this tutorial.</p>
<p>First of all, if the user is the admin, we always grant the access on the item <em>(line 5)</em>.<br />
If not we check if the current role has limitations <em>(line 9)</em>, if it&#8217;s the case we check if the current menu item is in the role restrictions <em>(line 13)</em><br />
And finally if none of these conditions are verified we always grant access <em>(line 24)</em>.<br />
[php]<br />
private function isAccessGranted( $id_menu_item )<br />
{<br />
    global $menu_restricted_access_array;</p>
<p>    if ( $this-&gt;isAdmin() )<br />
    {<br />
        return true;<br />
    }<br />
    else if ( isset($menu_restricted_access_array[$this-&gt;current_user_role]) )<br />
    {<br />
        $restricted_access = $menu_restricted_access_array[$this-&gt;current_user_role];</p>
<p>        if ( in_array($id_menu_item, $restricted_access) )<br />
        {<br />
            return true;<br />
        }<br />
        else<br />
        {<br />
            return false;<br />
        }<br />
    }<br />
    else<br />
    {<br />
        return true;<br />
    }<br />
}[/php]
</li>
</ul>
<h3>3. menu final render</h3>
<p>All these functions are triggered when the final render of the menu happen.<br />
I modified a little bit the start_el function to still take care about the publication issue (cf. <a href="http://www.tisseur-de-toile.fr/wordpress-tricks/fixing-the-menu-wordpress-menu-tricks-part-1.html" target="_blank">my previous article</a>) like this :<br />
[php]$is_item_published = ( $item_data-&gt;post_status == &quot;publish&quot; ) ? true : false;[/php]</p>
<p>This creates a new flag which will be combined to the restriction process.<br />
And now, let the party started with this bit of code :<br />
[php]if ( _USE_RESTRICTED_ACCESS )<br />
{<br />
    $restrictions_array = $this-&gt;getAllRestrictions();</p>
<p>    if ( is_user_logged_in() )<br />
    {<br />
        $item_to_display = ( $is_item_published &amp;&amp; $this-&gt;isAccessGranted($item-&gt;object_id) ) ? true : false ;<br />
    }<br />
    else if ( in_array($item-&gt;object_id, $restrictions_array) )<br />
    {<br />
        $item_to_display = false;<br />
    }<br />
    else<br />
    {<br />
        $item_to_display = $is_item_published;<br />
    }<br />
}<br />
else<br />
{<br />
    $item_to_display = $is_item_published;<br />
}[/php]<br />
This needs a little explanation :<br />
If the system is activated <em>(line 1)</em> and the user is logged <em>(line 5)</em> then I check the access and check the publication status.<br />
If the user is not logged in I just check if the item is part of the rectriction <em>(line 9)</em> previously gathered <em>(line 3)</em>.<br />
If none of above conditions are verified I just check the published status <em>(line 15)</em>.</p>
<h3>Final thoughts</h3>
<p>This is it !<br /> <br />
With a few hacks we can do a clean coding that suits our needs. You have the right to try this @ home <img src='http://www.tisseur-de-toile.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> <br />
I developped this technique using WordPress 3.1 RC-4 so it will be totally up to date when 3.1 will be out !<br />
Hope this will help you to set up your extranet menus.<br />
To be continued&#8230;</p>
<p>Cheers,<br />
jeFFF</p>
<p><a name="source"></a><br />
<a href="http://www.tisseur-de-toile.fr/wp-content/uploads/2011/02/wordpress-restrict-by-role.zip" target="_blank">DOWNLOAD : WordPress restrict by role script (PHP file, 2Ko)</a><br />
<em>credits &#8211; WordPress tattoo found on Edward T. Morita website  : <a href="http://www.edmorita.com">www.edmorita.com</a></em></p>
<p><strong>[UPDATE] &#8212; Big up for Tejas who modified the source code to use the nav item description to set up the aurthorized roles, his modifications can be found here : <a href="http://pastebin.com/hQnShaxA" target="_blank">http://pastebin.com/hQnShaxA</a></strong></p>
<img src="http://feeds.feedburner.com/~r/TisseurDeToile/~4/TR4B4-mjFOM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tisseur-de-toile.fr/wordpress-tricks/pimp-my-wordpress-menu-part-2-access-granted-to-authorized-personnel-only.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.tisseur-de-toile.fr/wordpress-tricks/pimp-my-wordpress-menu-part-2-access-granted-to-authorized-personnel-only.html</feedburner:origLink></item>
		<item>
		<title>Why blogging in english ?</title>
		<link>http://feedproxy.google.com/~r/TisseurDeToile/~3/fgt6jl0_SOw/why-blogging-in-english.html</link>
		<comments>http://www.tisseur-de-toile.fr/general-information/why-blogging-in-english.html#comments</comments>
		<pubDate>Mon, 24 Jan 2011 21:13:43 +0000</pubDate>
		<dc:creator>jeFFF</dc:creator>
				<category><![CDATA[General information]]></category>

		<guid isPermaLink="false">http://www.tisseur-de-toile.fr/?p=191</guid>
		<description><![CDATA[A lot of people asked me why, as a french guy, I'm blogging in English.<br />
This is some answers...]]></description>
			<content:encoded><![CDATA[<p>I said in <a href="http://www.tisseur-de-toile.fr/">my first post</a> that this is not my first blogging attempt, I used to do it some time ago but as I was too lazy to write it just disappeared from the surface of the Web.<br />
(Well, not entirely as I found <a href="http://web.archive.org/web/20051025223928/jefff73.free.fr/thoughts/index.php" target="_blank">this page</a> in the web.archive database Damn !!!!!) </p>
<p>In this old fashioned blog I used to talk about music, comics, everyday life and a lot of stuff, it was a sort of &#8220;safety valve&#8221; to get rid of boring days at work.<br />
These subjects might came back one day, I&#8217;m already thinking about a comic book section which will open in 2011 ( but I&#8217;m lazy remember ??? <img src='http://www.tisseur-de-toile.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</p>
<p>So, let&#8217;s get back to the main topic, why starting this particular blog in English ?<br />
I guess <a href="http://nemrod.tumblr.com" target="_blank">Nemrod</a> might be the one who helped me thinking about acting this way.<br />
In one discussion I asked himself why he always twitted in English and a part of his answer was that he wanted to be read by a lot of people.<br />
<br />
This answer suited me and as one of my main objectives this year is to take part in the life of the wordpress community, I thought english was the better language to express myself.</p>
<p>This doesn&#8217;t mean that you won&#8217;t see any french around here. I might switch back to it sometimes ( after all it&#8217;s still my mother tongue ! <img src='http://www.tisseur-de-toile.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ) but as I wanted to launch this new blog at the beginning of the year I have no choice to limit myself to one language only.</p>
<p>Stay tuned for many suprises this year !<br />
In the meantime, keep on rockin&#8217;<br />
jeFFF</p>
<img src="http://feeds.feedburner.com/~r/TisseurDeToile/~4/fgt6jl0_SOw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tisseur-de-toile.fr/general-information/why-blogging-in-english.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.tisseur-de-toile.fr/general-information/why-blogging-in-english.html</feedburner:origLink></item>
		<item>
		<title>Fixing the menu : WordPress menu Tricks part 1</title>
		<link>http://feedproxy.google.com/~r/TisseurDeToile/~3/nkix_yl_mPI/fixing-the-menu-wordpress-menu-tricks-part-1.html</link>
		<comments>http://www.tisseur-de-toile.fr/wordpress-tricks/fixing-the-menu-wordpress-menu-tricks-part-1.html#comments</comments>
		<pubDate>Sun, 16 Jan 2011 23:06:10 +0000</pubDate>
		<dc:creator>jeFFF</dc:creator>
				<category><![CDATA[Wordpress tricks]]></category>

		<guid isPermaLink="false">http://www.tisseur-de-toile.fr/?p=140</guid>
		<description><![CDATA[In WP3, unpublishing a page does not make the matching menu item disappear.<br />
The following trick, add a new capability to the menu walker to correct it.<br /><br />
This article is the first, but not least, in the wordpress tricks category.]]></description>
			<content:encoded><![CDATA[<p>The best part with a brand new blog is the ability to add new categories everyday if you like !<br />
So welcome to this brand new &#8220;wordpress tricks&#8221; section where I will put pieces of code which saved me a lot of time.</p>
<p>One of the great feature of WP 3, as far as I&#8217;m concerned, is the new menu option.<br />
As I told in the <a href="http://www.tisseur-de-toile.fr/web-folio/r-i-p-sparkling-bombs.html">RIP Sparkling Bombs post</a>, building a menu with the wp_list_posts or wp_list_pages was really tricky sometimes.<br />
This great feature, based on the <a href="http://www.woothemes.com/2010/02/woonav-integrated-in-wp-30/" target="_blank">WooNav, excellent piece of code</a> can be enhanced very simply.</p>
<p>I will do a little serie about these enhancements starting today with the &#8220;unpublish page&#8221; issue.</p>
<h3><strong><br />
1. Houston what could be the problem ?!?</strong></h3>
<p>As I worked on a personnal project I noticed an annoying thing about the menu.<br />
If you put an item matching a page link and then unpublished this page, the menu still appears in the menu bar and fataly leads to a 404 error.<br />
You can avoid this by deleting this specific menu and recreate it later, but you can&#8217;t do that if you want to keep your settings (like title attribute and menu label).<br />
One other way would be to create a second menu without the item you don&#8217;t want and display this one instead but it could be tricky if you already got plenty of menus and not very clean.</p>
<h3><strong><br />
2. The solution : extending the menu walker !</strong></h3>
<p>Fortunately, all menu items are build with a Walker class.<br />
If you don&#8217;t know what a Walker is, you can find a good definition on <a href="http://bugssite.org/blog/2009/12/08/wordpress-custom-walker-tutorial/" target="_blank">Shane&#8217;s blog</a> :</p>
<blockquote><p>&#8220;A walker class allows you to manipulate how data is displaied on your blog without having to modify the core files. What ever methods you do not override use the default method in the Walker class that you Extend.&#8221;</p></blockquote>
<p>If you look in the nav-menu-template.php library you&#8217;ll see the declaration of the Walker Class Menu (starting line 17)<br />
You can extends it and make a Menu walker  of your own that you can fully customize afterwards :</p>
<p>[php]class myCustom_Walker_Nav_Menu extends Walker_Nav_Menu<br />
{<br />
/* some code here&#8230; */<br />
}[/php]</p>
<p>As you can see in the class definition, the start_el method applies to all the menu items, if you override this method, you can modify the menu item behavior, you can try this as an exemple which will simply add &#8220;my-custom-menu-class&#8221; css  class on each menu item.<br />
You can add this piece of code in your functions.php</p>
<p>[php]<br />
function start_el(&amp;$output, $item, $depth, $args) {<br />
    global $wp_query;<br />
    $indent = ( $depth ) ? str_repeat( &quot;\t&quot;, $depth ) : &#8221;;</p>
<p>    $class_names = $value = &#8221;;<br />
    $classes = empty( $item-&gt;classes ) ? array() : (array) $item-&gt;classes;<br />
    $classes[] = &#8216;menu-item-&#8217; . $item-&gt;ID;<br />
    // &#8211;&gt; Add custom Class<br />
    $classes[] = &#8216;my-custom-menu-class&#8217;;</p>
<p>    $class_names = join( &#8216; &#8216;, apply_filters( &#8216;nav_menu_css_class&#8217;, array_filter( $classes ), $item ) );<br />
    $class_names = &#8221;;</p>
<p>    $id = apply_filters( &#8216;nav_menu_item_id&#8217;, &#8216;menu-item-&#8217;. $item-&gt;ID, $item, $args );<br />
    $id = strlen( $id ) ? &#8216; id=&quot;&#8217; . esc_attr( $id ) . &#8216;&quot;&#8217; : &#8221;;</p>
<p>    $output .= $indent . &#8216;&lt;li&#8217; . $id . $value . $class_names .&#8217;&gt;&#8217;;</p>
<p>    $attributes  = ! empty( $item-&gt;attr_title ) ? &#8216; title=&quot;&#8217;  . esc_attr( $item-&gt;attr_title ) .&#8217;&quot;&#8217; : &#8221;;<br />
    $attributes .= ! empty( $item-&gt;target )     ? &#8216; target=&quot;&#8217; . esc_attr( $item-&gt;target     ) .&#8217;&quot;&#8217; : &#8221;;<br />
    $attributes .= ! empty( $item-&gt;xfn )        ? &#8216; rel=&quot;&#8217;    . esc_attr( $item-&gt;xfn        ) .&#8217;&quot;&#8217; : &#8221;;<br />
    $attributes .= ! empty( $item-&gt;url )        ? &#8216; href=&quot;&#8217;   . esc_attr( $item-&gt;url        ) .&#8217;&quot;&#8217; : &#8221;;</p>
<p>    $item_output = $args-&gt;before;<br />
    $item_output .= &#8216;&lt;a&#8217;. $attributes .&#8217;&gt;&#8217;;<br />
    $item_output .= $args-&gt;link_before . apply_filters( &#8216;the_title&#8217;, $item-&gt;title, $item-&gt;ID ) . $args-&gt;link_after;<br />
    $item_output .= &#8216;&lt;/a&gt;&#8217;;<br />
    $item_output .= $args-&gt;after;</p>
<p>    $output .= apply_filters( &#8216;walker_nav_menu_start_el&#8217;, $item_output, $item, $depth, $args );<br />
}</p>
<p>[/php]</p>
<h3>3. Make it works !</h3>
<p>Now that we declared the new walker, the next step is to enable our menu to use it.<br />
In your function.php just create an instance of your new class by adding this line :</p>
<p>[php]$myCustom_menu_walker = new myCustom_Walker_Nav_Menu();[/php]</p>
<p>The last thing to do is to configure the menu function to use this new object.<br />
If you look in the twentyten theme&#8217;s header.php you&#8217;ll find the menu builder function call around line 85 (wp_nav_menu).<br />
One argument of this function is &#8216;walker&#8217; where you can specify the object you want to use.<br />
Modify the line to look like this :</p>
<p>[php]&lt;?php wp_nav_menu( array( &#8216;container_class&#8217; =&gt; &#8216;menu-header&#8217;, &#8216;theme_location&#8217; =&gt; &#8216;primary&#8217;, &#8216;walker&#8217; =&gt; $myCustom_menu_walker ) ); ?&gt;[/php]</p>
<p>If you now reload your page, you&#8217;ll see that all the menu items have your new CSS class &#8216;my-custom-menu-class&#8217;</p>
<h3>4. get rid of the unpublished page&#8230; finally !!!!!!</h3>
<p>To get rid of the page, you&#8217;ll have to execute this code before creating the HTML output :</p>
<p>[php]$item_to_display = true;<br />
$item_data = get_post($item-&gt;object_id);</p>
<p>if ( !empty($item_data) &amp;&amp; ($item-&gt;object == &quot;page&quot;) )<br />
{<br />
    $item_to_display = ( $item_data-&gt;post_status == &quot;publish&quot; ) ? true : false;<br />
    $item_output = &quot;&quot;;<br />
}[/php]</p>
<p>What we do here is to declare a new flag set on true to display the item (line 1).<br />
Each menu element is linked to an object, with the magic of the wp_post table which contains all wp elements we can gather all the element data using the get_post function and passing the item object ID variable (which store the ID of the item linked line 2)<br />
If I have a positive response and the object is a page (line 4) then I look at the page status and act one the flag to display it or not (line 6).<br />
<em>Note : I set an empty item_output string to avoid a PHP Notice that you can see only in debug mode but your code is better if you can avoid them (line 7).</em></p>
<p><em> </em>The last thing to do is to put a new condition just before the final HTML render :</p>
<p>[php]if ( $item_to_display )<br />
{<br />
$item_output = $args-&gt;before;<br />
$item_output .= &#8221;;<br />
$item_output .= $args-&gt;link_before . apply_filters( &#8216;the_title&#8217;, $item-&gt;title, $item-&gt;ID ) . $args-&gt;link_after;<br />
$item_output .= &#8221;;<br />
$item_output .= $args-&gt;after;<br />
}[/php]</p>
<p>DONE !</p>
<p>So this is it, we set up a new Walker and modify the menu behavior with this little trick.<br />
As it is my first tutorial, it would be great to have your feelings about it in terms of content, interest and clarity.<br />
As you probably noticed, english is not my mother tongue <img src='http://www.tisseur-de-toile.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
You&#8217;ll find below the fully commented source code to download.</p>
<p>Hope this might ve useful to you,<br />
have fun with WP !<br />
Cheers,<br />
jeFFF</p>
<p><a href='http://www.tisseur-de-toile.fr/wordpress-tricks/fixing-the-menu-wordpress-menu-tricks-part-1.html/attachment/fixing-the-menu-1' rel='attachment wp-att-180'>DOWNLOAD : fixing-the-menu-1</a><br />
<em>credits &#8211; picture of WordPress Converse © <a href="http://www.realgeek.com/" target="_blank">realgeek.com</a></em></p>
<img src="http://feeds.feedburner.com/~r/TisseurDeToile/~4/nkix_yl_mPI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tisseur-de-toile.fr/wordpress-tricks/fixing-the-menu-wordpress-menu-tricks-part-1.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.tisseur-de-toile.fr/wordpress-tricks/fixing-the-menu-wordpress-menu-tricks-part-1.html</feedburner:origLink></item>
		<item>
		<title>R.I.P Sparkling Bombs ! [updated]</title>
		<link>http://feedproxy.google.com/~r/TisseurDeToile/~3/S9ZapHSjm0A/r-i-p-sparkling-bombs.html</link>
		<comments>http://www.tisseur-de-toile.fr/web-folio/r-i-p-sparkling-bombs.html#comments</comments>
		<pubDate>Mon, 10 Jan 2011 22:19:09 +0000</pubDate>
		<dc:creator>jeFFF</dc:creator>
				<category><![CDATA[Web Folio]]></category>

		<guid isPermaLink="false">http://www.tisseur-de-toile.fr/?p=110</guid>
		<description><![CDATA[Last November, the Sparkling Bombs gave their last show in <a href="http://maps.google.com/maps?f=q&#038;source=s_q&#038;hl=en&#038;geocode=&#038;q=le+tigre+sélestat&#038;sll=37.0625,-95.677068&#038;sspn=63.728771,112.939453&#038;ie=UTF8&#038;hq=le+tigre&#038;hnear=Sélestat,+Bas-Rhin,+Alsace,+France&#038;ll=48.259327,7.456455&#038;spn=0.0134,0.027573&#038;z=16&#038;iwloc=A" target="_blank">Le Tigre in Sélestat</a>, the first place they played.<br />
I was their WebMaster since the beginning of the band, that was ten years ago...]]></description>
			<content:encoded><![CDATA[<p>What a strange way to start a new section on my blog, Web Folio aims to present some significant works I did as a Web Developer.</p>
<p>When <a title="The Joker, guitar player ins the sparkling bombs, web page..." href="http://www.sparklingbombs.com/sb2005/?cat=3" target="_blank">the Joker</a>, guitar player in the band, asked me if i was interested, I couldn&#8217;t refuse that offer.<br /> It was a great opportunity for me to leave the web marketing jobs and do something refreshing (you really need it sometimes !)<br /> I had &#8220;carte blanche&#8221; for all the coding and graphics.</p>
<p>As I look back at my wordpress development, <a title="Visit the Sparkling Bombs' website" href="http://www.sparklingbombs.com" target="_blank">the Sparkling Bombs&#8217; website</a> is one the first WP I hacked so hard to make things work together.<br /> Try to imagine working without the menu options, <a title="Wordpress tour dates manager plugins" href="http://wordpress.org/extend/plugins/search.php?q=tour+dates" target="_blank">manage tour dates</a> without a plugin and manage a huge amount of photos without <a title="Nextgen gallery, one of the best way to manage huge amount of pictures in worpress" href="http://wordpress.org/extend/plugins/nextgen-gallery/" target="_blank">nextgen gallery </a>!<br /> To understand that, you have to know that the last line of code is already 6 years old and the WP core is still the 1.5.2 version ( half way from now ! <img src='http://www.tisseur-de-toile.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</p>
<p>Like I said on the frontpage, the band split up after their last show last november and I couldn&#8217;t make it to seethem a last time.<br /> Although I received a really cool message from the band who thanked me for my work.<br /> Maybe I will have the chance to tell them directly, but guys if you read this, It&#8217;s been a great pleasure to work for you !</p>
<p>See ya around and keep on rockin&#8217;</p>
<p>jeFFF</p>
<p>[UPDATE] As I don&#8217;t know if the web site will be up in a few months, enjoy these screenshots :</p>
<style>#slidercbc55aee92 { width:543px; height:448px; }</style><div id="wrapper-nivo">    <div id="slider-wrapper" class="wrapper">        <div id="slidercbc55aee92" class="nivoSlider"><img width="543" height="448" src="http://www.tisseur-de-toile.fr/wp-content/uploads/2011/01/slide-1-543x448.jpg" class="attachment-medium" alt="Homepage with the &quot;Bomb Girl&quot;" title="Homepage with the &quot;Bomb Girl&quot;" /><img width="543" height="448" src="http://www.tisseur-de-toile.fr/wp-content/uploads/2011/01/slide-2-543x448.jpg" class="attachment-medium" alt="The Joker personal page" title="The Joker personal page" /><img width="543" height="448" src="http://www.tisseur-de-toile.fr/wp-content/uploads/2011/01/slide-3-543x448.jpg" class="attachment-medium" alt="The drum boy !" title="The drum boy !" /><img width="543" height="448" src="http://www.tisseur-de-toile.fr/wp-content/uploads/2011/01/slide-4-543x448.jpg" class="attachment-medium" alt="Her guitar playing will kick your ass ;)" title="Her guitar playing will kick your ass ;)" /><img width="543" height="448" src="http://www.tisseur-de-toile.fr/wp-content/uploads/2011/01/slide-5-543x448.jpg" class="attachment-medium" alt="Rickenbacker powah !" title="Rickenbacker powah !" />     </div> <!-----.nivoSlider end----->   </div> <!-----#slider-wrapper end-----></div> <!-----#wrapper end-----><script type="text/javascript"> jQuery(window).load(function() { jQuery('#slidercbc55aee92').nivoSlider( {controlNav: false, directionNav:false} ); });</script>
<img src="http://feeds.feedburner.com/~r/TisseurDeToile/~4/S9ZapHSjm0A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tisseur-de-toile.fr/web-folio/r-i-p-sparkling-bombs.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.tisseur-de-toile.fr/web-folio/r-i-p-sparkling-bombs.html</feedburner:origLink></item>
		<item>
		<title>Happy new What ??!</title>
		<link>http://feedproxy.google.com/~r/TisseurDeToile/~3/8HIa-T3mSD4/happy-new-what-2.html</link>
		<comments>http://www.tisseur-de-toile.fr/general-information/happy-new-what-2.html#comments</comments>
		<pubDate>Fri, 07 Jan 2011 12:54:30 +0000</pubDate>
		<dc:creator>jeFFF</dc:creator>
				<category><![CDATA[General information]]></category>

		<guid isPermaLink="false">http://www.tisseur-de-toile.fr/?p=104</guid>
		<description><![CDATA[Well, it's already January the 7th, guess it's time to wish you all (??!) my best wishes for this new year coming...]]></description>
			<content:encoded><![CDATA[<p>Actually, I was just about to post something about the loss of my Hardrive and tell a sad story about the end of 2010&#8230; but this damn piece of Hardware started to work again !<br />
I feel lucky as it contained all my web works and all my music at the same time ! ( The 2 most important things in life after my kids I guess <img src='http://www.tisseur-de-toile.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</p>
<p>Well, 2010 is finally over ! AT LAST !!!!<br />
There is only one year remaining before <a href="http://www.nasa.gov/topics/earth/features/2012.html" target="_blank">the end of the World !</a><br />
HAPPY NEW YEAR !</p>
<p>Stay tune for 2011 and its loads of tutorials, wordpress tricks, web folio here on T2T.fr</p>
<img src="http://feeds.feedburner.com/~r/TisseurDeToile/~4/8HIa-T3mSD4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tisseur-de-toile.fr/general-information/happy-new-what-2.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.tisseur-de-toile.fr/general-information/happy-new-what-2.html</feedburner:origLink></item>
		<item>
		<title>Bloggin’ time again !</title>
		<link>http://feedproxy.google.com/~r/TisseurDeToile/~3/X5gYZiDdQC0/bloggin-time-again.html</link>
		<comments>http://www.tisseur-de-toile.fr/general-information/bloggin-time-again.html#comments</comments>
		<pubDate>Sat, 01 Jan 2011 11:39:27 +0000</pubDate>
		<dc:creator>jeFFF</dc:creator>
				<category><![CDATA[General information]]></category>

		<guid isPermaLink="false">http://www.tisseur-de-toile.fr/?p=24</guid>
		<description><![CDATA[It's really good to be back !<br /><br />
A few years ago, I started to write a blog about a lot of uninteresting stuff... Well, I really don't know if what I will write here might be more interesting, but I will try the best I can to keep it fun anyway.<br />
Hope you will like it (or not)...]]></description>
			<content:encoded><![CDATA[It's really good to be back !<br /><br />
A few years ago, I started to write a blog about a lot of uninteresting stuff... Well, I really don't know if what I will write here might be more interesting, but I will try the best I can to keep it fun anyway.<br />
Hope you will like it (or not)...<img src="http://feeds.feedburner.com/~r/TisseurDeToile/~4/X5gYZiDdQC0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tisseur-de-toile.fr/general-information/bloggin-time-again.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.tisseur-de-toile.fr/general-information/bloggin-time-again.html</feedburner:origLink></item>
	</channel>
</rss>

