• Resolved OthelloBloke

    (@othellobloke)


    Hey…

    I need to keep using an old plugin that creates an is_child function, and there’s a group of code that’s throwing an error and I’m desperately someone out there can explain it to me and how to fix the error that was referring to the count function on the first line?

    		while( count( $allCats ) != 0 ) {
    			if( in_array( $ofParent, $allCats ) ) { return true; }
    			else { $allCats =  is_child_getParents( $allCats ); }
    		}

    I’d be exceedingly grateful.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator James Huff

    (@macmanx)

    What is the name of the plugin?

    Thread Starter OthelloBloke

    (@othellobloke)

    Ryan’s Useful Options.

    I took an old plugin called is_child and integrated into a plugin that I use on some client sites because I was sick and tired of copying and pasting. Figured I’d make a plugin.

    Dion

    (@diondesigns)

    No guarantees, but you can probably get it to work by changing this line:

    while( count( $allCats ) != 0 ) {

    to this:

    while( !empty($allCats) ) {

    Starting with PHP 7.2, the count() function requires the element to be something that is countable (array, object, etc). Previous versions of PHP allowed pretty much anything…with oftentimes unexpected results.

    Thread Starter OthelloBloke

    (@othellobloke)

    That nailed it. Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Error with an old plugin using count() function’ is closed to new replies.