Skip to content

Instantly share code, notes, and snippets.

@isaumya
Last active April 30, 2024 12:26
Show Gist options
  • Save isaumya/89f48dcd84cb58af1e668bb76ba2c029 to your computer and use it in GitHub Desktop.
Save isaumya/89f48dcd84cb58af1e668bb76ba2c029 to your computer and use it in GitHub Desktop.
Easily Remove WooCommerce Bloated Features like Marketing Hub from WordPress Admin Menu

Remove WooCommerce Bloated Features from WP Admin Menu

Recently WooCommerce has added a lot of improvements to the plugin which we really appriciate but at the same time a lot of bloated features has alos been added to the plugin like Marketing Hub, a completely useless menu taking extra space among the other important menu items. Now if you find Marketing Hub to be useful, you can keep it.

But just in case you are looking for a way to remove these features that you no longer need from your WordPress Admin menus, take a look at the following code snippets. Please note: though I will show you how you can remove the Marketing Hub from your WP Admin menu list completely and make sure WooCommerce doesn't execute codes for that feature you don't need, you can do the same for other WooCommerce features as well like Analytics.

How to remove Marketing Hub for WooCommerce <= v4.2

If you are using WooCommerce <= v4.2, you can simple add this one line of code in your theme's functions.php file or make a simple feature plugin and use that to disable the Marketing Hub feature.

add_filter( 'woocommerce_marketing_menu_items', '__return_empty_array' );

How to remove unnecessary features from WooCommerce >= v4.3

In WooCommerce v4.3, Marketing Hub has become a part of WooCommerce admin core features. So, the filter woocommerce_marketing_menu_items no longer exists in WooCommerce v4.3 and hence the above code won't work. But at the same time as Marketing Hub has become a part of WooCommerce admin core features, you can disable it easily along with other WooCommerce features that you might not need for your website.

Here is the code snippet to remove Marketing Hub from WooCommerce in v4.3+.

// Remove WooCommerce Marketing Hub Menu from the sidebar - for WooCommerce v4.3+
add_filter( 'woocommerce_admin_features', function( $features ) {
	/**
	 * Filter the list of features and get rid of the features not needed.
	 * 
	 * array_values() are being used to ensure that the filtered array returned by array_filter()
	 * does not preserve the keys of initial $features array. As key preservation is a default feature 
	 * of array_filter().
	 */
	return array_values(
		array_filter( $features, function($feature) {
			return $feature !== 'marketing';
		} ) 
	);
} );

Removing more than just Marketing Hub from WooCommerce v4.3+

Also just in case you need if you do var_dump($features) to see the list of WooCommerce Admin features, you will get an array like this:

array(10) { 
  [0]=> string(15) "activity-panels" 
  [1]=> string(9) "analytics" 
  [2]=> string(19) "analytics-dashboard" 
  [3]=> string(32) "analytics-dashboard/customizable" 
  [4]=> string(9) "marketing" 
  [5]=> string(10) "onboarding" 
  [6]=> string(21) "shipping-label-banner" 
  [7]=> string(12) "store-alerts" 
  [8]=> string(5) "wcpay" 
  [9]=> string(10) "homescreen" 
}

So, looking at this, you can easily disable more features along with Marketing Hub. For example if you want to disable Analytics along with ** Marketing Hub**, you can just simply tweak the above code like this:

// Remove WooCommerce Marketing Hub & Analytics Menu from the sidebar - for WooCommerce v4.3+
add_filter( 'woocommerce_admin_features', function( $features ) {
	/**
	 * Filter the list of features and get rid of the features not needed.
	 * 
	 * array_values() are being used to ensure that the filtered array returned by array_filter()
	 * does not preserve the keys of initial $features array. As key preservation is a default feature 
	 * of array_filter().
	 */
	return array_values(
		array_filter( $features, function($feature) {
			return ! in_array( $feature, [ 'marketing', 'analytics', 'analytics-dashboard', 'analytics-dashboard/customizable' ] );
		} ) 
	);
} );

Hope this helps. 🙂

Special Thanks

@boutzamat
Copy link

Leaving this here - in case anyone was looking for the solution to hide Extensions Menu

/* Disable extensions menu WooCommerce */ add_action( 'admin_menu', 'wcbloat_remove_admin_addon_submenu', 999 ); function wcbloat_remove_admin_addon_submenu() { remove_submenu_page( 'woocommerce', 'wc-addons'); }

add_filter( 'woocommerce_allow_marketplace_suggestions', '__return_false', 999 ); //Extension suggestions add_filter( 'woocommerce_helper_suppress_admin_notices', '__return_true' ); //Connect to woocommerce.com

Seems this isnt working anymore. Looks like they go out of their way to advertise now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment