From 0a8e219c9dcd97b772efcee31a07c9cee91a3a08 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 28 Jun 2016 11:56:45 +0100 Subject: [PATCH] Hide empty panels --- assets/js/admin/meta-boxes-product.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/assets/js/admin/meta-boxes-product.js b/assets/js/admin/meta-boxes-product.js index e02f910ccb8..d990c8b2326 100644 --- a/assets/js/admin/meta-boxes-product.js +++ b/assets/js/admin/meta-boxes-product.js @@ -162,6 +162,23 @@ jQuery( function( $ ) { $( '.hide_if_' + product_type ).hide(); $( 'input#_manage_stock' ).change(); + + // Hide empty panels/tabs after display + $( '.woocommerce_options_panel' ).each( function() { + var $children = $( this ).children( '.options_group' ); + + if ( 0 === $children.length ) { + return; + } + + var $invisble = $children.filter( function() { return 'none' === $( this ).css( 'display' ); } ); + + // Hide panel + if ( $invisble.length === $children.length ) { + var $id = $( this ).prop( 'id' ); + $( '.product_data_tabs' ).find( 'li a[href="#' + $id + '"]' ).parent().hide(); + } + } ); } // Sale price schedule