/** * Returns the complete taxonomy query var variable */ public function getQueryVar() { $wordpressKey = $this->getWordpressKey(); $generatedQueryVar = Strata::config("runtime.taxonomy.query_vars.{$wordpressKey}"); if (!is_null($generatedQueryVar)) { return $generatedQueryVar; } return $wordpressKey; }
/** * Registers the plugin and saved the context in which * the plugin will run. */ public function addFilters() { register_activation_hook(Strata::config('runtime.polyglot.loaderPath'), function () { $query = new Query(); $query->createTable(); }); $polyglot = new Polyglot(); // We need to rehook into setCurrentLocaleByContext because we need to // try again once global post objects are loaded. add_action(is_admin() ? 'admin_init' : 'wp', array($polyglot, "setCurrentLocaleByContext"), 3); is_admin() ? AdminAdaptor::addFilters() : FrontAdaptor::addFilters(); CommonAdaptor::addFilters(); WidgetAdaptor::addFilters(); }
private function taxonomyWasLocalizedInStrata($wordpressKey) { return !is_null(Strata::config("runtime.taxonomy.query_vars.{$wordpressKey}")); }
public function shouldFallbackToDefaultLocale() { return (bool) Strata::config("i18n.default_locale_fallback"); }
/** * Generates the template file path base directory. * @return string */ protected function getTemplatePath() { $dirname = dirname(Strata::config('runtime.polyglot.loaderPath')); $paths = array($dirname, 'src', 'Admin', 'View'); return implode(DIRECTORY_SEPARATOR, $paths) . DIRECTORY_SEPARATOR; }
private function generateTaxonomyTags($taxonomy) { $shouldFallback = (bool) Strata::config("i18n.default_locale_fallback"); $defaultLocale = Strata::i18n()->getDefaultLocale(); $currentLocale = Strata::i18n()->getCurrentLocale(); $permalinkManager = new TermPermalinkManager(); $currentPermalink = get_term_link($taxonomy, $taxonomy->taxonomy); // Keep the default url handy $defaultFallbackUrl = ""; if ($shouldFallback) { $permalinkManager->enforceLocale($defaultLocale); $defaultFallbackUrl = $permalinkManager->generatePermalink($currentPermalink, $taxonomy, $taxonomy->taxonomy); } foreach (Strata::i18n()->getLocales() as $locale) { $permalinkManager->enforceLocale($locale); try { $localizedUrl = $permalinkManager->generatePermalink($currentPermalink, $taxonomy, $taxonomy->taxonomy); $destinationIsTheSame = $localizedUrl === $currentPermalink; $isNotDefaultButIsNotTheCurrent = !$locale->isDefault() && $locale->getCode() !== $currentLocale->getCode(); if ($isNotDefaultButIsNotTheCurrent && $destinationIsTheSame && $shouldFallback) { $this->alternates[] = sprintf('<link rel="alternate" hreflang="%s" href="%s">', $locale->getCode(), $defaultFallbackUrl); $this->canonicals[] = sprintf('<link rel="canonical" href="%s">', $defaultFallbackUrl); } else { $this->alternates[] = sprintf('<link rel="alternate" hreflang="%s" href="%s">', $locale->getCode(), $localizedUrl); } } catch (Exception $e) { } } }
/** * Goes through the list of localization configurations values in Strata's * configuration file. * @return array A list of instantiated Locale object. */ protected function parseLocalesFromConfig() { $localeInfos = Hash::normalize((array) Strata::config("i18n.locales")); $locales = array(); foreach ($localeInfos as $key => $config) { $locales[$key] = new Locale($key, $config); } return $locales; }
protected function getPluginLocalePath() { return dirname(Strata::config('runtime.polyglot.loaderPath')) . DIRECTORY_SEPARATOR . 'locale'; }