Skip to content

Commit

Permalink
Stats: optimize the Admin Bar hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeymitr committed Oct 21, 2024
1 parent 55c0319 commit 84dd42e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Optimize the Stats Admin Bar hook by narrowing down the callback.
5 changes: 4 additions & 1 deletion projects/plugins/jetpack/modules/stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
function stats_load() {
Jetpack::enable_module_configurable( __FILE__ );

add_action( 'wp_head', 'stats_admin_bar_head', 100 );
// Only run the callback for those who can see the stats.
if ( is_user_logged_in() && current_user_can( 'view_stats' ) ) {
add_action( 'wp_head', 'stats_admin_bar_head', 100 );
}

add_action( 'jetpack_admin_menu', 'stats_admin_menu' );

Expand Down

0 comments on commit 84dd42e

Please sign in to comment.