/lite/includes/google.php

  1. <?php 
  2. function monsterinsights_google_app_config() { 
  3. // We'll go ahead and ask for these permissions on new installs 
  4. $scopes = array(  
  5. 'https://www.googleapis.com/auth/analytics.readonly',  
  6. 'https://www.googleapis.com/auth/analytics',  
  7. // 'https://www.googleapis.com/auth/analytics.manage.users',  
  8. // 'https://www.googleapis.com/auth/tagmanager.readonly',  
  9. // 'https://www.googleapis.com/auth/webmasters.readonly' 
  10. ); 
  11. $config = array( 
  12. 'application_name' => 'Google Analytics by MonsterInsights',  
  13. 'client_id' => '346753076522-21smrc6aq0hq8oij8001s57dfoo8igf5.apps.googleusercontent.com',  
  14. 'client_secret' => '5oWaEGFgp-bSrY6vWBmdPfIF',  
  15. 'redirect_uri' => 'urn:ietf:wg:oauth:2.0:oob',  
  16. 'scopes' => $scopes,  
  17. ); 
  18.  
  19. $config = apply_filters( 'monsterinsights_lite_google_app_config', $config ); 
  20. $config['scopes'] = $scopes; // Scopes requested are not changeable to minimize breakage. 
  21. return $config; 
  22.  
  23. function monsterinsights_create_client() { 
  24. require_once MONSTERINSIGHTS_PLUGIN_DIR . 'assets/lib/google/src/Google/autoload.php'; 
  25. require_once MONSTERINSIGHTS_PLUGIN_DIR . 'assets/lib/google/class-ga-client.php'; 
  26. $config = monsterinsights_google_app_config(); 
  27. $client = new MonsterInsights_GA_Client( $config, 'lite' ); 
  28. return $client; 
  29.  
  30. function monsterinsights_create_test_client() { 
  31. require_once MONSTERINSIGHTS_PLUGIN_DIR . 'assets/lib/google/src/Google/autoload.php'; 
  32. require_once MONSTERINSIGHTS_PLUGIN_DIR . 'assets/lib/google/class-ga-client.php'; 
  33. $config = monsterinsights_google_app_config(); 
  34. $client = new MonsterInsights_GA_Client( $config, 'test_lite' ); 
  35. return $client; 
  36.  
  37. function monsterinsights_set_client_oauth_version() { 
  38. monsterinsights_update_option( 'oauth_version', '1.0' ); 
  39.  
  40. function monsterinsights_get_report_date_range() { 
  41. return array( 
  42. 'start' => date( 'Y-m-d', strtotime( '-1 month' ) ),  
  43. 'end' => date( 'Y-m-d', strtotime( 'yesterday' ) ),  
  44. ); 
.