Couldn’t find a forum section that specially deals with documentation in general–or did I miss something?
The Codex post for function register_sidebars() has a code example (“Default Usage”) that for a couple of reasons doesn’t work as desired if you just copy/paste it:
you get notices for undefined variables, the ID for multiple sidebars would be the same and the sprint_f-wrapper function seems to be impractical, too (which is actually mentioned in the parameter description underneath – I don’t understand though why it it used then anyway).
I find this rather confusing but failed to come up with a better code example and hence didn’t edit anything. Perhaps someone more skilled can take care of it?
I can only assume that it is your implementation of this example that has caused the issues you mention. I’m not sure why you would get warnings about undefined variables and there were will no replicated ids due to the use of
%1$sto generate unique ids for every sidebar.
the sprint_f-wrapper function seems to be impractical
On what basis?
I am referring to Parameters where it says under
“name – Sidebar name. (Note: If copying from default usage above, remove sprintf( ) wrapper function.) “
Also, I don’t mean the ID being set by parameter ‘before_widget’ but the ‘id’ => “sidebar-$i”, which in fact doesn’t use %1$s
And the notice for undefined variable comes from usage of a variable $i that isn’t declared anywhere before and just seems to appear out of the blue (which I find confusing for a documentation).
the notice for undefined variable comes from usage of a variable $i that isn’t declared anywhere
It’s declared in WordPress core. I’ve used this in dozens of themes without the slightest problem.
I did thoroughly re-examine the example you mentioned but, personally, I cannot find any reason to change it. Even the sprint_f may be necessary if you are creating a translation-ready theme that uses a textdoamin.
I did thoroughly re-examine the example you mentioned…
That I have no doubt about and I appreciate your kind attention on the matter.
… , personally, I cannot find any reason to change it.
Then let’s just mark this topic as resolved.
Even the sprint_f may be necessary if you are creating a translation-ready theme that uses a textdoamin.
That isn’t mentioned anywhere and introducing a code example just to mention you should remove it in the next line doesn’t seem to be very helpful in a documentation.
Anyhow, I don’t want to argue and if you say it has worked since ages I’ll just believe, say ‘thank you’ and we leave everything as is. Sorry for the additional work I caused. Won’t happen again.
Hey – no problem! It’s always valid to re-examine default code examples and ensure that the Codex documentation is correct & kept up to date. Since anyone can login to the Codex and change pages (documentation has always been community project), errors can – and often do – creep in. So sanity checks are always a Good Idea(tm). 🙂
- The topic ‘Codex: register_sidebars()’ is closed to new replies.