Skip to main content
1 of 2
Zach
  • 1.9k
  • 5
  • 31
  • 53

Append query arg for all links (for administrators only)

In a sticky situation - I'm developing a site on a server that the client has access to as well and what I'd like to do is show WP_DEBUG only for administrators. Referencing Yoast's article on a way around this:

if ( isset($_GET['debug']) && $_GET['debug'] == 'true')
    define('WP_DEBUG', true);

would show WP_DEBUG only for URLs that have ?debug=true attached to them, like http://domain.com/?debug=true

I was thinking that the Debug Bar might hold some of this information in there by default (whether or not WP_DEBUG is turned on), but I was thinkin craziness as I don't believe that is the case.

So, what I was thinking would be useful, would be a check for the current user (having the manage_options capability and then run links through add_query_arg():

function zs_admin_debug() {
    if (!current_user_can('manage_options')) {
        add_query_arg('debug','true');
    }
}

but what I'm unsure about is - is there a hook I can use to effect all links on a site with this? This way, admins always see debug which I thought would be extremely useful. Thanks for any help as always!

Zach
  • 1.9k
  • 5
  • 31
  • 53