class-api-google.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. class Yoast_Api_Google {
  3. /**
  4. * This class will be loaded when someone calls the API library with the Google analytics module
  5. */
  6. public function __construct() {
  7. spl_autoload_register( array( $this, 'autoload_api_google_files' ) );
  8. }
  9. /**
  10. * Autoload the API Google class
  11. *
  12. * @param string $class_name - The class that should be loaded
  13. */
  14. private function autoload_api_google_files( $class_name ) {
  15. $path = dirname( __FILE__ );
  16. $class_name = strtolower( $class_name );
  17. $oauth_files = array(
  18. // Main requires
  19. 'yoast_google_client' => 'google/Google_Client',
  20. 'yoast_api_google_client' => 'class-api-google-client',
  21. // Requires in classes
  22. 'yoast_google_auth' => 'google/auth/Google_Auth',
  23. 'yoast_google_assertion' => 'google/auth/Google_AssertionCredentials',
  24. 'yoast_google_signer' => 'google/auth/Google_Signer',
  25. 'yoast_google_p12signer' => 'google/auth/Google_P12Signer',
  26. 'yoast_google_authnone' => 'google/auth/Google_AuthNone',
  27. 'yoast_google_oauth2' => 'google/auth/Google_OAuth2',
  28. 'yoast_google_verifier' => 'google/auth/Google_Verifier',
  29. 'yoast_google_loginticket' => 'google/auth/Google_LoginTicket',
  30. 'yoast_google_pemverifier' => 'google/auth/Google_PemVerifier',
  31. 'yoast_google_model' => 'google/service/Google_Model',
  32. 'yoast_google_service' => 'google/service/Google_Service',
  33. 'yoast_google_serviceresource' => 'google/service/Google_ServiceResource',
  34. 'yoast_google_utils' => 'google/service/Google_Utils',
  35. 'yoast_google_batchrequest' => 'google/service/Google_BatchRequest',
  36. 'yoast_google_mediafileupload' => 'google/service/Google_MediaFileUpload',
  37. 'yoast_google_uritemplate' => 'google/external/URITemplateParser',
  38. 'yoast_google_cache' => 'google/cache/Google_Cache',
  39. // Requests
  40. 'yoast_google_cacheparser' => 'google/io/Google_CacheParser',
  41. 'yoast_google_io' => 'google/io/Google_IO',
  42. 'yoast_google_httprequest' => 'google/io/Google_HttpRequest',
  43. 'yoast_google_rest' => 'google/io/Google_REST',
  44. // Wordpress
  45. 'yoast_google_wpio' => 'google/io/Google_WPIO',
  46. 'yoast_google_wpcache' => 'google/cache/Google_WPCache',
  47. );
  48. if ( ! empty( $oauth_files[$class_name] ) ) {
  49. if ( file_exists( $path . '/' . $oauth_files[$class_name] . '.php' ) ) {
  50. require_once( $path . '/' . $oauth_files[$class_name] . '.php' );
  51. }
  52. }
  53. }
  54. }