如何禁用WooCommerce 4.0+新增的仪表盘和分析页面

正如《WooCommerce 4.0引入新的管理界面和安装向导》所介绍的一样,WooCommerce 4.0 在后台新增了仪表盘(Dashboard)和分析( Analytics )页面,具体如下图所示:

如果要完全禁用WooCommerce仪表盘和分析页面,可以使用woocommerce_admin_disabled过滤钩子来完成。如果您将其放在主题的functions.php文件中,则下面的代码将无法正常工作。您必须创建一个插件,然后通过“插件”->“已安装的插件”将其激活。

<?php
/**
 * Plugin Name: Disable Dashboard for WooCommerce
 * Description: Disables new WooCommerce Dashboard introduced in WooCommerce 4.0. Simply activate the plugin and disable Analytics section. No configuration needed.
 * Version: 1.0
 * Author: ospiotr
 * Developer: ospiotr
 * Text Domain: disable-dashboard-for-woocommerce
 * Domain Path: /languages
 * Requires at least: 4.5
 * Tested up to: 5.4
 * Requires PHP: 5.6
 * WC requires at least: 4.0
 * WC tested up to: 4.0
 * License: GNU General Public License v3.0
 * License URI: http://www.gnu.org/licenses/gpl-3.0.html
 */
 
if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}
 /**
 * Check if WooCommerce is active
 **/
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
    add_filter( 'woocommerce_admin_disabled', '__return_true' );
}

以上代码来自 Disable Dashboard for WooCommerce 插件,你可以直接下载 Disable Dashboard for WooCommerce 插件启用即可: https://wordpress.org/plugins/disable-dashboard-for-woocommerce/

来源:

https://www.wpdaxue.com/disable-dashboard-for-woocommerce.html

微信公众号
手机浏览(小程序)
0
分享到:
没有账号? 忘记密码?