• Resolved silverfernsport

    (@silverfernsport)


    Hey guys, I’ve installed the plugin in a different website and it threw a strange error that I haven’t seen before:

    Warning: Attempt to read property “term_id” on int in?/plugins/wpc-ajax-search/wpc-ajax-search.php?on line?1128

    This is the function inside the plugin that throws the error:

    function nav_menu_items( $items, $args ) {

                        $saved_menus = self::get_setting( ‘menus’, [] );

                        if ( is_array( $saved_menus ) && in_array( $args->menu->term_id, $saved_menus ) ) {

                            $items .= ‘<li class=”menu-item wpcas-menu-item menu-item-type-wpcas”><a href=”#”>’ . self::localization( ‘menu’, esc_html__( ‘Search’, ‘wpc-ajax-search’ ) ) . ‘</a></li>’;

                        }

                        return $items;

                    }

    It seems that the array with the menus is not building property or for some reason it can’t read the ID of my menu, the weird thing is that I have this plugin on another website and it works perfectly.

    Any ideas what this could be or how I can work around it, maybe by hard coding the header menu ID? Thanks!

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter silverfernsport

    (@silverfernsport)

    Hey guys, after some debugging I found out that the object doesn’t contain any property named term_id, so I tried removing the “->term_id” access from the function and now it’s working well! Here’s the modified function:

    $saved_menus = self::get_setting( ‘menus’, [] );

    if ( is_array( $saved_menus ) && in_array( $args->menu, $saved_menus ) ) {

    $items .= ‘<li class=”menu-item wpcas-menu-item menu-item-type-wpcas”><a href=”#”>’ . self::localization( ‘menu’,

            esc_html__( ‘Search’, ‘wpc-ajax-search’ ) ) . ‘</a></li>’;

    }

    return $items;

    }

Viewing 1 replies (of 1 total)
  • The topic ‘Plugin throwing error’ is closed to new replies.