Skip to content

Instantly share code, notes, and snippets.

@modemlooper
Created June 17, 2014 02:45
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 modemlooper/339460ce07933269536d to your computer and use it in GitHub Desktop.
Save modemlooper/339460ce07933269536d to your computer and use it in GitHub Desktop.
Limit AppPresser to iPhone and Android browser only
function apppresser_limit_access_app() {
$agents = $_SERVER['HTTP_USER_AGENT'] ;
$app = false;
$useragents = array (
"iPhone",
"iPod",
"iPad",
"Android"
);
foreach ( $useragents as $useragent ) {
if ( preg_match("/".$useragent."/i", $agents ) ){
$app = true;
}
}
if( !$app && !current_user_can('manage_options') ) {
echo "You need the app!";
exit;
}
}
add_action( 'appp_before', 'apppresser_limit_access_app' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment