/** * Checks if the Disconnect button is pressed and if so deletes the credentials from the options. * * @since 2.4.5 */ public function replyToValidatePage($aInput, $aOldInput, $oFactory, $aSubmitInformation) { if ('disconnect_from_twitter' !== $aSubmitInformation['field_id']) { return $aInput; } $_oOption = $GLOBALS['oFetchTweets_Option']; // If the Disconnect button is pressed. $aInput = is_array($aInput) ? $aInput : array(); // the transient needs to be removed FetchTweets_WPUtilities::deleteTransient(FetchTweets_Commons::TransientPrefix . '_' . md5(serialize(array($_oOption->getConsumerKey(), $_oOption->getConsumerSecret(), $_oOption->getAccessToken(), $_oOption->getAccessTokenSecret())))); FetchTweets_WPUtilities::deleteTransient(FetchTweets_Commons::TransientPrefix . '_' . md5(serialize(array(FetchTweets_Commons::ConsumerKey, FetchTweets_Commons::ConsumerSecret, $_oOption->getAccessTokenAuto(), $_oOption->getAccessTokenSecretAuto())))); $aInput['authentication_keys'] = array(); $aInput['twitter_connect'] = array(); do_action('fetch_tweets_action_updated_credentials', array()); return $aInput; }
/** * Returns an array of lists received from the previous page; otherwise, fetches lists from the set screen name. * */ protected function _getLists($sScreenName = '', $iAccountID = 0) { // If the cache is set from the previous page, use that. $sListTransient = isset($_GET['list_cache']) ? $_GET['list_cache'] : ''; if (!empty($sListTransient)) { $aLists = FetchTweets_WPUtilities::getTransient($sListTransient, array()); FetchTweets_WPUtilities::deleteTransient($sListTransient); return $aLists; } if (empty($sScreenName)) { return array(); } // Fetch lists from the given screen name. $_oOption =& $GLOBALS['oFetchTweets_Option']; $_aCredentials = $_oOption->getCredentialsByID($iAccountID); $oFetch = new FetchTweets_Fetch($_aCredentials['consumer_key'], $_aCredentials['consumer_secret'], $_aCredentials['access_token'], $_aCredentials['access_secret']); $aLists = $oFetch->getListNamesFromScreenName($sScreenName, $iAccountID); return $aLists; }
/** * Re-saves the cache after adding oEmbed elements. * * @since 1.3.0 */ public function _replyToAddOEmbedElements($sRequestURI) { $strTransientKey = FetchTweets_Commons::TransientPrefix . "_" . md5($sRequestURI); // Check if the transient is locked $strLockTransient = FetchTweets_Commons::TransientPrefix . '_' . md5("LockOEm_" . trim($strTransientKey)); // up to 40 characters, the prefix can be up to 8 characters if (false !== FetchTweets_WPUtilities::getTransient($strLockTransient)) { return; // it means the cache is being modified. } // Set a lock flag transient that indicates the transient is being renewed. FetchTweets_WPUtilities::setTransient($strLockTransient, true, FetchTweets_Utilities::getAllowedMaxExecutionTime()); // Perform oEmbed caching - no API request will be performed $oFetch = new FetchTweets_Fetch(); // structure: array( 'mod' => time(), 'data' => $this->oBase64->encode( $vData ) ), $arrTransient = $oFetch->getTransient($strTransientKey); // If the mandatory keys are not set, it's broken. if (!isset($arrTransient['mod'], $arrTransient['data'])) { FetchTweets_WPUtilities::deleteTransient($strTransientKey); return; } $arrTweets = (array) $this->oBase64->decode($arrTransient['data']); $oFetch->addEmbeddableMediaElements($arrTweets); // the array is passed as reference. // Re-save the cache. // FetchTweets_Debug::logArray( 'saving oembed transient' ); $oFetch->setTransient($sRequestURI, $arrTweets, $arrTransient['mod'], true); // the method handles the encoding. // Delete the lock transient FetchTweets_WPUtilities::deleteTransient($strLockTransient); }