Home › Forums › Feature Requests › Ability to Link to Specific Tabs on Options Page › Reply To: Ability to Link to Specific Tabs on Options Page
Nice approach, jsilver. I’d add a decodeUriComponent() around the hash to make it support all languages, some non English chars would be automatically encoded by the browser.
so, something like this:
//add an ACF tab shortcut link
add_action( "admin_footer", "acf_link_to_tab" );
function acf_link_to_tab(){ ?>
<script>
(function($){
acf.add_action('ready', function(){
if (location.hash.length>1){
let hash = location.hash.substring(1);
let decodedHash = decodeURIComponent(hash);
$('.acf-tab-wrap .acf-tab-button').each(function(i, button){
let target = $(button).text().toLowerCase().replace(' ', '-');
if (decodedHash == target){
$(button).trigger('click');
return false;
}
});
}
});
})(jQuery);
</script><?php
}
If you really want, you can add a try-catch around the decode call.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.