protected function createGoogleClient($options, $includeoauth = false) { // Another plugin might have already included these files // Unfortunately we just have to hope they have a similar enough version set_include_path(get_include_path() . PATH_SEPARATOR . plugin_dir_path(__FILE__)); // Google PHP Client obtained from https://github.com/google/google-api-php-client // Using modified Google Client to avoid name clashes - rename process: // find . -type f -exec sed -i '' -e 's/Google_/GoogleGAL_/g' {} + if (!class_exists('GoogleGAL_Client')) { require_once 'Google/Client.php'; } $client = new GoogleGAL_Client(); $client->setApplicationName("Wordpress Site"); $client->setClientId($options['ga_clientid']); $client->setClientSecret($options['ga_clientsecret']); $client->setRedirectUri($this->get_login_url()); $scopes = array_unique(apply_filters('gal_gather_scopes', $this->get_default_scopes())); $client->setScopes($scopes); $client->setApprovalPrompt($options['ga_force_permissions'] ? 'force' : 'auto'); $oauthservice = null; if ($includeoauth) { if (!class_exists('GoogleGAL_Service_Oauth2')) { require_once 'Google/Service/Oauth2.php'; } $oauthservice = new GoogleGAL_Service_Oauth2($client); } return array($client, $oauthservice); }