It works, but not as advertised
-
The plugin lists a feature “No tracking for admin users logged-in.” – however, the Analytics tracking code is still displayed even when logged in as an admin (not inside the Admin Panel, but on the normal blog sites).
Looking into the code, I realized that the author tries to accomplish this switch using
is_admin()
. The WordPress Codex clearly states: ” It should not be used as a means to verify whether the current user has permission to view the Dashboard or the administration panel (try current_user_can() instead)” (see https://codex.www.ads-software.com/Function_Reference/is_admin)I solved this by manually adapting the check in the plugin code to
if (!current_user_can( ‘edit_posts’ )) {
add_action(‘wp_head’, ‘NKgoogleanalytics’);
}P.S.: I also have a feature request: It should be possible to select wether you want the code inserted into the head or the end of the page (for speed optimization).
- The topic ‘It works, but not as advertised’ is closed to new replies.