Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Talk:How to Pass Tag Parameters

This was a larger rewrite than I was planning, so any input, especially if anything is not clear enough, is greatly encouraged. -Kaf 08:12, 15 Jan 2005 (GMT)


I'm a little unclear on your section on defaults.

Not all tags will set defaults in this fashion, so check the documentation for a parameter's default value, and when one is specified use it as your parameter value.

If a parameter has a default value, and that is the value you want to use, you're suggesting passing that value to the function anyway? While it would certainly work, it seems like defaults should be... defaults. Maybe I'm just misinterpreting what you're saying.

Otherwise. Wow, this is a very informative page, and very well presented. Learn something new every day!
--MDAWaffe 08:59, 15 Jan 2005 (GMT)

I see how that can be confusing. Let's see if I can keep my answer simple enough as to swipe some of it for inclusion in the page...
At issue is the way WordPress handles argument defaults, which one finds to be in two distinctly different ways, typically based on a function's design necessities, but I think occasionally on a coder's quirks. In the case of get_archives(), the example I provide uses empty values to force defaults because that's how the function accepts them: it checks for null values in the arguments, and sets values to defaults if the ones you passed are empty. However, try passing '' to the category or limit parameters in get_links(). Not pretty. In such cases you have to treat WordPress like an idiot and inform a function of its defaults. But there's also the issue with 'text-displayed' string parameters, in that passing an empty value sets it to nothing, so one has no choice but to pass the default text value. -Kaf 09:46, 15 Jan 2005 (GMT)
Aha. Now that I have an example, it makes sense to me. For a function like get_archives(), defaults are only applied if no arguments are passed (well, true for category, anyway, I didn't look very far down). Also, since you can't do something like get_links( , , , , , , , , , , ), there's no ideal way to handle displayed strings, as you say (the function asks itself, "am I to put nothing before the link, or am I to put the default? All MDAWaffe gave me to work with was ''." All is clear now. Baby steps to nirvana.
Perhaps you could say something like "for some tags, defaults only apply when no arguments are passed. So, to be on the safe side, if you pass any arguments to a PHP style function, pass all the defaults too."
Thanks! --MDAWaffe 10:07, 15 Jan 2005 (GMT)

type 'callable'

it's not mentioned if its possible to pass something like inline functions as callbacks, i.e. when defining a shortcode

This section is not very clear

I have been reading various Codex sections to clarify some questions I've had. This section is not all that clear in understanding. First: In the section on query-string-style parameters, the use of the word 'wrapper' is not well defined. It can be interpreted in more than one way. An example or some context would greatly improve the understanding of what the author is attempting to communicate. Second: Under the Callback section, the description is, "Some things call for a callback. There's no explanation of what they want, so good luck." Totally inappropriate. Not sure if the author is trying to be funny, or sarcastic, or what; but it certainly doesn't help the new reader who is visiting the page looking for an understanding of what the topic is all about.

I would attempt to edit these two examples, but after reading them, I'm unclear as to whether my understanding is correct or incorrect; and I didn't want to compound already existing problems.

If someone could jump in and writing some explanations, from the perspective that they understand that the information should be presented so that the 'uninformed', who don't know the information, can get a handle on it. Obviously, that's why they came to these Codex pages in the first place.

Thanks