I’ve added a help section using the add_help_tab() function. I’d like to be able to click a link somewhere on the theme/plugin page and have the help panel open at whichever tab I need. Can someone help me out with the required JS for this?
Each tab panel has a unique hash link associated with it so I’d need to use this somehow I’m guessing
/themes.php?page=theme_options#tab-panel-general
1 Answer
Maybe the Q is bordering the off-topic
, but IMO interesting in WordPress context.
I’ve tested this directly in FireBug, in the Dashboard page (wp-admin/index.php
).
var $ =jQuery.noConflict();
// Remove 'active' class from all link tabs
$('li[id^="tab-link-"]').each(function(){
$(this).removeClass('active');
});
// Hide all panels
$('div[id^="tab-panel-"]').each(function(){
$(this).css('display','none');
});
// Set our desired link/panel
$('#tab-link-help-content').addClass('active');
$('#tab-panel-help-content').css('display','block');
// Force click on the Help tab
$('#contextual-help-link').click();