jetpack_mobile_request_handler

The Jetpack by WordPress.com jetpack mobile request handler function.

Description

jetpack_mobile_request_handler(); 

Usage

  1. if ( !function_exists( 'jetpack_mobile_request_handler' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/minileven/minileven.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = jetpack_mobile_request_handler(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/modules/minileven/minileven.php  
  1. function jetpack_mobile_request_handler() { 
  2. global $wpdb; 
  3. if (isset($_GET['ak_action'])) { 
  4. $url = parse_url( get_bloginfo( 'url' ) ); 
  5. $domain = $url['host']; 
  6. if (!empty($url['path'])) { 
  7. $path = $url['path']; 
  8. else { 
  9. $path = '/'; 
  10. $redirect = false; 
  11. switch ($_GET['ak_action']) { 
  12. case 'reject_mobile': 
  13. setcookie( 
  14. 'akm_mobile' 
  15. , 'false' 
  16. , time() + 300000 
  17. , $path 
  18. , $domain 
  19. ); 
  20. $redirect = true; 
  21.  
  22. /** 
  23. * In Jetpack's Mobile theme, fires after the user taps on the link to display a full version of the site. 
  24. * @module minileven 
  25. * @since 1.8.0 
  26. */ 
  27. do_action( 'mobile_reject_mobile' ); 
  28. break; 
  29. case 'force_mobile': 
  30. case 'accept_mobile': 
  31. setcookie( 
  32. 'akm_mobile' 
  33. , 'true' 
  34. , time() + 300000 
  35. , $path 
  36. , $domain 
  37. ); 
  38. $redirect = true; 
  39.  
  40. /** 
  41. * In Jetpack's Mobile theme, fires after the user taps on the link to go back from full site to mobile site. 
  42. * @module minileven 
  43. * @since 1.8.0 
  44. */ 
  45. do_action( 'mobile_force_mobile' ); 
  46. break; 
  47. if ($redirect) { 
  48. if ( isset( $_GET['redirect_to'] ) && $_GET['redirect_to'] ) { 
  49. $go = urldecode( $_GET['redirect_to'] ); 
  50. } else if (!empty($_SERVER['HTTP_REFERER'])) { 
  51. $go = $_SERVER['HTTP_REFERER']; 
  52. else { 
  53. $go = remove_query_arg( array( 'ak_action' ) ); 
  54. wp_safe_redirect( $go ); 
  55. exit;