Support Forum

Hook idea…

LH Lee H
Lee H
Member

Edit: Topic should be “Filter idea” not hook. Sorry.

Is is possible, or reasonable to consider adding a second argument to filters that are near the end of a function?

Example: apply_filters(‘sph_ProfileEditButton’, $out) allows you filter, modify or even replace output before it’s returned. I’d like to see apply_filters(‘sph_ProfileEditButton’, $out, $a) so the arguments are exposed for lot’s of reasons. I’m loving we are usings wp_parse_args. And that we can add unlimited extra args because of it. But it’s wasted if we can’t access the  args later. 🙁

10 Answers

New Answer

MP Mr Papa
Mr Papa
Member

it is a hook…  filters and actions make up hooks… wink

I thought we had put the args array in most of those template tags hooks…  I agree they should be there – the one you reference clearly is not…

will trawl through them and add…

LH Lee H
Lee H
Member

If it wasn’t kinda creepy… I’d hug ya. laugh

Thanks!

MP Mr Papa
Mr Papa
Member

cool looked like about 50% had them and 50% did not… that will teach us to follow our own standards! roll

LH Lee H
Lee H
Member

Aaaaaaah….   that move just allowed me to delete a ton of hacky code that allowed me to detect if it was my plugin calling the functions or not.

Much more better!

YS Yellow Swordfish
Yellow Swordfish
Member

I haven’t updated source code yet but have these been added to the filter prior to the echo?

I like the idea of that but we have to remember that at that point the $a contents are not sanitised.

LH Lee H
Lee H
Member

Can’t vouch for each of them, but so far I’m finding them prior to the echo. Will keep in mind about sanitizing. Something to remember to add to the faq, wiki, codex or whatever we are going to use to document.

MP Mr Papa
Mr Papa
Member

yes, they are before the echo..   and yes, users need to sanitize – good point to document…  this is just like the filter on the args themselves…

LH Lee H
Lee H
Member

I am so loving the change!

However I had forgotten how to add_filter for extra arguments. A new pot of coffee is a Godsend.

For the boneheaded like me, this example will handle one argument (most common usage):

add_filter('sph_ExampleFilter', 'myExampleFilterFunction');

This example will handle 2 args. Edit ‘2’ to handle more if filter supports:

add_filter('sph_ExampleFilter', 'myExampleFilterFunction', '', '2');
MP Mr Papa
Mr Papa
Member

add_filter(‘sph_filter’, ‘my_filter_routine’, 10, 2);

this would be for priority 10, the default… you can change…

and for 2 arguments…