Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
plugins-topic
Hook idea...
Avatar
Lee H
Coastal New England (USA)
Member
Free Members
sp_UserOfflineSmall Offline
Sep 4, 2011 - 9:27 am

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. 🙁

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Sep 4, 2011 - 12:00 pm

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...

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Sep 4, 2011 - 12:40 pm

these have been committed...

Avatar
Lee H
Coastal New England (USA)
Member
Free Members
sp_UserOfflineSmall Offline
Sep 4, 2011 - 1:06 pm

If it wasn't kinda creepy... I'd hug ya. [Image Can Not Be Found]

Thanks!

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Sep 4, 2011 - 1:12 pm

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

Avatar
Lee H
Coastal New England (USA)
Member
Free Members
sp_UserOfflineSmall Offline
Sep 4, 2011 - 1:24 pm

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!

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Sep 4, 2011 - 1:36 pm

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.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Lee H
Coastal New England (USA)
Member
Free Members
sp_UserOfflineSmall Offline
Sep 4, 2011 - 1:47 pm

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.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Sep 4, 2011 - 2:06 pm

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...

Avatar
Lee H
Coastal New England (USA)
Member
Free Members
sp_UserOfflineSmall Offline
Sep 4, 2011 - 4:54 pm

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');
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17362
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625