Tin*_*ork 2 php wordpress backend woocommerce
使用最新版本的 WooCommerce,有一个“主页”部分,我无法使用任何内置设置删除该部分。
我已设法删除分析和营销选项,但如何删除“主页”选项,并以这种方式使其像以前一样 - 所有订单的概述?
add_filter( 'woocommerce_admin_get_feature_config', 'remove_wc_marketing_menu_option', 10, 1 );
function remove_wc_marketing_menu_option($feature_config){
$feature_config['marketing'] = false;
$feature_config['analytics'] = false;
return $feature_config;
}
Run Code Online (Sandbox Code Playgroud)
您可以使用remove_submenu_page
function action_admin_menu() {
// Contains the URI of the current page.
$current_url = $_SERVER['REQUEST_URI'];
// Make sure wc-admin / customers page will still work
if ( strpos( $current_url, 'customers' ) == false) {
remove_submenu_page( 'woocommerce', 'wc-admin' );
}
}
add_action( 'admin_menu', 'action_admin_menu', 99, 0 );
Run Code Online (Sandbox Code Playgroud)
编辑:同时发布新版本的 WooCommerce 后,访问某些页面时上述答案似乎存在问题,可以使用以下方法解决:
function strposa( string $haystack, array $needles, int $offset = 0 ) : bool {
foreach ( $needles as $needle ) {
if ( strpos( $haystack, $needle, $offset ) !== false ) {
return false; // stop on first true result
}
}
return true;
}
function action_admin_menu() {
// Contains the URI of the current page.
$current_url = $_SERVER['REQUEST_URI'];
// Pages that must remain accessible
$should_still_work = array( 'customers', 'analytics', 'marketing' );
// Make sure some wc-admin pages will still work
if ( strposa( $current_url, $should_still_work ) ) {
remove_submenu_page( 'woocommerce', 'wc-admin' );
}
}
add_action( 'admin_menu', 'action_admin_menu', 99, 0 );
Run Code Online (Sandbox Code Playgroud)
在此更新的答案中使用:Using an array as Neededs in strpos
有关的:
| 归档时间: |
|
| 查看次数: |
760 次 |
| 最近记录: |