Skip to content

Commit 11a1685

Browse files
manchumaharatareq1988
authored andcommitted
Active tab highlight override from url hash (#81)
* Create class.settings-api.php if url has section id as hash then set it as active or override the current local storage value Here is an exmaple from a practical plugin integration wp-admin/options-general.php?page=cbxuseronline#cbxuseronline_dash_widget where #cbxuseronline_dash_widget is id of a section. * Update class.settings-api.php variable named fixed for 'activetab'
1 parent 2f74376 commit 11a1685

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/class.settings-api.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,15 @@ function script() {
566566
if (typeof(localStorage) != 'undefined' ) {
567567
activetab = localStorage.getItem("activetab");
568568
}
569+
570+
//if url has section id as hash then set it as active or override the current local storage value
571+
if(window.location.hash){
572+
activetab = window.location.hash;
573+
if (typeof(localStorage) != 'undefined' ) {
574+
localStorage.setItem("activetab", activetab);
575+
}
576+
}
577+
569578
if (activetab != '' && $(activetab).length ) {
570579
$(activetab).fadeIn();
571580
} else {

0 commit comments

Comments
 (0)