Created
June 17, 2014 02:45
-
-
Save modemlooper/339460ce07933269536d to your computer and use it in GitHub Desktop.
Limit AppPresser to iPhone and Android browser only
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 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