WordPress.org

Forums

Widget Logic
Syntax Error with Widget Logic (9 posts)

  1. lombardipublishingjoey
    Member
    Posted 2 years ago #

    Here's the error:

    [Tue May 08 09:07:08 2012] [error] [client 10.183.253.48] PHP Parse error: syntax error, unexpected '{' in /var/www/vhosts/XXX.com/wp-content/plugins/widget-logic/widget_logic.php(270) : eval()'d code on line 1

    Any idea what the issue could be?

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

  2. alanft
    Member
    Plugin Author

    Posted 2 years ago #

    There's something awry with some of your widget logic code where you have a stray or extra '{' bracket.

    export all your widget logic code to a config file for safe keeping and trawl through the widget logic in each widget looking for bad code - or just blank the code and see if that fixes it if it's complicated. then you can restore it from the config file

  3. CatGraphicsWeb
    Member
    Posted 2 years ago #

    Hi, I'm getting the same error and maybe someone can help.
    I'm trying to prevent a default site-wide banner from showing up on specific category archives and single post pages by using this widget logic conditional tag:

    !is_category(array(X,XX) || !is_single() && in_category(array(X,XX))

    I have 2 other widgets that should take it's place, and they do work - as long as the default site-wide banner widget is removed completely.
    Can anyone tell me if my above syntax is wrong?

    Looking at alanft's response, I carefully checked all my sytax for any errant brackets but it looks ok. I'm a PHP newbie, so maybe the above code is wrong?
    Any help appreciated.
    Thanks.

  4. alanft
    Member
    Plugin Author

    Posted 2 years ago #

    You have one more ( than you have ), which is why you are getting a "PHP Parse error: syntax error"

  5. CatGraphicsWeb
    Member
    Posted 2 years ago #

    Thanks alanft for the reply, I must be blind!
    I changed the code to this:
    !is_category(array(3,256)) || !is_single() && in_category(array(3,256))
    I added the missing ) after the first array.
    I think it works! Only reason I'm not yet convinced is because on 2 computers/5 browsers I have tested these pages so many times, both banner ads are showing up on the same page! I'm hoping this is only a browser cache issue on my local machines.
    If it works with additional testing - I'm thrilled with the help! I've been struggling with this all week. You've saved the day.. Thank you so much.

  6. alanft
    Member
    Plugin Author

    Posted 2 years ago #

    Great stuff.

    Based on your description of what you are trying to achieve you might want to try

    !is_category(array(3,256)) || !(is_single() && in_category(array(3,256)))

    and see if that improves things

  7. CatGraphicsWeb
    Member
    Posted 2 years ago #

    I think that may be better! You just added another set of brackets around the is_single statement. I tried it and it still works... I think I'll put it on the live site and then I can really breathe a sign of relief!

  8. CatGraphicsWeb
    Member
    Posted 2 years ago #

    So after some more testing on the 'test' site, I finally bit the bullet and used the code on the 'real' site. But it did NOT work! It showed some wackiness with both banners overlapping each other. Even if my own browsers are showing cached material, viewers might have the same situation. I just don't understand it. The test and real site are identical and in the same root, different folders. I copy/pasted the code from one to the other, so no chance of typos. I so want this !is_category..etc. to work as I might need it later. In the meantime I may have to use my fall-back plan to hard-code the default banner ad HTML into the header.php. "If/when" there's a widget placed in the space with designated conditional tag, it should appear as it's supposed to. Thanks for helping anyway!

  9. Joshi Saveena
    Member
    Posted 2 years ago #

    Hi all,
    I am a newbie here. I was having some wordpress issues for which i tried solving it by deactivating the plugins.I has a wysiwyg plug in with the widget logic already installed on it. So by degault, when i activated the plugins back my wigget logic for every post was gone. Its a whole bunch of posts and i dont know what logic is on which, so thinking if anyone could help me recover those widget logic codes back,, Need help seriouslyyy,,,, please.....

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic