Title: Errors when adding search box to menu
Last modified: August 24, 2016

---

# Errors when adding search box to menu

 *  Resolved [rtpHarry](https://wordpress.org/support/users/rtpharry/)
 * (@rtpharry)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/errors-when-adding-search-box-to-menu/)
 * When I click the “Add to menu” button within the Search Box accordion item on
   nav-menus.php I see the following errors:
 *     ```
       Notice: Undefined variable: _object in /srv/www/basetemplate/htdocs/wp-admin/includes/ajax-actions.php on line 1091
   
       Notice: Trying to get property of non-object in /srv/www/basetemplate/htdocs/wp-admin/includes/ajax-actions.php on line 1095
       ```
   
 * Note: I have `define( 'WP_DEBUG', true );` set in my wp-config.php.
 * When I save and look at the site front end I see the search box in the menu and
   it seems to work.
 * [https://wordpress.org/plugins/bop-search-box-item-type-for-nav-menus/](https://wordpress.org/plugins/bop-search-box-item-type-for-nav-menus/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [rtpHarry](https://wordpress.org/support/users/rtpharry/)
 * (@rtpharry)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/errors-when-adding-search-box-to-menu/#post-5965208)
 * Looking at this some more it seems that it is a bug with WP that assumes there
   will only ever be three types of `menu-item-type`, or at least doesn’t check 
   that the $_object exists before it tries to use it.
 *  Plugin Author [joe_bopper](https://wordpress.org/support/users/joe_bopper/)
 * (@joe_bopper)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/errors-when-adding-search-box-to-menu/#post-5965213)
 * Thanks for drawing this to my attention.
 * This is happening due to a bit of rubbishness in the wordpress core code. The
   code doesn’t declare the $_object variable and then proceeds to define $_object
   in a switch statement without a default choice. This leads to the notice you 
   are seeing for strict error reporting.
 * The trouble with this output is that it distracts the ajax call from the desired
   return. If you leave the admin menus page and return, you’ll find it has added
   the search box.
 * I will try to find a workaround resolution to this and post up a new version 
   soon.
 * Cheers.
 *  Thread Starter [rtpHarry](https://wordpress.org/support/users/rtpharry/)
 * (@rtpharry)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/errors-when-adding-search-box-to-menu/#post-5965214)
 * Yeah I agree, I’ve been digging around and it seems like its been a known issue
   for two years:
 * [https://core.trac.wordpress.org/ticket/23805#comment:3](https://core.trac.wordpress.org/ticket/23805#comment:3)
 * There is a one-liner which would fix it but it needs to be done in the core.
 * Unless there is a way to override the ajax call in the admin panel and use your
   own I think you might just have to wait for WP to fix the bug.
 *  Plugin Author [joe_bopper](https://wordpress.org/support/users/joe_bopper/)
 * (@joe_bopper)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/errors-when-adding-search-box-to-menu/#post-5965224)
 * I think I’ve found a solution but am having server connection issues at the moment;
   will have to check tomorrow morning (UK) instead.
 * Basically the fix involves checking if the core php ajax action in [admin-ajax.php on line 72](https://core.trac.wordpress.org/browser/tags/4.1/src/wp-admin/admin-ajax.php)
   and [ajax-actions.php on line 1063](https://core.trac.wordpress.org/browser/tags/4.1/src/wp-admin/includes/ajax-actions.php)
   is registered. Then, if it isn’t registered, add my own action first; else, remove
   the core action, add mine and then re-add the core action. (I think this is the
   best way to not potentially interfere with other plugins).
 * My action then checks if the menu item type is a search box and, if so, process
   some nice code that works before issuing `wp_die()`. Otherwise, do nothing and
   move onto the next hooked action (presumably the core one).
 * Thanks again for letting me know about this and I’ll send an update tomorrow.
 *  Plugin Author [joe_bopper](https://wordpress.org/support/users/joe_bopper/)
 * (@joe_bopper)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/errors-when-adding-search-box-to-menu/#post-5965331)
 * Hi,
 * I’ve updated the plugin now to work around the core function.
 * Cheers.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Errors when adding search box to menu’ is closed to new replies.

 * ![](https://ps.w.org/bop-search-box-item-type-for-nav-menus/assets/icon-128x128.
   png?rev=1067133)
 * [Bop Search Box Item Type For Nav Menus](https://wordpress.org/plugins/bop-search-box-item-type-for-nav-menus/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/bop-search-box-item-type-for-nav-menus/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/bop-search-box-item-type-for-nav-menus/)
 * [Active Topics](https://wordpress.org/support/plugin/bop-search-box-item-type-for-nav-menus/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/bop-search-box-item-type-for-nav-menus/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/bop-search-box-item-type-for-nav-menus/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [joe_bopper](https://wordpress.org/support/users/joe_bopper/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/errors-when-adding-search-box-to-menu/#post-5965331)
 * Status: resolved