/** * @return tubepress_api_url_UrlInterface */ private function _startAdminUrl($pageSlug, tubepress_spi_http_oauth2_Oauth2ProviderInterface $provider) { $asString = $this->_wpFunctions->admin_url('admin.php'); $toReturn = $this->_urlFactory->fromString($asString); $providerName = $provider->getName(); $toReturn->getQuery()->set('page', $pageSlug)->set('provider', $providerName)->set('csrf_token', $this->getCsrfSecret()); return $toReturn; }
public function onAction_wp_head(tubepress_api_event_EventInterface $event) { /* no need to print anything in the head of the admin section */ if ($this->_wpFunctions->is_admin()) { return; } /* this inline JS helps initialize TubePress */ echo $this->_htmlGenerator->getCSS(); echo $this->_htmlGenerator->getJS(); }
/** * Filter the content (which may be empty). */ public function onFilter_row_meta(tubepress_api_event_EventInterface $event) { $links = $event->getSubject(); $args = $event->getArgument('args'); $file = $args[0]; $plugin = $this->_wpFunctions->plugin_basename(basename(TUBEPRESS_ROOT) . '/tubepress.php'); if ($file != $plugin) { return; } $toReturn = array_merge($links, array(sprintf('<a href="options-general.php?page=tubepress.php">%s</a>', $this->_wpFunctions->__('Settings', 'tubepress')), sprintf('<a href="http://support.tubepress.com/">Support</a>'))); $event->setSubject($toReturn); }
/** * {@inheritdoc} */ public function saveAll(array $optionNamesToValues) { foreach ($optionNamesToValues as $optionName => $optionValue) { $this->_wpFunctions->update_option(self::$_optionPrefix . $optionName, $optionValue); } /* * WordPress API is silly. * * http://codex.wordpress.org/Function_Reference/update_option */ return null; }
public function onAction_widgets_init(tubepress_api_event_EventInterface $event) { if (!$event->hasArgument('unit-testing') && !class_exists('tubepress_wordpress_impl_wp_WpWidget')) { require TUBEPRESS_ROOT . '/src/add-ons/wordpress/classes/tubepress/wordpress/impl/wp/WpWidget.php'; } $this->_wpFunctions->register_widget('tubepress_wordpress_impl_wp_WpWidget'); /* * These next three lines are deprecated! */ $widgetOps = array('classname' => 'widget_tubepress', 'description' => $this->_translator->trans('Displays YouTube or Vimeo videos with TubePress. Limited to a single instance per site. Use the other TubePress widget instead!')); //>(translatable)< $this->_wpFunctions->wp_register_sidebar_widget('tubepress', 'TubePress (legacy)', array($this, '__fireWidgetHtmlEvent'), $widgetOps); $this->_wpFunctions->wp_register_widget_control('tubepress', 'TubePress (legacy)', array($this, '__fireWidgetControlEvent')); }
public function __callbackConvertToWpUrlString(tubepress_api_url_UrlInterface $url) { if ($url->isAbsolute()) { return $url->toString(); } if (!isset($this->_urlCache)) { $this->_urlCache = new tubepress_internal_collection_Map(); $this->_urlCache->put('url.base', rtrim($this->_environment->getBaseUrl()->toString(), '/')); $this->_urlCache->put('url.user', rtrim($this->_environment->getUserContentUrl()->toString(), '/')); $this->_urlCache->put('basename', basename(TUBEPRESS_ROOT)); } $urlAsString = $url->toString(); $tubePressBaseUrl = $this->_urlCache->get('url.base'); $userContentUrl = $this->_urlCache->get('url.user'); $baseName = $this->_urlCache->get('basename'); $isSystem = false; if ($this->_stringUtils->startsWith($urlAsString, "{$tubePressBaseUrl}/web/")) { $isSystem = true; } else { if (!$this->_stringUtils->startsWith($urlAsString, "{$userContentUrl}/")) { //this should never happen return $urlAsString; } } if ($isSystem) { $path = str_replace($tubePressBaseUrl, '', $urlAsString); return $this->_wpFunctions->plugins_url($path, "{$baseName}/tubepress.php"); } $path = str_replace($userContentUrl, '', $urlAsString); return $this->_wpFunctions->content_url('tubepress-content' . $path); }
public function onFilter_jetpack_photon_skip_for_url(tubepress_api_event_EventInterface $event) { $args = $event->getArgument('args'); $imageUrl = $args[0]; try { $imageUrl = $this->_urlFactory->fromString($imageUrl); } catch (\InvalidArgumentException $e) { return; } $imageHost = $imageUrl->getHost(); foreach ($this->_domainsToSearch as $domain) { if ($imageHost === "{$domain}" || $this->_stringUtils->endsWith($imageHost, ".{$domain}")) { $event->setSubject(true); return; } } }
private function _getWpContentUrl() { $isWpMuDomainMapped = defined('DOMAIN_MAPPING') && constant('DOMAIN_MAPPING') && defined('COOKIE_DOMAIN'); /* http://code.google.com/p/tubepress/issues/detail?id=495#c2 */ if ($isWpMuDomainMapped) { $scheme = $this->_wpFunctionsInterface->is_ssl() ? 'https://' : 'http://'; return $scheme . constant('COOKIE_DOMAIN') . '/wp-content'; } return $this->_wpFunctionsInterface->content_url(); }
/** * @return array An associative array of filenames to template display names. */ public function getPageTemplates() { if (!$this->_cache->containsKey('templates')) { $wpTheme = $this->_wpFunctions->wp_get_theme(); /* @noinspection PhpUndefinedMethodInspection */ $toReturn = $wpTheme->get_page_templates(); $toReturn['index.php'] = 'default'; asort($toReturn); $this->_cache->put('templates', $toReturn); } return $this->_cache->get('templates'); }
/** * 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); }
/** * {@inheritdoc} */ public function onSubmit() { $this->_wpFunctions->check_admin_referer('tubepress-save', 'tubepress_nonce'); return null; }
/** * Filter the content (which may be empty). */ public function onAction_admin_menu(tubepress_api_event_EventInterface $event) { $this->_wpFunctions->add_options_page('TubePress Options', 'TubePress', 'manage_options', 'tubepress', array($this, '__fireOptionsPageEvent')); $this->_wpFunctions->add_submenu_page(null, '', '', 'manage_options', 'tubepress_oauth2_start', array($this, '__noop')); $this->_wpFunctions->add_submenu_page(null, '', '', 'manage_options', 'tubepress_oauth2', array($this, '__noop')); }
/** * {@inheritdoc} */ public function getLocale() { return $this->_wpFunctions->get_locale(); }
private function _addShortcodeListener() { $keyword = $this->_persistence->fetch(tubepress_api_options_Names::SHORTCODE_KEYWORD); $this->_wpFunctions->add_shortcode($keyword, array($this, 'callback_onShortcode')); }