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 onGlobalJsConfig(tubepress_api_event_EventInterface $event) { /* * @var array */ $config = $event->getSubject(); if (!isset($config['urls'])) { $config['urls'] = array(); } $baseUrl = $this->_environment->getBaseUrl()->getClone(); $userContentUrl = $this->_environment->getUserContentUrl()->getClone(); $ajaxEndpointUrl = $this->_environment->getAjaxEndpointUrl()->getClone(); $baseUrl->removeSchemeAndAuthority(); $userContentUrl->removeSchemeAndAuthority(); $ajaxEndpointUrl->removeSchemeAndAuthority(); $config['urls']['base'] = "{$baseUrl}"; $config['urls']['usr'] = "******"; $config['urls']['ajax'] = "{$ajaxEndpointUrl}"; $event->setSubject($config); }
private function _recursivelyGetFromTheme(tubepress_api_theme_ThemeInterface $theme, $getter) { $toReturn = $theme->{$getter}($this->_environment->getBaseUrl(), $this->_environment->getUserContentUrl()); $parentThemeName = $theme->getParentThemeName(); if (!$parentThemeName) { return $toReturn; } $theme = $this->_themeRegistry->getInstanceByName($parentThemeName); if (!$theme) { return $toReturn; } $fromParent = $this->_recursivelyGetFromTheme($theme, $getter); if (is_array($fromParent)) { $toReturn = array_merge($fromParent, $toReturn); } else { $toReturn = $fromParent . $toReturn; } return $toReturn; }
/** * {@inheritdoc} */ public function getTemplateVariables(tubepress_api_media_MediaItem $mediaItem) { $dataUrl = $this->_urlFactory->fromString(sprintf('https://www.youtube.com/watch?v=%s', $mediaItem->getId())); return array('userContentUrl' => $this->_environment->getUserContentUrl(), 'autostart' => $this->_context->get(tubepress_api_options_Names::EMBEDDED_AUTOPLAY), tubepress_api_template_VariableNames::EMBEDDED_DATA_URL => $dataUrl, tubepress_jwplayer5_api_OptionNames::COLOR_FRONT => $this->_context->get(tubepress_jwplayer5_api_OptionNames::COLOR_FRONT), tubepress_jwplayer5_api_OptionNames::COLOR_LIGHT => $this->_context->get(tubepress_jwplayer5_api_OptionNames::COLOR_LIGHT), tubepress_jwplayer5_api_OptionNames::COLOR_SCREEN => $this->_context->get(tubepress_jwplayer5_api_OptionNames::COLOR_SCREEN), tubepress_jwplayer5_api_OptionNames::COLOR_BACK => $this->_context->get(tubepress_jwplayer5_api_OptionNames::COLOR_BACK)); }