Skip to content

Instantly share code, notes, and snippets.

@ArtfulPussycat
Last active December 9, 2016 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArtfulPussycat/a8a51e70995f827c66062de175956c05 to your computer and use it in GitHub Desktop.
Save ArtfulPussycat/a8a51e70995f827c66062de175956c05 to your computer and use it in GitHub Desktop.
Hide Jetpack and disable direct access
function ap_remove_jetpack_page( ) {
if ( class_exists( 'Jetpack' ) && !current_user_can( 'manage_options' ) ) {
remove_menu_page( 'jetpack' );
}
}
add_action( 'admin_menu', 'ap_remove_jetpack_page', 999 );
add_action( 'admin_init', 'restrict_page' );
function restrict_page() {
if ( class_exists( 'Jetpack' ) && !current_user_can( 'manage_options' ) ) {
if ( isset( $_GET['page'] ) && $_GET['page'] == 'jetpack' ) {
wp_die( 'no access' );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment