coursepress pro warning message above header

Hi,

When I activated the coursepress pro pllugin, I got this warning message at the top of the page, above the header area:

Warning: in_array() expects parameter 2 to be array, null given in /home1/avirog/public_html/wp-content/themes/generatepress/inc/navigation.php on line 207

The warning repeats eight times.

What does this refer to, and how do I fix it?

I deactivated all the plugins, in order to determine which plugin was causing this, and it was the Coursepress pro plugin.

Wordpress, theme, and wpmu dev are all the latest versions.

I switched to a Wordpress theme, and the site looks vastly different, but I did not get the error message.

Does the warning message indicate a certain part of the theme I was using needs to be modified in some way? I want to keep using the theme I had before.

Thanks for any guidance!

All the best,
Dina

  • Luís

    Hi avi ,

    Hope you're doing well today!

    Seems to be an issue related to your theme. Are you using the debug flag enabled in your wp-config.php? If yes, can you try disable it, changing:

    define( 'WP_DEBUG', true );

    to

    define( 'WP_DEBUG', false);

    https://codex.wordpress.org/Debugging_in_WordPress

    Can be just a simple warning that don't interferes with the well functioning of the website.

    Cheers, Luís

  • avi

    I asked in the support forum for the theme I am using- GeneratePress. YEs, it is something to do with the theme.

    Below is the answer I got over there.

    ////////
    This is the function in GP it’s clashing with:

    add_filter( 'walker_nav_menu_start_el', 'generate_nav_dropdown', 10, 4 );
    function generate_nav_dropdown( $item_output, $item, $depth, $args )
    {
    // If we're working with the primary or secondary theme locations
    if ( 'primary' == $args->theme_location || 'secondary' == $args->theme_location || 'slideout' == $args->theme_location ) {
    // If a dropdown menu is detected
    $dropdown = ( in_array( 'menu-item-has-children', $item->classes ) ) ? true : false;
    if ( $dropdown ) :
    // Add our arrow icon
    $item_output = str_replace( $args->link_after . '', $args->link_after . '<span role="button" class="dropdown-menu-toggle" aria-expanded="false"></span>', $item_output );
    endif;
    }

    // Return the output
    return $item_output;
    }

    Basically, the error is saying
    $item->classes
    isn’t an array, which it is by default in WordPress.

    I wonder if something in the plugin is causing it not to be an array? Worth asking them.

    ////////
    So, I am not sure what that all means, and I am not sure what to do about it. Does it have to do with the wp_debug you mentioned above?

    Any help for resolving this I would appreciate very much!

  • avi

    Hi,

    I didn't want to turn off the debug flag until the code was seen to. Did you take a look at the code from the theme builder? Here it is again as he wrote it to me:

    ////////
    This is the function in GP it’s clashing with:

    add_filter( 'walker_nav_menu_start_el', 'generate_nav_dropdown', 10, 4 );
    function generate_nav_dropdown( $item_output, $item, $depth, $args )
    {
    // If we're working with the primary or secondary theme locations
    if ( 'primary' == $args->theme_location || 'secondary' == $args->theme_location || 'slideout' == $args->theme_location ) {
    // If a dropdown menu is detected
    $dropdown = ( in_array( 'menu-item-has-children', $item->classes ) ) ? true : false;
    if ( $dropdown ) :
    // Add our arrow icon
    $item_output = str_replace( $args->link_after . '', $args->link_after . '<span role="button" class="dropdown-menu-toggle" aria-expanded="false"></span>', $item_output );
    endif;
    }

    // Return the output
    return $item_output;
    }

    Basically, the error is saying
    $item->classes
    isn’t an array, which it is by default in WordPress.

    I wonder if something in the plugin is causing it not to be an array? Worth asking them.

    ////////

    I would prefer to have this fixed instead of just turning off the warning messages.

    Thank you for your help!

  • Luís

    Hi avi ,

    Hope you're doing well today!

    Firstly, sorry for my late reply and all the problems it may have caused.

    Please, try change this line:

    $dropdown = ( in_array( 'menu-item-has-children', $item->classes ) ) ? true : false;

    to

    $dropdown = ( in_array( 'menu-item-has-children', (array)$item->classes ) ) ? true : false;

    I hope this information has been helpful. If I can help you in this or other questions, please let me know!

    Cheers, Luís