Support » Plugins and Hacks » Widget Logic » [Resolved] Warning: in_array() [function.in-array]: Wrong datatype for second argument

[Resolved] Warning: in_array() [function.in-array]: Wrong datatype for second argument

  • Just upgraded WordPress to 3.5 and now receiving the following warning on my site:

    Warning: in_array() [function.in-array]: Wrong datatype for second argument ... /public_html/wp-content/plugins/widget-logic/widget_logic.php(270) : eval()'d code on line 1

    Will a fix/update to the plugin be coming soon to resolve the error? Or is there something I can do on this end?


Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author alanft


    the error suggests the problem is in one of the bits of widget logic in one of your widgets. (line 270 is the bit that executes your given WL code)

    But you could try the DEV version which I have updated to work with 3.5

    Plugin Author alanft


    never mind, I’ve committed 0.54 now. but you still may need to comb through your WL

    Thanks for your quick reply alanft. I upgraded to 0.55 and still had the error, so I went through my WL and I think it was having trouble with the way I was trying to get ancestors of a page:
    global $post; return ( is_page('community') || $post->post_parent == '15' || in_array( 15, get_post_ancestors($post)) );
    I changed it to a is_tree function found here http://wordpress.org/support/topic/is_tree-function but that created a different error:
    ‘Warning: Invalid argument supplied for foreach() in …/wp-content/themes/rutland-theme/functions.php on line 26’
    which is
    ‘foreach($anc as $ancestor) {‘
    Do you know the best WL to show a widget on children and grandchildren of a specific page ID?

    Plugin Author alanft


    there’s another thread with someone having trouble with get_post_ancestors – I’ll have a look at that to see if there’s some substantial change in WP3.5

    hard to say what’s up with your is_tree function (as that page doesn’t have any code with foreach in it)

    i will take a look at get_post_ancestors

    Plugin Author alanft


    Yep, looking at 3.4 v 3.5, get_post_ancestors was re-written and now can return FALSE, so any

    in_array(n, get_post_ancestors($post))

    conditionals have to be written with a bit more caution testing $post first, something like

    ($post) && in_array(n, get_post_ancestors($post))

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Warning: in_array() [function.in-array]: Wrong datatype for second argument’ is closed to new replies.