Skip to content

Instantly share code, notes, and snippets.

@mikeyarce
Last active March 13, 2020 18:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeyarce/afc88da127c1ea5b81de2043dbc63f63 to your computer and use it in GitHub Desktop.
Save mikeyarce/afc88da127c1ea5b81de2043dbc63f63 to your computer and use it in GitHub Desktop.
Disable and hide Jetpack Stats module
<?php
// Disable the Stats Jetpack Module
add_filter( 'jetpack_active_modules', 'vipgo_override_jp_modules', 99, 9 );
function vipgo_override_jp_modules( $modules ) {
$disabled_modules = array(
'stats',
);
foreach ( $disabled_modules as $module_slug ) {
$found = array_search( $module_slug, $modules, true );
if ( false !== $found ) {
unset( $modules[ $found ] );
}
}
return $modules;
}
// Remove Stats from the list of Jetpack modules
add_filter( 'jetpack_get_available_modules', 'vipgo_jetpack_hide_stats_module' );
function vipgo_jetpack_hide_stats_module( $modules ) {
if( isset( $modules['stats'] ) ) {
unset( $modules['stats'] );
}
return $modules;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment