/**
  * Re-saves the cache after adding oEmbed elements.
  * 
  * @since			1.3.0
  */
 public function addOEmbedElements($strTransientKey)
 {
     $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'])) {
         delete_transient($strTransientKey);
         return;
     }
     $arrTweets = (array) $this->oBase64->decode($arrTransient['data']);
     $oFetch->addEmbeddableMediaElements($arrTweets);
     // the array is passed as reference.
     // Re-save the cache.
     $oFetch->setTransient($strTransientKey, $arrTweets, $arrTransient['mod']);
     // the method handles the encoding.
 }
Ejemplo n.º 2
0
 /**
  * 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);
 }