在WooCommerce 4.3.x中禁用(删除)市场营销菜单选项 [英] Disable (remove) the marketing menu option in WooCommerce 4.3.x
问题描述
自WooCommerce 4.3.x
发布以来,先前用于删除与4.1.x
一起使用的市场营销"菜单选项的修补程序不再起作用,我想知道是否有人知道如何为4.3.x
删除它.
Since the release of WooCommerce 4.3.x
, the previous fix for removing the Marketing menu option that worked with 4.1.x
does not work anymore and I'm wondering if anyone knows how to remove it for 4.3.x
.
我尝试了所有这些方法,但均未成功:
I've tried all of these without success:
#1:
add_filter( 'woocommerce_marketing_menu_items', '__return_empty_array' );
#2:
add_action( 'admin_init', 'remove_wc_marketing_menu_item' );
function remove_wc_marketing_menu_item() {
remove_menu_page( 'admin.php?page=wc-admin&path=/marketing' );
}
#3:
add_action( 'admin_init', 'remove_wc_marketing_menu_item' );
function remove_wc_marketing_menu_item() {
remove_menu_page( 'wc-admin&path=/marketing' );
}
#4:
add_filter( 'woocommerce_marketing_menu_items', 'remove_wc_marketing_menu_item' );
function remove_wc_marketing_menu_item( $marketing_pages ) {
return array();
}
它们都不与最新的WP和WC一起使用.我没有安装其他插件,也没有使用自定义的子主题或类似的东西.
None of them work with the latest WP and WC. I have no other plugins installed and I'm not using a customized child theme or anything like that.
欢迎所有想法.
推荐答案
/**
* Overwrites the allowed features array using a local `feature-config.php` file.
*
* @param array $features Array of feature slugs.
*/
public function replace_supported_features( $features ) {
$feature_config = apply_filters( 'woocommerce_admin_get_feature_config', wc_admin_get_feature_config() );
$features = array_keys( array_filter( $feature_config ) );
return $features;
}
您将获得:(在WooCommerce 4.3.1版本中经过测试)
So you get: (Tested in WooCommerce 4.3.1 version)
function filter_woocommerce_admin_get_feature_config( $feature_config ) {
$feature_config['marketing'] = false;
return $feature_config;
}
add_filter( 'woocommerce_admin_get_feature_config', 'filter_woocommerce_admin_get_feature_config', 10, 1 );
来源: https://gist.github.com/isaumya/89f48dcd84cb58af1e668bb76ba2c029 - https://github.com/woocommerce/woocommerce-admin/issues/4716
作为插件提供: https://wordpress.org/plugins/disable -dashboard-for-woocommerce/
这篇关于在WooCommerce 4.3.x中禁用(删除)市场营销菜单选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!