我对woocommerce产品数据选项有奇怪的问题。而不是默认打开,我的是关闭在页面打开。
我尝试用这个函数删除“关闭”类,但没有成功。对此有什么建议吗?
add_filter( "postbox_classes_product_woocommerce-product-data", 'product_postbox_data_open' );
function product_postbox_data_open( $classes ) {
array_splice( $classes, 'closed' );
return $classes;
}
您需要通过phpmyadmin从user_id
的wp_usermeta
中删除以closedpostboxes_product
作为元键的行…
您也可以运行一次此功能(通过作为管理员浏览任何页面):
add_action( 'init', function(){
if( current_user_can('administrator') ) {
delete_user_meta( get_current_user_id(), 'closedpostboxes_product' );
}
});
代码放在活动子主题(或活动主题)的functions.php文件中。使用后取下。
更新:这是一种方法,我解决了我的问题:)
add_action('admin_footer', 'disable_metabox_folding');
function disable_metabox_folding()
{ ?><script>
jQuery(window).load(function() {
jQuery('.postbox').removeClass('closed');
});
</script><?php
}