Last active
December 9, 2016 19:27
-
-
Save ArtfulPussycat/a8a51e70995f827c66062de175956c05 to your computer and use it in GitHub Desktop.
Hide Jetpack and disable direct access
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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