Title: Fatal Error Adding Menu&#8230;
Last modified: June 15, 2025

---

# Fatal Error Adding Menu…

 *  Resolved [Matt Pramschufer](https://wordpress.org/support/users/mattpramschufer/)
 * (@mattpramschufer)
 * [9 months, 3 weeks ago](https://wordpress.org/support/topic/fatal-error-adding-menu/)
 * I get this fatal error every couple of days, we use the Stripe plugin by WooCommerce
   as well, so not sure if it is related to that plugin or WC in general. Figured
   I would pass it along.
 * An error of type E_ERROR was caused in line 87 of the file /var/www/domain.com/
   wp-content/plugins/woocommerce/src/Internal/Admin/Settings/PaymentsController.
   php. Error message: Uncaught TypeError: strpos(): Argument #1 ($haystack) must
   be of type string, null given in /var/www/domain.com/wp-content/plugins/woocommerce/
   src/Internal/Admin/Settings/PaymentsController.php:87
   Stack trace: 0 /var/www/
   domain.com/wp-content/plugins/woocommerce/src/Internal/Admin/Settings/PaymentsController.
   php(87): strpos(NULL, ‘Payments’) 1 /var/www/domain.com/wp-includes/class-wp-
   hook.php(324): Automattic\WooCommerce\Internal\Admin\Settings\PaymentsController-
   >add_menu(”) 2 /var/www/domain.com/wp-includes/class-wp-hook.php(348): WP_Hook-
   >apply_filters(NULL, Array) 3 /var/www/domain.com/wp-includes/plugin.php(517):
   WP_Hook->do_action(Array) 4 /var/www/domain.com/wp-admin/includes/menu.php(161):
   do_action(‘admin_menu’, ”) 5 /var/www/domain.com/wp-admin/menu.php(423): require_once(‘/
   var/www/domain…’) 6 /var/www/domain.com/wp-admin/admin.php(159): require(‘/var/
   www/domain…’) 7 /var/www/domain.com/wp-admin/index.php(10): require_once(‘/var/
   www/domain…’) 8 {main}

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

 *  [Mahfuzur Rahman](https://wordpress.org/support/users/mahfuzurwp/)
 * (@mahfuzurwp)
 * [9 months, 3 weeks ago](https://wordpress.org/support/topic/fatal-error-adding-menu/#post-18513231)
 * Hi [@mattpramschufer](https://wordpress.org/support/users/mattpramschufer/) ,
 * Thanks for sharing the error details. The issue occurs because the code is trying
   to use `strpos()` on a value that is `null` instead of a string, which causes
   the fatal error.
 * This might happen if any plugin or custom code is modifying or adding admin menu
   items in a way that results in incomplete or unexpected menu data.
 * To help narrow down the cause, could you please let us know if you have any customizations
   affecting admin menus?
 * Also, since you mentioned using the Stripe plugin, please try temporarily deactivating
   it to see if the error persists without it.
 * This will help us determine whether the issue is related to the Stripe plugin
   or another part of your setup.
 * Looking forward to your update!
 *  Thread Starter [Matt Pramschufer](https://wordpress.org/support/users/mattpramschufer/)
 * (@mattpramschufer)
 * [9 months, 3 weeks ago](https://wordpress.org/support/topic/fatal-error-adding-menu/#post-18516686)
 * Thanks for the reply [@mahfuzurwp](https://wordpress.org/support/users/mahfuzurwp/)
   
   I was able to fix the error by updating the payments controller to properly check
   if $menu_item[0] and $menu_item[2] were actually set, before trying to run strpos
   on it. Figured you might want to pass onto devs.
 * Replaced:
 *     ```wp-block-code
       if ( $this->store_has_providers_with_incentive() ) {	$badge = ' <span class="wcpay-menu-badge awaiting-mod count-1"><span class="plugin-count">1</span></span>';	foreach ( $menu as $index => $menu_item ) {		// Only add the badge markup if not already present and the menu item is the Payments menu item.		if ( 0 === strpos( $menu_item[0], $menu_title )		     && $menu_path === $menu_item[2]		     && false === strpos( $menu_item[0], $badge ) ) {			$menu[ $index ][0] .= $badge; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited			// One menu item with a badge is more than enough.			break;		}	}}
       ```
   
 * With this:
 *     ```wp-block-code
       if ( $this->store_has_providers_with_incentive() ) {	$badge = ' <span class="wcpay-menu-badge awaiting-mod count-1"><span class="plugin-count">1</span></span>';	foreach ( $menu as $index => $menu_item ) {		// Ensure $menu_item[0] is a string before using strpos		if ( isset( $menu_item[0], $menu_item[2] )		     && is_string( $menu_item[0] )		     && 0 === strpos( $menu_item[0], $menu_title )		     && $menu_path === $menu_item[2]		     && false === strpos( $menu_item[0], $badge ) ) {			$menu[ $index ][0] .= $badge; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited			// One menu item with a badge is more than enough.			break;		}	}}
       ```
   
 *  Plugin Support [shahzeen(woo-hc)](https://wordpress.org/support/users/shahzeenfarooq/)
 * (@shahzeenfarooq)
 * [9 months, 3 weeks ago](https://wordpress.org/support/topic/fatal-error-adding-menu/#post-18518003)
 * Hi there!
   Thank you for sharing the code snippet with us. To clarify, this specific
   code is **not part of the WooCommerce core plugin** itself. The code you posted
   appears to be related to displaying a badge in the WordPress admin menu, and 
   the badge class `wcpay-menu-badge` along with references to `store_has_providers_with_incentive()`
   and “Payments menu” indicate it likely belongs to payment plugin you are using.
   In that case, I suggest reaching out to the **payment plugin’s support team**
   and informing them about the issue you’re facing. They’ll be able to investigate
   further and help you resolve it.
 * If you’re using the **WooCommerce Stripe Gateway** plugin, you can create a support
   ticket here:
   👉 https://wordpress.org/support/plugin/woocommerce-gateway-stripe/#
   new-topic-0
 *  Thread Starter [Matt Pramschufer](https://wordpress.org/support/users/mattpramschufer/)
 * (@mattpramschufer)
 * [9 months, 2 weeks ago](https://wordpress.org/support/topic/fatal-error-adding-menu/#post-18521056)
 * [@shahzeenfarooq](https://wordpress.org/support/users/shahzeenfarooq/) technically
   the code IS part of the WooCommerce plugin, as it appears in
 * `/plugins/**woocommerce**/src/Internal/Admin/Settings/PaymentsController.php:
   87`
 * but you are correct this block of code relies on third-party data. That being
   said, the $menu_item variables should still be properly validated so it doesn’t
   throw a fatal error when a third-party incorrectly passes data to it. 🙂 I will
   reach out to the Stripe Gateway folks and let them know. 
   Thanks for the quick
   replies, and I hope you have a great weekend!
 *  Plugin Support [shahzeen(woo-hc)](https://wordpress.org/support/users/shahzeenfarooq/)
 * (@shahzeenfarooq)
 * [9 months, 2 weeks ago](https://wordpress.org/support/topic/fatal-error-adding-menu/#post-18521181)
 * Hi [@mattpramschufer](https://wordpress.org/support/users/mattpramschufer/)
 * Sorry for the confusion. I’ve checked the `PaymentsController.php` file and can
   confirm that the code you shared does exist in the WooCommerce core file.
 * However, it looks like another plugin (or custom code) is adding a top-level 
   menu item with an empty or null title before WooCommerce runs its `add_menu()`
   function. This is likely what’s causing the error.
 * The best approach would be to contact the support team of the plugin you suspect
   is responsible.
   In the meantime, I recommend deactivating all plugins except **
   WooCommerce** and the **Stripe plugin**, and then checking if the issue persists.
   This will help identify if another plugin is interfering.

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

The topic ‘Fatal Error Adding Menu…’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [shahzeen(woo-hc)](https://wordpress.org/support/users/shahzeenfarooq/)
 * Last activity: [9 months, 2 weeks ago](https://wordpress.org/support/topic/fatal-error-adding-menu/#post-18521181)
 * Status: resolved