WooCommerce 管理产品 "general data" 邮箱问题

WooCommerce Admin product "general data" postbox issue

我对 woocommerce 产品数据选项有奇怪的问题。我的不是默认打开,而是在打开页面时关闭。

我尝试使用此功能删除“关闭”class,但没有成功。有什么建议吗?

add_filter( "postbox_classes_product_woocommerce-product-data", 'product_postbox_data_open' );
function product_postbox_data_open( $classes ) {
    array_splice( $classes, 'closed' );

  return $classes;
}

更新: 这是一种方法,我解决了我的问题:)

   add_action('admin_footer', 'disable_metabox_folding');
        function disable_metabox_folding()
        { ?><script>
        jQuery(window).load(function() {
           jQuery('.postbox').removeClass('closed');
        });
        </script><?php
    }

您需要从 wp_usermeta 中为您的 user_id 删除以 closedpostboxes_product 作为元键的行,通过 phpMyAdmin…

你也可以这样做 运行 一旦这个功能(通过以管理员身份浏览任何页面):

add_action( 'init', function(){
    if( current_user_can('administrator') ) {
        delete_user_meta( get_current_user_id(), 'closedpostboxes_product' );
    }
});

代码进入活动子主题(或活动主题)的 functions.php 文件。使用后将其删除。