Add clearer guidance for filter return values - #521
Conversation
Some shunt-using plugins out there return values like `false` to the shunt filter if their conditions aren't met. This used to work, but was never "correct" according to the API contract. We should have had clearer guidance on this sooner, though.
|
@LeoColomb The build succeeded when the lint was failing, and now the build is failing after linter auto-fixes (to text I didn't touch, fwiw). Would appreciate you taking a look when you have a minute! |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
website | a6649af | Commit Preview URL Branch Preview URL |
Aug 18 2026, 07:43 PM |
Co-authored-by: Léo Colombaro <LeoColomb@users.noreply.github.com>
|
Hey, a bit late into the conversation -- thanks @dgw for proposing this documentation improvement I have a suggestion for the shunt code sample: instead of yourls_add_filter('shunt_update_clicks', 'yp_dont_log_conditional');
yourls_add_filter('shunt_log_redirect', 'yp_dont_log_conditional');
function yp_dont_log_conditional($value = yourls_shunt_default()) {
if (yp_dont_log_conditions_match()) {
return true;
}
return $value;
}simply yourls_add_filter('shunt_update_clicks', 'yp_dont_log_conditional');
yourls_add_filter('shunt_log_redirect', 'yp_dont_log_conditional');
function yp_dont_log_conditional( $dont_shunt ) {
if (yp_dont_log_conditions_match()) {
return true;
}
return $dont_shunt;
}Bigger improvement: the function doesn't rely on 1.10.4+ Little improvement: naming the param Thoughts ? |
|
Good point about <1.10.4, and not needing a default value. How about Lemme open another PR with these tweaks as separate commits and we can continue there. |
|
Yes |
Pre-requisites
Change Description
This is my attempt at addressing @ozh's documentation suggestion in YOURLS/dont-log-bots#5 (comment)
I was trying to get it done fairly quickly in between things IRL, so I'm sure there's room for improvement. But the important thing is having an open PR at all, reminding us to address the documentation gap. 🙂