/** * Get the Social Share Tokens from the API * @return void */ function ppp_set_social_tokens() { if (defined('PPP_TW_CONSUMER_KEY') && defined('PPP_TW_CONSUMER_SECRET') || defined('LINKEDIN_KEY') && defined('LINKEDIN_SECRET') || defined('bitly_clientid') && defined('bitly_secret') || defined('PPP_FB_APP_ID') && defined('PPP_FB_APP_SECRET')) { return; } $social_tokens = ppp_has_local_tokens(); if (false === $social_tokens) { define('PPP_LOCAL_TOKENS', false); $social_tokens = get_transient('ppp_social_tokens'); if (!$social_tokens) { $license = trim(get_option('_ppp_license_key')); $url = PPP_STORE_URL . '/?ppp-get-tokens&ppp-license-key=' . $license . '&ver=' . md5(time() . $license); $response = wp_remote_get($url, array('timeout' => 15, 'sslverify' => false)); if (is_wp_error($response)) { return false; } $social_tokens = json_decode(wp_remote_retrieve_body($response)); } } else { define('PPP_LOCAL_TOKENS', true); delete_transient('ppp_social_tokens'); if (isset($social_tokens->options)) { foreach ($social_tokens->options as $constant => $value) { $constant = strtoupper($constant); if (defined($constant)) { continue; } switch ($constant) { case 'NO_AUTO_UPDATE': // Avoid the call to the API to check for software updates $value = is_bool($value) ? $value : false; define('NO_AUTO_UPDATE', $value); break; } } } } if (false === PPP_LOCAL_TOKENS && !isset($social_tokens->error) && (isset($social_tokens->twitter) || isset($social_tokens->facebook) || isset($social_tokens->linkedin))) { set_transient('ppp_social_tokens', $social_tokens, WEEK_IN_SECONDS); } do_action('ppp_set_social_token_constants', $social_tokens); }
public function test_has_local_tokens() { $this->assertFalse(ppp_has_local_tokens()); }