Exemplo n.º 1
0
 /**
  * Filter the content (which may be empty).
  */
 public function printControlHtml()
 {
     /* are we saving? */
     if ($this->_httpRequestParams->hasParam(self::WIDGET_SUBMIT_TAG)) {
         $this->_wpFunctions->check_admin_referer('tubepress-widget-nonce-save', 'tubepress-widget-nonce');
         $this->_persistence->queueForSave(tubepress_wordpress_api_Constants::OPTION_WIDGET_SHORTCODE, $this->_httpRequestParams->getParamValue('tubepress-widget-tagstring'));
         $this->_persistence->queueForSave(tubepress_wordpress_api_Constants::OPTION_WIDGET_TITLE, $this->_httpRequestParams->getParamValue('tubepress-widget-title'));
         $this->_persistence->flushSaveQueue();
     }
     $templateVars = array(self::WIDGET_TITLE => $this->_persistence->fetch(tubepress_wordpress_api_Constants::OPTION_WIDGET_TITLE), self::WIDGET_CONTROL_TITLE => $this->_translator->trans('Title'), self::WIDGET_CONTROL_SHORTCODE => $this->_translator->trans(sprintf('TubePress shortcode for the widget. See the <a href="%s" target="_blank">documentation</a>.', "http://docs.tubepress.com/")), self::WIDGET_SHORTCODE => $this->_persistence->fetch(tubepress_wordpress_api_Constants::OPTION_WIDGET_SHORTCODE), self::WIDGET_SUBMIT_TAG => self::WIDGET_SUBMIT_TAG, self::WIDGET_NONCE_FIELD => $this->_wpFunctions->wp_nonce_field('tubepress-widget-nonce-save', 'tubepress-widget-nonce', true, false));
     echo $this->_templating->renderTemplate('wordpress/single-widget-controls', $templateVars);
 }
Exemplo n.º 2
0
 public function saveToken(tubepress_spi_http_oauth2_Oauth2ProviderInterface $provider, $slug, tubepress_api_http_oauth_v2_TokenInterface $token)
 {
     $tokens = $this->_context->get(tubepress_api_options_Names::OAUTH2_TOKENS);
     $decoded = json_decode($tokens, true);
     $providerName = $provider->getName();
     if (!isset($decoded[$providerName])) {
         $decoded[$providerName] = array();
     }
     $providerTokens = $decoded[$providerName];
     $toSave = array(self::$_ACCESS_TOKEN => $token->getAccessToken(), self::$_EXPIRY_UNIX => $token->getEndOfLifeUnixTime(), self::$_EXTRA => $token->getExtraParams());
     if ($token->getRefreshToken()) {
         $toSave[self::$_REFRESH_TOKEN] = $token->getRefreshToken();
     }
     $providerTokens[$slug] = $toSave;
     $decoded[$providerName] = $providerTokens;
     $this->_persistence->queueForSave(tubepress_api_options_Names::OAUTH2_TOKENS, json_encode($decoded));
     $this->_persistence->flushSaveQueue();
 }
Exemplo n.º 3
0
 /**
  * @param string $name  The option name.
  * @param string $value The option value.
  *
  * @return string|null Null if stored successfully, otherwise a string error message.
  */
 protected function sendToStorage($name, $value)
 {
     return $this->_persistence->queueForSave($name, $value);
 }