예제 #1
0
 public function onAcceptableValues(tubepress_api_event_EventInterface $event)
 {
     $tokens = $this->_persistence->fetch(tubepress_api_options_Names::OAUTH2_TOKENS);
     $decoded = json_decode($tokens, true);
     $toSet = is_array($decoded) ? array_keys($decoded) : array();
     $event->setSubject($toSet);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function get($optionName)
 {
     if (array_key_exists($optionName, $this->_ephemeralOptions)) {
         return $this->_ephemeralOptions[$optionName];
     }
     try {
         return $this->_persistence->fetch($optionName);
     } catch (InvalidArgumentException $e) {
         if ($this->_optionReference->optionExists($optionName) && !$this->_optionReference->isMeantToBePersisted($optionName)) {
             return null;
         }
         throw $e;
     }
 }
예제 #3
0
 private function _getInfo(tubepress_spi_http_oauth2_Oauth2ProviderInterface $provider, $dataPoint)
 {
     $clients = $this->_persistence->fetch(tubepress_api_options_Names::OAUTH2_CLIENT_DETAILS);
     $decodedClients = json_decode($clients, true);
     $providerName = $provider->getName();
     $path = $providerName . '.' . $dataPoint;
     return $this->_arrayReader->getAsString($decodedClients, $path, null);
 }
예제 #4
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);
 }
예제 #5
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);
 }
예제 #6
0
 private function _addShortcodeListener()
 {
     $keyword = $this->_persistence->fetch(tubepress_api_options_Names::SHORTCODE_KEYWORD);
     $this->_wpFunctions->add_shortcode($keyword, array($this, 'callback_onShortcode'));
 }