Support

Account

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.