[Plugin: Widget Logic] Can’t have ‘return’ in function name
-
I was trying to use Widget Logic with a custom function of my own, and ran into a problem. I made a function called
is_return_visitor()
to tell me if the current visitor was either a logged-in user or someone who had previously left a comment on my site.Widget Logic threw a parse error.
The reason is because of the way it handles the option to say
return(foo)
. If you see the string ‘return’ anywhere in the Widget Logic condition, you try to parse the code directly, instead of wrapping it in your own ‘return’ statement. So, because my function was named ‘is_return_visitor’, Widget Logic thought I was using my own return statement.You might consider changing the simple string comparison to a regex, to more accurately detect that.
In the meantime, I just renamed my function to
is_repeat_visitor()
.
- The topic ‘[Plugin: Widget Logic] Can’t have ‘return’ in function name’ is closed to new replies.