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); }
/** * {@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; } }
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); }
/** * 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); }
private function _addShortcodeListener() { $keyword = $this->_persistence->fetch(tubepress_api_options_Names::SHORTCODE_KEYWORD); $this->_wpFunctions->add_shortcode($keyword, array($this, 'callback_onShortcode')); }