WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Widget Logic] Can't have 'return' in function name (2 posts)

  1. Dougal Campbell
    Member
    Posted 3 years ago #

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

    http://wordpress.org/extend/plugins/widget-logic/

  2. alanft
    Member
    Posted 3 years ago #

    Sorry about that – I'll try to find some foolproof way to check if the WL contains a proper return.

    the work around is that IF you have the string 'return' in your WL anywhere (as you do in the name of a function) that you have to then add an ACTUAL return and final semi-colon

    eg return is_return_visitor(foo);

Topic Closed

This topic has been closed to new replies.

About this Topic