Updates.
|
|
@ -0,0 +1,922 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mutiple Domain WordPress plugin.
|
||||||
|
*
|
||||||
|
* Core features.
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
*
|
||||||
|
* - Clay Allsopp <https://github.com/clayallsopp>
|
||||||
|
* - Alexander Nosov <https://github.com/cyberaleks>
|
||||||
|
* - João Faria <https://github.com/jffaria>
|
||||||
|
* - Raphael Stäbler <https://github.com/blazer82>
|
||||||
|
* - Tobias Keller <https://github.com/Tobias-Keller>
|
||||||
|
* - Maxime Granier <https://github.com/maxgranier>
|
||||||
|
*
|
||||||
|
* @author Gustavo Straube <https://github.com/straube>
|
||||||
|
* @version 1.0.6
|
||||||
|
* @package multiple-domain
|
||||||
|
*/
|
||||||
|
class MultipleDomain
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The plugin version.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 0.3
|
||||||
|
*/
|
||||||
|
const VERSION = '1.0.6';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of the default HTTP port.
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
const PORT_HTTP = 80;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of the default HTTPS port.
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
const PORT_HTTPS = 443;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The plugin instance.
|
||||||
|
*
|
||||||
|
* @var \MultipleDomain
|
||||||
|
* @since 0.8.4
|
||||||
|
*/
|
||||||
|
private static $instance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current domain.
|
||||||
|
*
|
||||||
|
* This property's value also may include the host port when it's
|
||||||
|
* different than `80` (the default HTTP port) and `443` (the default HTTPS
|
||||||
|
* port).
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 0.2
|
||||||
|
*/
|
||||||
|
private $domain = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The original domain set in WordPress installation.
|
||||||
|
*
|
||||||
|
* This property's value also may include the host port when it's
|
||||||
|
* different than `80` (the default HTTP port) and `443` (the default HTTPS
|
||||||
|
* port).
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 0.3
|
||||||
|
*/
|
||||||
|
private $originalDomain = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of available domains.
|
||||||
|
*
|
||||||
|
* This array holds all available domains as its keys. Each item in the
|
||||||
|
* array is also an array containing the following keys:
|
||||||
|
*
|
||||||
|
* - `base`
|
||||||
|
* - `lang`
|
||||||
|
* - `protocol`
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $domains = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate whether the default ports should be ingored.
|
||||||
|
*
|
||||||
|
* This check is used when redirecting from a domain to another, for
|
||||||
|
* example.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @since 0.11.0
|
||||||
|
*/
|
||||||
|
private $ignoreDefaultPorts = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate whether canonical link should be added to pages.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @since 0.11.0
|
||||||
|
*/
|
||||||
|
private $addCanonical = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin activation tasks.
|
||||||
|
*
|
||||||
|
* The required plugin options are added to WordPress. We also make sure
|
||||||
|
* this plugin is the first loaded here.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 0.7
|
||||||
|
*/
|
||||||
|
public static function activate()
|
||||||
|
{
|
||||||
|
add_option('multiple-domain-domains', []);
|
||||||
|
add_option('multiple-domain-ignore-default-ports', true);
|
||||||
|
add_option('multiple-domain-add-canonical', false);
|
||||||
|
|
||||||
|
self::loadFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update plugin loading order to load this plugin before any other plugin
|
||||||
|
* and make sure all plugins use the right domain replacements.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 0.8.7
|
||||||
|
*/
|
||||||
|
public static function loadFirst()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Relative path to this plugin. The array of active plugins has the
|
||||||
|
* plugin path as its keys. We'll use this path to move Multiple Domain
|
||||||
|
* to the first position in that array.
|
||||||
|
*/
|
||||||
|
$path = str_replace(WP_PLUGIN_DIR . '/', '', MULTIPLE_DOMAIN_PLUGIN);
|
||||||
|
$plugins = get_option('active_plugins');
|
||||||
|
|
||||||
|
if (empty($plugins)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($key = array_search($path, $plugins))) {
|
||||||
|
array_splice($plugins, $key, 1);
|
||||||
|
array_unshift($plugins, $path);
|
||||||
|
update_option('active_plugins', $plugins);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the single plugin instance.
|
||||||
|
*
|
||||||
|
* @return \MultipleDomain The plugin instance.
|
||||||
|
* @since 0.8.4
|
||||||
|
*/
|
||||||
|
public static function instance()
|
||||||
|
{
|
||||||
|
if (!isset(self::$instance)) {
|
||||||
|
self::$instance = new self();
|
||||||
|
}
|
||||||
|
return self::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance.
|
||||||
|
*
|
||||||
|
* Adds actions and filters required by the plugin.
|
||||||
|
*/
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
|
$this->initAttributes();
|
||||||
|
$this->hookActions();
|
||||||
|
$this->hookFilters();
|
||||||
|
$this->hookShortcodes();
|
||||||
|
|
||||||
|
new MultipleDomainSettings($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// WordPress API integration
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the class attributes.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 0.8
|
||||||
|
*/
|
||||||
|
private function initAttributes()
|
||||||
|
{
|
||||||
|
$this->ignoreDefaultPorts = (bool) get_option('multiple-domain-ignore-default-ports');
|
||||||
|
$this->originalDomain = $this->getDomainFromUrl(get_option('home'), $this->ignoreDefaultPorts);
|
||||||
|
|
||||||
|
$this->domain = $this->getDomainFromRequest();
|
||||||
|
|
||||||
|
$domains = (array) get_option('multiple-domain-domains');
|
||||||
|
$this->resetDomains();
|
||||||
|
foreach ($domains as $domain => $options) {
|
||||||
|
$options = wp_parse_args($options, [
|
||||||
|
'base' => null,
|
||||||
|
'lang' => null,
|
||||||
|
'protocol' => null,
|
||||||
|
]);
|
||||||
|
$this->addDomain($domain, $options['base'], $options['lang'], $options['protocol']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!array_key_exists($this->domain, $this->domains)) {
|
||||||
|
$this->domain = $this->originalDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addCanonical = (bool) get_option('multiple-domain-add-canonical');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook plugin actions to WordPress.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 0.8
|
||||||
|
*/
|
||||||
|
private function hookActions()
|
||||||
|
{
|
||||||
|
add_action('init', [ $this, 'redirect' ]);
|
||||||
|
add_action('wp_head', [ $this, 'addHrefLangTags' ]);
|
||||||
|
add_action('wp_head', [ $this, 'addCanonicalTag' ]);
|
||||||
|
add_action('plugins_loaded', [ $this, 'loaded' ]);
|
||||||
|
add_action('activated_plugin', [ self::class, 'loadFirst' ]);
|
||||||
|
add_action('wpseo_register_extra_replacements', [ $this, 'registerYoastVars' ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook plugin filters to WordPress.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 0.8
|
||||||
|
*/
|
||||||
|
private function hookFilters()
|
||||||
|
{
|
||||||
|
|
||||||
|
// Generic domain replacement
|
||||||
|
add_filter('content_url', [ $this, 'fixUrl' ]);
|
||||||
|
add_filter('option_siteurl', [ $this, 'fixUrl' ]);
|
||||||
|
add_filter('option_home', [ $this, 'fixUrl' ]);
|
||||||
|
add_filter('plugins_url', [ $this, 'fixUrl' ]);
|
||||||
|
add_filter('wp_get_attachment_url', [ $this, 'fixUrl' ]);
|
||||||
|
add_filter('get_the_guid', [ $this, 'fixUrl' ]);
|
||||||
|
|
||||||
|
// Specific domain replacement filters
|
||||||
|
add_filter('upload_dir', [ $this, 'fixUploadDir' ]);
|
||||||
|
add_filter('the_content', [ $this, 'fixContentUrls' ], 20);
|
||||||
|
add_filter('allowed_http_origins', [ $this, 'addAllowedOrigins' ]);
|
||||||
|
|
||||||
|
// Add body class based on domain
|
||||||
|
add_filter('body_class', [ $this, 'addDomainBodyClass' ]);
|
||||||
|
|
||||||
|
// Stop WP built in Canonical URL if this plugin has 'Add canonical links' enabled
|
||||||
|
add_filter('get_canonical_url', [ $this, 'getCanonicalUrl' ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook plugin shortcodes to WordPress.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 0.8.5
|
||||||
|
*/
|
||||||
|
private function hookShortcodes()
|
||||||
|
{
|
||||||
|
add_shortcode('multiple_domain', [ $this, 'shortcode' ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the current domain.
|
||||||
|
*
|
||||||
|
* Since this value is checked against plugin settings, it may not reflect
|
||||||
|
* the actual current domain in `HTTP_HOST` key from global `$_SERVER` var.
|
||||||
|
*
|
||||||
|
* Depending on the plugin settings, the domain also may include the host
|
||||||
|
* port when it's different than `80` (the default HTTP port) and `443` (the
|
||||||
|
* default HTTPS port).
|
||||||
|
*
|
||||||
|
* @return string|null The domain.
|
||||||
|
* @since 0.2
|
||||||
|
*/
|
||||||
|
public function getDomain()
|
||||||
|
{
|
||||||
|
return $this->domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return original domain set in WordPress installation.
|
||||||
|
*
|
||||||
|
* Notice this method may return an unexpected value when running the site
|
||||||
|
* using the `server` command from wp-cli. That's because wp-cli changes the
|
||||||
|
* value of `site_url` and `home_url` options through a filter.
|
||||||
|
* Unfortunately, it's not possible to change this behaviour.
|
||||||
|
*
|
||||||
|
* The domain also may include the host port when it's different than `80`
|
||||||
|
* (the default HTTP port) and `443` (the default HTTPS port).
|
||||||
|
*
|
||||||
|
* @return string The domain.
|
||||||
|
* @since 0.3
|
||||||
|
*/
|
||||||
|
public function getOriginalDomain()
|
||||||
|
{
|
||||||
|
return $this->originalDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all domains available.
|
||||||
|
*
|
||||||
|
* The keys in the returned array are the domain name. Each item in the
|
||||||
|
* array is also an array containing the following keys:
|
||||||
|
*
|
||||||
|
* - `base`
|
||||||
|
* - `lang`
|
||||||
|
* - `protocol`
|
||||||
|
*
|
||||||
|
* @return array The list of domains.
|
||||||
|
* @since 0.11.0
|
||||||
|
*/
|
||||||
|
public function getDomains()
|
||||||
|
{
|
||||||
|
return $this->domains;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate whether the default ports (`80` or `443`) should be ingored.
|
||||||
|
*
|
||||||
|
* This check is used when redirecting from a domain to another, for
|
||||||
|
* example.
|
||||||
|
*
|
||||||
|
* @return bool A boolean indicating if the default port should be ignored.
|
||||||
|
* @since 0.8.2
|
||||||
|
*/
|
||||||
|
public function shouldIgnoreDefaultPorts()
|
||||||
|
{
|
||||||
|
return $this->ignoreDefaultPorts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate whether the canonical tags should be added to page.
|
||||||
|
*
|
||||||
|
* @return bool A boolean indicating if the default port should be ignored.
|
||||||
|
* @since 0.11.0
|
||||||
|
*/
|
||||||
|
public function shouldAddCanonical()
|
||||||
|
{
|
||||||
|
return $this->addCanonical;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the base path associated to the given domain.
|
||||||
|
*
|
||||||
|
* If no domain is passed to the function, it'll return the base path for
|
||||||
|
* the current domain.
|
||||||
|
*
|
||||||
|
* Notice this function may return `null` when no base path is set for a
|
||||||
|
* given domain in the plugin config.
|
||||||
|
*
|
||||||
|
* @param string|null $domain The domain.
|
||||||
|
* @return string|null The base path.
|
||||||
|
* @since 0.10.3
|
||||||
|
*/
|
||||||
|
public function getDomainBase($domain = null)
|
||||||
|
{
|
||||||
|
return $this->getDomainAttribute('base', $domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the language associated to the given domain.
|
||||||
|
*
|
||||||
|
* If no domain is passed to the function, it'll return the language for
|
||||||
|
* the current domain.
|
||||||
|
*
|
||||||
|
* Notice this function may return `null` when no language is set for a
|
||||||
|
* given domain in the plugin config.
|
||||||
|
*
|
||||||
|
* @param string|null $domain The domain.
|
||||||
|
* @return string|null The language code.
|
||||||
|
* @since 0.8
|
||||||
|
*/
|
||||||
|
public function getDomainLang($domain = null)
|
||||||
|
{
|
||||||
|
return $this->getDomainAttribute('lang', $domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the protocol option for the given domain.
|
||||||
|
*
|
||||||
|
* If no domain is passed to the function, it'll return the option for the
|
||||||
|
* current domain.
|
||||||
|
*
|
||||||
|
* The possible returned values are `http`, `https`, or `auto` (default). If
|
||||||
|
* no protocol is defined for a given domain, the default value will be
|
||||||
|
* returned.
|
||||||
|
*
|
||||||
|
* @param string|null $domain The domain.
|
||||||
|
* @return string The protocol option.
|
||||||
|
* @since 0.10.0
|
||||||
|
*/
|
||||||
|
public function getDomainProtocol($domain = null)
|
||||||
|
{
|
||||||
|
$protocol = $this->getDomainAttribute('protocol', $domain);
|
||||||
|
return in_array($protocol, [ 'http', 'https' ]) ? $protocol : 'auto';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the list of domains.
|
||||||
|
*
|
||||||
|
* In case the `$keepOriginal` param is `true`, which is the default, the
|
||||||
|
* list of domains will have only the original domain where WordPress was
|
||||||
|
* installed.
|
||||||
|
*
|
||||||
|
* @param bool $keepOriginal Indicates whether the original domain should
|
||||||
|
* be kept.
|
||||||
|
* @return void
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function resetDomains($keepOriginal = true)
|
||||||
|
{
|
||||||
|
if (!$keepOriginal || empty($this->originalDomain)) {
|
||||||
|
$this->domains = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->domains = [
|
||||||
|
$this->originalDomain => [
|
||||||
|
'base' => null,
|
||||||
|
'lang' => null,
|
||||||
|
'protocol' => 'auto',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new domain to the list of domains.
|
||||||
|
*
|
||||||
|
* Besides the `$domain` param, all other are optional.
|
||||||
|
*
|
||||||
|
* @param string $domain The domain.
|
||||||
|
* @param string $base The base path.
|
||||||
|
* @param string $lang The language.
|
||||||
|
* @param string $protocol The protocol option. It can be `http`, `https`
|
||||||
|
* or `auto`.
|
||||||
|
* @return void
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function addDomain($domain, $base = null, $lang = null, $protocol = 'auto')
|
||||||
|
{
|
||||||
|
$this->domains[$domain] = [
|
||||||
|
'base' => $base,
|
||||||
|
'lang' => $lang,
|
||||||
|
'protocol' => $protocol,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the current list of domains in the WordPress options.
|
||||||
|
*
|
||||||
|
* This is can be used to persist changes made to the list of domains with
|
||||||
|
* `resetDomains` and `addDomain` methods.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function storeDomains()
|
||||||
|
{
|
||||||
|
update_option('multiple-domain-domains', $this->domains);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the current domain has a base URL restriction and the current
|
||||||
|
* request URI doesn't match it, redirects the user.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function redirect()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Allow developers to create their own logic for redirection.
|
||||||
|
*/
|
||||||
|
do_action('multiple_domain_redirect', $this->domain);
|
||||||
|
|
||||||
|
$base = $this->getDomainBase();
|
||||||
|
$uri = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null;
|
||||||
|
|
||||||
|
$base = ltrim($base, '/');
|
||||||
|
$uri = ltrim($uri, '/');
|
||||||
|
|
||||||
|
if (empty($base) || preg_match('/^wp-[a-z]+(\.php|\/|$)/i', $uri)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($uri, $base) !== 0) {
|
||||||
|
wp_redirect(home_url('/' . $base));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the domain in the given URL.
|
||||||
|
*
|
||||||
|
* The domain in the given URL is replaced with the current domain. If the
|
||||||
|
* URL contains `/wp-admin/` it'll be ignored when replacing the domain and
|
||||||
|
* returned as is.
|
||||||
|
*
|
||||||
|
* @param string $url The URL to fix.
|
||||||
|
* @return string The domain replaced URL.
|
||||||
|
* @since 0.10.0
|
||||||
|
*/
|
||||||
|
public function fixUrl($url)
|
||||||
|
{
|
||||||
|
if (!preg_match('/\/wp-admin\/?/', $url)) {
|
||||||
|
$domain = $this->getDomainFromUrl($url);
|
||||||
|
$url = $this->replaceDomain($domain, $url);
|
||||||
|
}
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the domain in `upload_dir` filter used by `wp_upload_dir()`.
|
||||||
|
*
|
||||||
|
* The domain in the given `url` and `baseurl` is replaced by the current
|
||||||
|
* domain.
|
||||||
|
*
|
||||||
|
* @param array $uploads The array of `url`, `baseurl` and other
|
||||||
|
* properties.
|
||||||
|
* @return array The domain-replaced values.
|
||||||
|
* @since 0.4
|
||||||
|
*/
|
||||||
|
public function fixUploadDir($uploads)
|
||||||
|
{
|
||||||
|
$uploads['url'] = $this->fixUrl($uploads['url']);
|
||||||
|
$uploads['baseurl'] = $this->fixUrl($uploads['baseurl']);
|
||||||
|
return $uploads;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the domain in post content.
|
||||||
|
*
|
||||||
|
* All occurrences of any of the available domains (i.e. all domains set in
|
||||||
|
* the plugin config) will be replaced with the current domain.
|
||||||
|
*
|
||||||
|
* @param string $content The content to fix.
|
||||||
|
* @return string The domain replaced content.
|
||||||
|
* @since 0.8
|
||||||
|
*/
|
||||||
|
public function fixContentUrls($content)
|
||||||
|
{
|
||||||
|
foreach (array_keys($this->domains) as $domain) {
|
||||||
|
$content = $this->replaceDomain($domain, $content);
|
||||||
|
}
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add all available domains to allowed origins.
|
||||||
|
*
|
||||||
|
* This filter is used to prevent CORS issues.
|
||||||
|
*
|
||||||
|
* @param array $origins The default list of allowed origins.
|
||||||
|
* @return array The updated list of allowed origins.
|
||||||
|
* @since 0.8
|
||||||
|
*/
|
||||||
|
public function addAllowedOrigins($origins)
|
||||||
|
{
|
||||||
|
foreach (array_keys($this->domains) as $domain) {
|
||||||
|
$origins[] = 'https://' . $domain;
|
||||||
|
$origins[] = 'http://' . $domain;
|
||||||
|
}
|
||||||
|
return array_values(array_unique($origins));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the current domain to the body class in a sanitized version.
|
||||||
|
*
|
||||||
|
* If the current domain is `example.com`, the class added to the page body
|
||||||
|
* will be `multiple-domain-example-com`. Notice this filter only has effect
|
||||||
|
* when the `body_class()` function is added to the page's `<body> tag`.
|
||||||
|
*
|
||||||
|
* @param array $classes The initial list of body class names.
|
||||||
|
* @return array Updated list of body class names.
|
||||||
|
* @since 0.9.0
|
||||||
|
*/
|
||||||
|
public function addDomainBodyClass($classes)
|
||||||
|
{
|
||||||
|
$classes[] = 'multiple-domain-' . preg_replace('/[^a-z0-9]+/i', '-', $this->domain);
|
||||||
|
return $classes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add `hreflang` links to head for SEO purpose.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @author Alexander Nosov <https://github.com/cyberaleks>
|
||||||
|
* @since 0.4
|
||||||
|
*/
|
||||||
|
public function addHrefLangTags()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The WP class instance.
|
||||||
|
*
|
||||||
|
* @var WP
|
||||||
|
*/
|
||||||
|
global $wp;
|
||||||
|
|
||||||
|
$uri = trailingslashit('/' . ltrim(add_query_arg([], $wp->request), '/'));
|
||||||
|
$currentProtocol = $this->getCurrentProtocol();
|
||||||
|
|
||||||
|
foreach (array_keys($this->domains) as $domain) {
|
||||||
|
$protocol = $this->getDomainProtocol($domain);
|
||||||
|
if ($protocol === 'auto') {
|
||||||
|
$protocol = $currentProtocol;
|
||||||
|
}
|
||||||
|
$protocol .= '://';
|
||||||
|
|
||||||
|
$lang = $this->getDomainLang($domain);
|
||||||
|
|
||||||
|
if (!empty($lang)) {
|
||||||
|
$this->outputHrefLangTag($protocol . $domain . $uri, $lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($domain === $this->originalDomain) {
|
||||||
|
$this->outputHrefLangTag($protocol . $domain . $uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add `canonical` links to head for SEO purpose.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 0.11.0
|
||||||
|
*/
|
||||||
|
public function addCanonicalTag()
|
||||||
|
{
|
||||||
|
if (!$this->shouldAddCanonical()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The WP class instance.
|
||||||
|
*
|
||||||
|
* @var WP
|
||||||
|
*/
|
||||||
|
global $wp;
|
||||||
|
|
||||||
|
$uri = home_url(add_query_arg([], $wp->request), 'relative') . '/';
|
||||||
|
$currentProtocol = $this->getCurrentProtocol();
|
||||||
|
|
||||||
|
$protocol = $this->getDomainProtocol($this->originalDomain);
|
||||||
|
if ($protocol === 'auto') {
|
||||||
|
$protocol = $currentProtocol;
|
||||||
|
}
|
||||||
|
$protocol .= '://';
|
||||||
|
|
||||||
|
$this->outputCanonicalTag($protocol . $this->originalDomain . $uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This shortcode simply returns the current domain.
|
||||||
|
*
|
||||||
|
* @return string The current domain.
|
||||||
|
* @since 0.8.5
|
||||||
|
*/
|
||||||
|
public function shortcode()
|
||||||
|
{
|
||||||
|
return $this->domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load text domain when plugin is loaded.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 0.8.6
|
||||||
|
*/
|
||||||
|
public function loaded()
|
||||||
|
{
|
||||||
|
$path = dirname(plugin_basename(MULTIPLE_DOMAIN_PLUGIN)) . '/languages/';
|
||||||
|
load_plugin_textdomain('multiple-domain', false, $path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register vars to be used as text replacements in Yoast tags.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 0.11.0
|
||||||
|
*/
|
||||||
|
public function registerYoastVars()
|
||||||
|
{
|
||||||
|
wpseo_register_var_replacement(
|
||||||
|
'%%multiple_domain%%',
|
||||||
|
[ $this, 'getDomain' ],
|
||||||
|
'advanced',
|
||||||
|
__('The current domain from Multiple Domain', 'multiple-domain')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current domain via request headers parsing.
|
||||||
|
*
|
||||||
|
* @return string|null The current domain.
|
||||||
|
* @since 0.8.7
|
||||||
|
*/
|
||||||
|
private function getDomainFromRequest()
|
||||||
|
{
|
||||||
|
$domain = $this->getHostHeader();
|
||||||
|
|
||||||
|
if (empty($domain)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$matches = [];
|
||||||
|
if (preg_match('/^(.*):(\d+)$/', $domain, $matches) && $this->isDefaultPort($matches[2])) {
|
||||||
|
$domain = $matches[1];
|
||||||
|
}
|
||||||
|
return $domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the `Host` HTTP header value.
|
||||||
|
*
|
||||||
|
* To make it compatible with proxies, this function first tries to get the
|
||||||
|
* value from `X-Host` header and, then, falls back to the regular `Host`
|
||||||
|
* header.
|
||||||
|
*
|
||||||
|
* It returns `null` in case both headers are empty.
|
||||||
|
*
|
||||||
|
* @return string|null The HTTP `Host` header value.
|
||||||
|
* @since 0.8.7
|
||||||
|
*/
|
||||||
|
private function getHostHeader()
|
||||||
|
{
|
||||||
|
if (!empty($_SERVER['HTTP_X_HOST'])) {
|
||||||
|
return $_SERVER['HTTP_X_HOST'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($_SERVER['HTTP_HOST'])) {
|
||||||
|
return $_SERVER['HTTP_HOST'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current URL protocol based on server settings.
|
||||||
|
*
|
||||||
|
* The possible returned values are `http` and `https`.
|
||||||
|
*
|
||||||
|
* @return string The protocol.
|
||||||
|
*/
|
||||||
|
private function getCurrentProtocol()
|
||||||
|
{
|
||||||
|
return empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === 'off' ? 'http' : 'https';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an attribute by its name for the given domain.
|
||||||
|
*
|
||||||
|
* If no domain is passed to the function, it'll return the attribute value
|
||||||
|
* for the current domain.
|
||||||
|
*
|
||||||
|
* Notice this function may return `null` when the attribute is not set in
|
||||||
|
* the plugin config or doesn't exist.
|
||||||
|
*
|
||||||
|
* @param string $name The attribute name.
|
||||||
|
* @param string|null $domain The domain.
|
||||||
|
* @return string The attribute value.
|
||||||
|
* @since 0.10.0
|
||||||
|
*/
|
||||||
|
private function getDomainAttribute($name, $domain = null)
|
||||||
|
{
|
||||||
|
if (empty($domain)) {
|
||||||
|
$domain = $this->domain;
|
||||||
|
}
|
||||||
|
$attribute = null;
|
||||||
|
if (!empty($this->domains[$domain][$name])) {
|
||||||
|
$attribute = $this->domains[$domain][$name];
|
||||||
|
}
|
||||||
|
return $attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the domain.
|
||||||
|
*
|
||||||
|
* All occurrences of the given domain will be replaced with the current
|
||||||
|
* domain in the content.
|
||||||
|
*
|
||||||
|
* The protocol may also be replaced following the protocol settings defined
|
||||||
|
* in the plugin config for the current domain.
|
||||||
|
*
|
||||||
|
* @param string $domain The domain to replace.
|
||||||
|
* @param string $content The content that will have the domain replaced.
|
||||||
|
* @return string The domain-replaced content.
|
||||||
|
*/
|
||||||
|
private function replaceDomain($domain, $content)
|
||||||
|
{
|
||||||
|
if (MULTIPLE_DOMAIN_LOW_MEMORY) {
|
||||||
|
return $this->replaceDomainUsingLessMemory($domain, $content);
|
||||||
|
}
|
||||||
|
if (array_key_exists($domain, $this->domains)) {
|
||||||
|
$regex = '/(https?):\/\/' . preg_quote($domain, '/') . '(?![a-z0-9.\-:])/i';
|
||||||
|
$protocol = $this->getDomainProtocol($this->domain);
|
||||||
|
$replace = ($protocol === 'auto' ? '${1}' : $protocol) . '://' . $this->domain;
|
||||||
|
$content = preg_replace($regex, $replace, $content);
|
||||||
|
}
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the domain using less memory.
|
||||||
|
*
|
||||||
|
* This function does the same as `replaceDoamin`, however it uses
|
||||||
|
* `mb_eregi_replace` instead of `preg_replace` for less memory consumption.
|
||||||
|
* On the other hand, it takes more time to execute.
|
||||||
|
*
|
||||||
|
* @param string $domain The domain to replace.
|
||||||
|
* @param string $content The content that will have the domain replaced.
|
||||||
|
* @return string The domain-replaced content.
|
||||||
|
* @since 1.0.2
|
||||||
|
*/
|
||||||
|
private function replaceDomainUsingLessMemory($domain, $content)
|
||||||
|
{
|
||||||
|
if (array_key_exists($domain, $this->domains)) {
|
||||||
|
$regex = '(https?):\/\/' . preg_quote($domain, '/') . '(?![a-z0-9.\-:])';
|
||||||
|
$protocol = $this->getDomainProtocol($this->domain);
|
||||||
|
$replace = ($protocol === 'auto' ? '\\1' : $protocol) . '://' . $this->domain;
|
||||||
|
$content = mb_eregi_replace($regex, $replace, $content);
|
||||||
|
}
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the given URL to return only its domain.
|
||||||
|
*
|
||||||
|
* The server port may be included in the returning value depending on its
|
||||||
|
* number and plugin settings.
|
||||||
|
*
|
||||||
|
* @param string $url The URL to parse.
|
||||||
|
* @param bool $ignoreDefaultPorts If `true` is passed to this value, a
|
||||||
|
* default HTTP or HTTPS port will be ignored even if it's present
|
||||||
|
* in the URL.
|
||||||
|
* @return string The domain.
|
||||||
|
* @since 0.2
|
||||||
|
*/
|
||||||
|
private function getDomainFromUrl($url, $ignoreDefaultPorts = false)
|
||||||
|
{
|
||||||
|
$parts = parse_url($url);
|
||||||
|
$domain = $parts['host'];
|
||||||
|
if (!empty($parts['port']) && !($ignoreDefaultPorts && $this->isDefaultPort($parts['port']))) {
|
||||||
|
$domain .= ':' . $parts['port'];
|
||||||
|
}
|
||||||
|
return $domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the given port is a default HTTP (`80`) or HTTPS (`443`) port.
|
||||||
|
*
|
||||||
|
* @param int $port The port to check.
|
||||||
|
* @return bool Indicates if the port is a default one.
|
||||||
|
* @since 0.2
|
||||||
|
*/
|
||||||
|
private function isDefaultPort($port)
|
||||||
|
{
|
||||||
|
$port = (int) $port;
|
||||||
|
return $port === self::PORT_HTTP || $port === self::PORT_HTTPS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints a `hreflang` link tag.
|
||||||
|
*
|
||||||
|
* @param string $url The URL to be set into `href` attribute.
|
||||||
|
* @param string $lang The language code to be set into `hreflang`
|
||||||
|
* attribute. Defaults to `x-default`.
|
||||||
|
* @return void
|
||||||
|
* @since 0.5
|
||||||
|
*/
|
||||||
|
private function outputHrefLangTag($url, $lang = 'x-default')
|
||||||
|
{
|
||||||
|
$url = htmlentities($url);
|
||||||
|
$lang = str_replace('_', '-', $lang);
|
||||||
|
printf('<link rel="alternate" href="%s" hreflang="%s" />', $url, $lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints a `canonical` link tag.
|
||||||
|
*
|
||||||
|
* @param string $url The canonical URL to be set into `href` attribute.
|
||||||
|
* @return void
|
||||||
|
* @since 0.11.0
|
||||||
|
*/
|
||||||
|
private function outputCanonicalTag($url)
|
||||||
|
{
|
||||||
|
$url = htmlentities($url);
|
||||||
|
printf('<link rel="canonical" href="%s" />', $url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter override WordPress built-in canonical tag generation if using the this plugin's canonical tag feature
|
||||||
|
*
|
||||||
|
* @param $url
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCanonicalUrl($url)
|
||||||
|
{
|
||||||
|
// If *not* using the plugin's canonical tags, then return this URL. Otherwise, don't
|
||||||
|
if (!$this->shouldAddCanonical()) {
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,355 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mutiple Domain settings.
|
||||||
|
*
|
||||||
|
* Integration with WordPress admin.
|
||||||
|
*
|
||||||
|
* @author Gustavo Straube <https://github.com/straube>
|
||||||
|
* @version 1.0.6
|
||||||
|
* @since 0.11.0
|
||||||
|
* @package multiple-domain
|
||||||
|
*/
|
||||||
|
class MultipleDomainSettings
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The plugin core instance.
|
||||||
|
*
|
||||||
|
* @var \MultipleDomain
|
||||||
|
*/
|
||||||
|
private $core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance.
|
||||||
|
*
|
||||||
|
* Adds actions and filters required by the plugin for the admin.
|
||||||
|
*
|
||||||
|
* @param \MultipleDomain $core The core plugin class instance.
|
||||||
|
*/
|
||||||
|
public function __construct(MultipleDomain $core)
|
||||||
|
{
|
||||||
|
$this->core = $core;
|
||||||
|
|
||||||
|
$this->hookActions();
|
||||||
|
$this->hookFilters();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// WordPress API integration
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook plugin actions to WordPress.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function hookActions()
|
||||||
|
{
|
||||||
|
add_action('admin_init', [ $this, 'settings' ]);
|
||||||
|
add_action('admin_enqueue_scripts', [ $this, 'scripts' ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook plugin filters to WordPress.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function hookFilters()
|
||||||
|
{
|
||||||
|
add_filter('plugin_action_links_' . plugin_basename(MULTIPLE_DOMAIN_PLUGIN), [ $this, 'actionLinks' ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the required settings to show in the admin.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function settings()
|
||||||
|
{
|
||||||
|
add_settings_section('multiple-domain', __('Multiple Domain', 'multiple-domain'), [
|
||||||
|
$this,
|
||||||
|
'settingsHeading',
|
||||||
|
], 'general');
|
||||||
|
add_settings_field('multiple-domain-domains', __('Domains', 'multiple-domain'), [
|
||||||
|
$this,
|
||||||
|
'settingsFieldsForDomains',
|
||||||
|
], 'general', 'multiple-domain');
|
||||||
|
add_settings_field('multiple-domain-options', __('Options', 'multiple-domain'), [
|
||||||
|
$this,
|
||||||
|
'settingsFieldsForOptions',
|
||||||
|
], 'general', 'multiple-domain');
|
||||||
|
|
||||||
|
register_setting('general', 'multiple-domain-domains', [
|
||||||
|
$this,
|
||||||
|
'sanitizeDomainsSettings',
|
||||||
|
]);
|
||||||
|
register_setting('general', 'multiple-domain-ignore-default-ports', [
|
||||||
|
$this,
|
||||||
|
'castToBool',
|
||||||
|
]);
|
||||||
|
register_setting('general', 'multiple-domain-add-canonical', [
|
||||||
|
$this,
|
||||||
|
'castToBool',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanitizes the domain settings.
|
||||||
|
*
|
||||||
|
* It takes the value sent by the user in the settings form and parses it
|
||||||
|
* to store in the internal format used by the plugin.
|
||||||
|
*
|
||||||
|
* @param array $value The user defined option value.
|
||||||
|
* @return array The sanitized option value.
|
||||||
|
*/
|
||||||
|
public function sanitizeDomainsSettings($value)
|
||||||
|
{
|
||||||
|
$domains = [];
|
||||||
|
if (is_array($value)) {
|
||||||
|
foreach ($value as $row) {
|
||||||
|
if (empty($row['host'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$host = preg_replace('/^https?:\/\//i', '', $row['host']);
|
||||||
|
$base = !empty($row['base']) ? $row['base'] : null;
|
||||||
|
$lang = !empty($row['lang']) ? $row['lang'] : null;
|
||||||
|
$proto = !empty($row['protocol']) ? $row['protocol'] : 'auto';
|
||||||
|
$domains[$host] = [
|
||||||
|
'base' => $base,
|
||||||
|
'lang' => $lang,
|
||||||
|
'protocol' => $proto,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $domains;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Casts the given value to boolean.
|
||||||
|
*
|
||||||
|
* @param mixed $value The value to cast.
|
||||||
|
* @return bool A bolean representing the passed value.
|
||||||
|
*/
|
||||||
|
public function castToBool($value)
|
||||||
|
{
|
||||||
|
return (bool) $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the settings heading.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function settingsHeading()
|
||||||
|
{
|
||||||
|
echo $this->loadView('heading');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the fields for setting domains.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function settingsFieldsForDomains()
|
||||||
|
{
|
||||||
|
$fields = '';
|
||||||
|
$counter = 0;
|
||||||
|
|
||||||
|
foreach ($this->core->getDomains() as $domain => $values) {
|
||||||
|
$base = null;
|
||||||
|
$lang = null;
|
||||||
|
$protocol = null;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Backward compatibility with earlier versions.
|
||||||
|
*/
|
||||||
|
if (is_string($values)) {
|
||||||
|
$base = $values;
|
||||||
|
} else {
|
||||||
|
$base = !empty($values['base']) ? $values['base'] : null;
|
||||||
|
$lang = !empty($values['lang']) ? $values['lang'] : null;
|
||||||
|
$protocol = !empty($values['protocol']) ? $values['protocol'] : null;
|
||||||
|
}
|
||||||
|
$fields .= $this->getDomainFields($counter++, $domain, $base, $lang, $protocol);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Adds a row of empty fields to the settings when no domain is set.
|
||||||
|
*/
|
||||||
|
if ($counter === 0) {
|
||||||
|
$fields = $this->getDomainFields($counter);
|
||||||
|
}
|
||||||
|
|
||||||
|
$fieldsToAdd = $this->getDomainFields('COUNT');
|
||||||
|
echo $this->loadView('domains', compact('fields', 'fieldsToAdd'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the fields for plugin options.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function settingsFieldsForOptions()
|
||||||
|
{
|
||||||
|
$ignoreDefaultPorts = $this->core->shouldIgnoreDefaultPorts();
|
||||||
|
$addCanonical = $this->core->shouldAddCanonical();
|
||||||
|
echo $this->loadView('options', compact('ignoreDefaultPorts', 'addCanonical'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enqueues the required scripts.
|
||||||
|
*
|
||||||
|
* @param string $hook The current admin page.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function scripts($hook)
|
||||||
|
{
|
||||||
|
if ($hook !== 'options-general.php') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$settingsPath = plugins_url('settings.js', MULTIPLE_DOMAIN_PLUGIN);
|
||||||
|
wp_enqueue_script('multiple-domain-settings', $settingsPath, [ 'jquery' ], MultipleDomain::VERSION, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the "Settings" link to the plugin row in the plugins page.
|
||||||
|
*
|
||||||
|
* @param array $links The default list of links.
|
||||||
|
* @return array The updated list of links.
|
||||||
|
*/
|
||||||
|
public function actionLinks($links)
|
||||||
|
{
|
||||||
|
$url = admin_url('options-general.php#multiple-domain');
|
||||||
|
$link = '<a href="' . $url . '">' . __('Settings', 'multiple-domain') . '</a>';
|
||||||
|
array_unshift($links, $link);
|
||||||
|
return $links;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the fields for a domain setting.
|
||||||
|
*
|
||||||
|
* @param int $count The field count. It's used within the field name,
|
||||||
|
* since it's an array.
|
||||||
|
* @param string $host The host field value.
|
||||||
|
* @param string $base The base URL field value.
|
||||||
|
* @param string $lang The language field value.
|
||||||
|
* @param string $protocol The protocol handling option.
|
||||||
|
* @return string The rendered group of fields.
|
||||||
|
*/
|
||||||
|
private function getDomainFields($count, $host = null, $base = null, $lang = null, $protocol = null)
|
||||||
|
{
|
||||||
|
$langField = $this->getLangField($count, $lang);
|
||||||
|
return $this->loadView('fields', compact('count', 'host', 'base', 'protocol', 'langField'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the language field for domain settings.
|
||||||
|
*
|
||||||
|
* @param int $count The field count. It's used within the field name,
|
||||||
|
* since it's an array.
|
||||||
|
* @param string $lang The selected language.
|
||||||
|
* @return string The rendered field.
|
||||||
|
*/
|
||||||
|
private function getLangField($count, $lang = null)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Backward compability with a locale defined in previous versions.
|
||||||
|
*
|
||||||
|
* The HTML `lang` attribute uses a dash (`en-US`) to separate language
|
||||||
|
* and region, but WP languages have an underscore (`en_US`).
|
||||||
|
*/
|
||||||
|
if (!empty($lang)) {
|
||||||
|
$lang = str_replace('-', '_', $lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
$locales = $this->getLocales();
|
||||||
|
|
||||||
|
return $this->loadView('lang', compact('count', 'lang', 'locales'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of locales.
|
||||||
|
*
|
||||||
|
* The keys of the returned array are locale codes and the values are
|
||||||
|
* their names.
|
||||||
|
*
|
||||||
|
* A cached version will be returned if available.
|
||||||
|
*
|
||||||
|
* @return array The locales list.
|
||||||
|
*/
|
||||||
|
private function getLocales()
|
||||||
|
{
|
||||||
|
$locales = wp_cache_get('locales', 'multiple-domain');
|
||||||
|
|
||||||
|
if (empty($locales)) {
|
||||||
|
$locales = $this->getLocalesFromFile();
|
||||||
|
wp_cache_set('locales', $locales, 'multiple-domain');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $locales;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of locales from the source file.
|
||||||
|
*
|
||||||
|
* The keys of the returned array are locale codes and the values are
|
||||||
|
* their names.
|
||||||
|
*
|
||||||
|
* @return array The locales list.
|
||||||
|
*/
|
||||||
|
private function getLocalesFromFile()
|
||||||
|
{
|
||||||
|
$locales = [];
|
||||||
|
|
||||||
|
$handle = fopen(dirname(MULTIPLE_DOMAIN_PLUGIN) . '/locales.csv', 'r');
|
||||||
|
while (($row = fgetcsv($handle)) !== false) {
|
||||||
|
$locales[$row[0]] = $row[1];
|
||||||
|
}
|
||||||
|
fclose($handle);
|
||||||
|
asort($locales);
|
||||||
|
|
||||||
|
return $locales;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a view and return its contents.
|
||||||
|
*
|
||||||
|
* @param string $name The view name.
|
||||||
|
* @param array|null $data The data to pass to the view. Each key will be
|
||||||
|
* extracted as a variable into the view file.
|
||||||
|
* @return string The view contents.
|
||||||
|
*/
|
||||||
|
private function loadView($name, $data = null)
|
||||||
|
{
|
||||||
|
$path = sprintf('%s/views/%s.php', dirname(MULTIPLE_DOMAIN_PLUGIN), $name);
|
||||||
|
if (!is_file($path)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
if (is_array($data)) {
|
||||||
|
extract($this->replaceNull($data));
|
||||||
|
}
|
||||||
|
include $path;
|
||||||
|
return ob_get_clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace all `null` values in an array.
|
||||||
|
*
|
||||||
|
* @param array $array The original array.
|
||||||
|
* @param mixed $replacement The value to replace the `null` occurrences.
|
||||||
|
* @return array The array with replaced values.
|
||||||
|
*/
|
||||||
|
private function replaceNull($array, $replacement = '')
|
||||||
|
{
|
||||||
|
return array_map(function ($value) use ($replacement) {
|
||||||
|
return $value === null ? $replacement : $value;
|
||||||
|
}, $array);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Multiple Domain\n"
|
||||||
|
"POT-Creation-Date: 2019-01-18 15:34-0200\n"
|
||||||
|
"PO-Revision-Date: 2019-01-18 16:22-0200\n"
|
||||||
|
"Last-Translator: \n"
|
||||||
|
"Language-Team: Straube <https://straube.co>\n"
|
||||||
|
"Language: en_US\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"X-Generator: Poedit 2.2.1\n"
|
||||||
|
"X-Poedit-Basepath: .\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
"X-Poedit-KeywordsList: __;_e\n"
|
||||||
|
"X-Poedit-SearchPath-0: .\n"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:181
|
||||||
|
msgid "Multiple Domain"
|
||||||
|
msgstr "Multiple Domain"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:185
|
||||||
|
msgid "Domains"
|
||||||
|
msgstr "Domains"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:189
|
||||||
|
msgid "Options"
|
||||||
|
msgstr "Options"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:251
|
||||||
|
msgid ""
|
||||||
|
"You can use multiple domains in your WordPress defining them below. It's "
|
||||||
|
"possible to limit the access for each domain to a base URL."
|
||||||
|
msgstr ""
|
||||||
|
"You can use multiple domains in your WordPress defining them below. It’s "
|
||||||
|
"possible to limit the access for each domain to a base URL."
|
||||||
|
|
||||||
|
#: MultipleDomain.php:283
|
||||||
|
msgid "Add domain"
|
||||||
|
msgstr "Add domain"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:285
|
||||||
|
msgid ""
|
||||||
|
"A domain may contain the port number. If a base URL restriction is set for a "
|
||||||
|
"domain, all requests that don't start with the base URL will be redirected "
|
||||||
|
"to the base URL. <b>Example</b>: the domain and base URL are <code>example."
|
||||||
|
"com</code> and <code>/base/path</code>, when requesting <code>example.com/"
|
||||||
|
"other/path</code> it will be redirected to <code>example.com/base/path</"
|
||||||
|
"code>. Additionaly, it's possible to set a language for each domain, which "
|
||||||
|
"will be used to add <code><link></code> tags with a <code>hreflang</"
|
||||||
|
"code> attribute to the document head."
|
||||||
|
msgstr ""
|
||||||
|
"A domain may contain the port number. If a base URL restriction is set for a "
|
||||||
|
"domain, all requests that don’t start with the base URL will be redirected "
|
||||||
|
"to the base URL. <b>Example</b>: the domain and base URL are <code>example."
|
||||||
|
"com</code> and <code>/base/path</code>, when requesting <code>example.com/"
|
||||||
|
"other/path</code> it will be redirected to <code>example.com/base/path</"
|
||||||
|
"code>. Additionaly, it’s possible to set a language for each domain, which "
|
||||||
|
"will be used to add <code><link></code> tags with a <code>hreflang</"
|
||||||
|
"code> attribute to the document head."
|
||||||
|
|
||||||
|
#: MultipleDomain.php:305
|
||||||
|
msgid "Ignore default ports"
|
||||||
|
msgstr "Ignore default ports"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:306
|
||||||
|
msgid ""
|
||||||
|
"When enabled, removes the port from URL when redirecting and it's a default "
|
||||||
|
"HTTP (<code>80</code>) or HTTPS (<code>443</code>) port."
|
||||||
|
msgstr ""
|
||||||
|
"When enabled, removes the port from URL when redirecting and it’s a default "
|
||||||
|
"HTTP (<code>80</code>) or HTTPS (<code>443</code>) port."
|
||||||
|
|
||||||
|
#: MultipleDomain.php:412
|
||||||
|
msgid "Settings"
|
||||||
|
msgstr "Settings"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:609
|
||||||
|
msgid "Domain"
|
||||||
|
msgstr "Domain"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:612
|
||||||
|
msgid "Base path restriction"
|
||||||
|
msgstr "Base path restriction"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:615
|
||||||
|
msgid "Remove"
|
||||||
|
msgstr "Remove"
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Multiple Domain\n"
|
||||||
|
"POT-Creation-Date: 2019-01-18 15:34-0200\n"
|
||||||
|
"PO-Revision-Date: 2019-01-18 16:22-0200\n"
|
||||||
|
"Language-Team: Straube <https://straube.co>\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"X-Generator: Poedit 2.2.1\n"
|
||||||
|
"X-Poedit-Basepath: .\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
"X-Poedit-KeywordsList: __;_e\n"
|
||||||
|
"Last-Translator: \n"
|
||||||
|
"Language: pt_BR\n"
|
||||||
|
"X-Poedit-SearchPath-0: .\n"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:181
|
||||||
|
msgid "Multiple Domain"
|
||||||
|
msgstr "Multiple Domain"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:185
|
||||||
|
msgid "Domains"
|
||||||
|
msgstr "Domínios"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:189
|
||||||
|
msgid "Options"
|
||||||
|
msgstr "Opções"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:251
|
||||||
|
msgid ""
|
||||||
|
"You can use multiple domains in your WordPress defining them below. It's "
|
||||||
|
"possible to limit the access for each domain to a base URL."
|
||||||
|
msgstr ""
|
||||||
|
"Você pode usar múltiplos domínios com o seu WordPress os definindo abaixo. É "
|
||||||
|
"possível limitar o acesso a cada domínio a uma URL base."
|
||||||
|
|
||||||
|
#: MultipleDomain.php:283
|
||||||
|
msgid "Add domain"
|
||||||
|
msgstr "Adicionar domínio"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:285
|
||||||
|
msgid ""
|
||||||
|
"A domain may contain the port number. If a base URL restriction is set for a "
|
||||||
|
"domain, all requests that don't start with the base URL will be redirected "
|
||||||
|
"to the base URL. <b>Example</b>: the domain and base URL are <code>example."
|
||||||
|
"com</code> and <code>/base/path</code>, when requesting <code>example.com/"
|
||||||
|
"other/path</code> it will be redirected to <code>example.com/base/path</"
|
||||||
|
"code>. Additionaly, it's possible to set a language for each domain, which "
|
||||||
|
"will be used to add <code><link></code> tags with a <code>hreflang</"
|
||||||
|
"code> attribute to the document head."
|
||||||
|
msgstr ""
|
||||||
|
"Um domínio pode conter um número de porta. Se uma restrição de URL base for "
|
||||||
|
"definida para um domínio, todos as requisições que não começarem com a URL "
|
||||||
|
"base serão direcionadas para a URL base. <b>Exemplo</b>: o domínio e a base "
|
||||||
|
"são <code>example.com</code> e <code>/caminho/base</code>, quando "
|
||||||
|
"requisitando <code>example.com/outro/caminho</code> será redirecionado para "
|
||||||
|
"<code>example.com/caminho/base</code>. Adicionalmente, é possível determinar "
|
||||||
|
"um idioma para cada domínio, que será usado para adicionar tags <code><"
|
||||||
|
"link></code> com o atributo <code>hreflang</code> ao cabeçalho do "
|
||||||
|
"documento."
|
||||||
|
|
||||||
|
#: MultipleDomain.php:305
|
||||||
|
msgid "Ignore default ports"
|
||||||
|
msgstr "Ignorar portas padrão"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:306
|
||||||
|
msgid ""
|
||||||
|
"When enabled, removes the port from URL when redirecting and it's a default "
|
||||||
|
"HTTP (<code>80</code>) or HTTPS (<code>443</code>) port."
|
||||||
|
msgstr ""
|
||||||
|
"Quando habilitado, remove a porta da URL quando redirecionando e é uma porta "
|
||||||
|
"padrão HTTP (<code>80</code>) ou HTTPS (<code>443</code>)."
|
||||||
|
|
||||||
|
#: MultipleDomain.php:412
|
||||||
|
msgid "Settings"
|
||||||
|
msgstr "Configurações"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:609
|
||||||
|
msgid "Domain"
|
||||||
|
msgstr "Domínio"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:612
|
||||||
|
msgid "Base path restriction"
|
||||||
|
msgstr "Restrição de caminho base"
|
||||||
|
|
||||||
|
#: MultipleDomain.php:615
|
||||||
|
msgid "Remove"
|
||||||
|
msgstr "Remover"
|
||||||
|
|
@ -0,0 +1,564 @@
|
||||||
|
id,value
|
||||||
|
af,Afrikaans
|
||||||
|
af_NA,"Afrikaans (Namibia)"
|
||||||
|
af_ZA,"Afrikaans (South Africa)"
|
||||||
|
ak,Akan
|
||||||
|
ak_GH,"Akan (Ghana)"
|
||||||
|
sq,Albanian
|
||||||
|
sq_AL,"Albanian (Albania)"
|
||||||
|
sq_XK,"Albanian (Kosovo)"
|
||||||
|
sq_MK,"Albanian (Macedonia)"
|
||||||
|
am,Amharic
|
||||||
|
am_ET,"Amharic (Ethiopia)"
|
||||||
|
ar,Arabic
|
||||||
|
ar_DZ,"Arabic (Algeria)"
|
||||||
|
ar_BH,"Arabic (Bahrain)"
|
||||||
|
ar_TD,"Arabic (Chad)"
|
||||||
|
ar_KM,"Arabic (Comoros)"
|
||||||
|
ar_DJ,"Arabic (Djibouti)"
|
||||||
|
ar_EG,"Arabic (Egypt)"
|
||||||
|
ar_ER,"Arabic (Eritrea)"
|
||||||
|
ar_IQ,"Arabic (Iraq)"
|
||||||
|
ar_IL,"Arabic (Israel)"
|
||||||
|
ar_JO,"Arabic (Jordan)"
|
||||||
|
ar_KW,"Arabic (Kuwait)"
|
||||||
|
ar_LB,"Arabic (Lebanon)"
|
||||||
|
ar_LY,"Arabic (Libya)"
|
||||||
|
ar_MR,"Arabic (Mauritania)"
|
||||||
|
ar_MA,"Arabic (Morocco)"
|
||||||
|
ar_OM,"Arabic (Oman)"
|
||||||
|
ar_PS,"Arabic (Palestinian Territories)"
|
||||||
|
ar_QA,"Arabic (Qatar)"
|
||||||
|
ar_SA,"Arabic (Saudi Arabia)"
|
||||||
|
ar_SO,"Arabic (Somalia)"
|
||||||
|
ar_SS,"Arabic (South Sudan)"
|
||||||
|
ar_SD,"Arabic (Sudan)"
|
||||||
|
ar_SY,"Arabic (Syria)"
|
||||||
|
ar_TN,"Arabic (Tunisia)"
|
||||||
|
ar_AE,"Arabic (United Arab Emirates)"
|
||||||
|
ar_EH,"Arabic (Western Sahara)"
|
||||||
|
ar_YE,"Arabic (Yemen)"
|
||||||
|
hy,Armenian
|
||||||
|
hy_AM,"Armenian (Armenia)"
|
||||||
|
as,Assamese
|
||||||
|
as_IN,"Assamese (India)"
|
||||||
|
az,Azerbaijani
|
||||||
|
az_AZ,"Azerbaijani (Azerbaijan)"
|
||||||
|
az_Cyrl_AZ,"Azerbaijani (Cyrillic, Azerbaijan)"
|
||||||
|
az_Cyrl,"Azerbaijani (Cyrillic)"
|
||||||
|
az_Latn_AZ,"Azerbaijani (Latin, Azerbaijan)"
|
||||||
|
az_Latn,"Azerbaijani (Latin)"
|
||||||
|
bm,Bambara
|
||||||
|
bm_Latn_ML,"Bambara (Latin, Mali)"
|
||||||
|
bm_Latn,"Bambara (Latin)"
|
||||||
|
eu,Basque
|
||||||
|
eu_ES,"Basque (Spain)"
|
||||||
|
be,Belarusian
|
||||||
|
be_BY,"Belarusian (Belarus)"
|
||||||
|
bn,Bengali
|
||||||
|
bn_BD,"Bengali (Bangladesh)"
|
||||||
|
bn_IN,"Bengali (India)"
|
||||||
|
bs,Bosnian
|
||||||
|
bs_BA,"Bosnian (Bosnia & Herzegovina)"
|
||||||
|
bs_Cyrl_BA,"Bosnian (Cyrillic, Bosnia & Herzegovina)"
|
||||||
|
bs_Cyrl,"Bosnian (Cyrillic)"
|
||||||
|
bs_Latn_BA,"Bosnian (Latin, Bosnia & Herzegovina)"
|
||||||
|
bs_Latn,"Bosnian (Latin)"
|
||||||
|
br,Breton
|
||||||
|
br_FR,"Breton (France)"
|
||||||
|
bg,Bulgarian
|
||||||
|
bg_BG,"Bulgarian (Bulgaria)"
|
||||||
|
my,Burmese
|
||||||
|
my_MM,"Burmese (Myanmar (Burma))"
|
||||||
|
ca,Catalan
|
||||||
|
ca_AD,"Catalan (Andorra)"
|
||||||
|
ca_FR,"Catalan (France)"
|
||||||
|
ca_IT,"Catalan (Italy)"
|
||||||
|
ca_ES,"Catalan (Spain)"
|
||||||
|
zh,Chinese
|
||||||
|
zh_CN,"Chinese (China)"
|
||||||
|
zh_HK,"Chinese (Hong Kong SAR China)"
|
||||||
|
zh_MO,"Chinese (Macau SAR China)"
|
||||||
|
zh_Hans_CN,"Chinese (Simplified, China)"
|
||||||
|
zh_Hans_HK,"Chinese (Simplified, Hong Kong SAR China)"
|
||||||
|
zh_Hans_MO,"Chinese (Simplified, Macau SAR China)"
|
||||||
|
zh_Hans_SG,"Chinese (Simplified, Singapore)"
|
||||||
|
zh_Hans,"Chinese (Simplified)"
|
||||||
|
zh_SG,"Chinese (Singapore)"
|
||||||
|
zh_TW,"Chinese (Taiwan)"
|
||||||
|
zh_Hant_HK,"Chinese (Traditional, Hong Kong SAR China)"
|
||||||
|
zh_Hant_MO,"Chinese (Traditional, Macau SAR China)"
|
||||||
|
zh_Hant_TW,"Chinese (Traditional, Taiwan)"
|
||||||
|
zh_Hant,"Chinese (Traditional)"
|
||||||
|
kw,Cornish
|
||||||
|
kw_GB,"Cornish (United Kingdom)"
|
||||||
|
hr,Croatian
|
||||||
|
hr_BA,"Croatian (Bosnia & Herzegovina)"
|
||||||
|
hr_HR,"Croatian (Croatia)"
|
||||||
|
cs,Czech
|
||||||
|
cs_CZ,"Czech (Czech Republic)"
|
||||||
|
da,Danish
|
||||||
|
da_DK,"Danish (Denmark)"
|
||||||
|
da_GL,"Danish (Greenland)"
|
||||||
|
nl,Dutch
|
||||||
|
nl_AW,"Dutch (Aruba)"
|
||||||
|
nl_BE,"Dutch (Belgium)"
|
||||||
|
nl_BQ,"Dutch (Caribbean Netherlands)"
|
||||||
|
nl_CW,"Dutch (Curaçao)"
|
||||||
|
nl_NL,"Dutch (Netherlands)"
|
||||||
|
nl_SX,"Dutch (Sint Maarten)"
|
||||||
|
nl_SR,"Dutch (Suriname)"
|
||||||
|
dz,Dzongkha
|
||||||
|
dz_BT,"Dzongkha (Bhutan)"
|
||||||
|
en,English
|
||||||
|
en_AS,"English (American Samoa)"
|
||||||
|
en_AI,"English (Anguilla)"
|
||||||
|
en_AG,"English (Antigua & Barbuda)"
|
||||||
|
en_AU,"English (Australia)"
|
||||||
|
en_BS,"English (Bahamas)"
|
||||||
|
en_BB,"English (Barbados)"
|
||||||
|
en_BE,"English (Belgium)"
|
||||||
|
en_BZ,"English (Belize)"
|
||||||
|
en_BM,"English (Bermuda)"
|
||||||
|
en_BW,"English (Botswana)"
|
||||||
|
en_IO,"English (British Indian Ocean Territory)"
|
||||||
|
en_VG,"English (British Virgin Islands)"
|
||||||
|
en_CM,"English (Cameroon)"
|
||||||
|
en_CA,"English (Canada)"
|
||||||
|
en_KY,"English (Cayman Islands)"
|
||||||
|
en_CX,"English (Christmas Island)"
|
||||||
|
en_CC,"English (Cocos (Keeling) Islands)"
|
||||||
|
en_CK,"English (Cook Islands)"
|
||||||
|
en_DG,"English (Diego Garcia)"
|
||||||
|
en_DM,"English (Dominica)"
|
||||||
|
en_ER,"English (Eritrea)"
|
||||||
|
en_FK,"English (Falkland Islands)"
|
||||||
|
en_FJ,"English (Fiji)"
|
||||||
|
en_GM,"English (Gambia)"
|
||||||
|
en_GH,"English (Ghana)"
|
||||||
|
en_GI,"English (Gibraltar)"
|
||||||
|
en_GD,"English (Grenada)"
|
||||||
|
en_GU,"English (Guam)"
|
||||||
|
en_GG,"English (Guernsey)"
|
||||||
|
en_GY,"English (Guyana)"
|
||||||
|
en_HK,"English (Hong Kong SAR China)"
|
||||||
|
en_IN,"English (India)"
|
||||||
|
en_IE,"English (Ireland)"
|
||||||
|
en_IM,"English (Isle of Man)"
|
||||||
|
en_JM,"English (Jamaica)"
|
||||||
|
en_JE,"English (Jersey)"
|
||||||
|
en_KE,"English (Kenya)"
|
||||||
|
en_KI,"English (Kiribati)"
|
||||||
|
en_LS,"English (Lesotho)"
|
||||||
|
en_LR,"English (Liberia)"
|
||||||
|
en_MO,"English (Macau SAR China)"
|
||||||
|
en_MG,"English (Madagascar)"
|
||||||
|
en_MW,"English (Malawi)"
|
||||||
|
en_MY,"English (Malaysia)"
|
||||||
|
en_MT,"English (Malta)"
|
||||||
|
en_MH,"English (Marshall Islands)"
|
||||||
|
en_MU,"English (Mauritius)"
|
||||||
|
en_FM,"English (Micronesia)"
|
||||||
|
en_MS,"English (Montserrat)"
|
||||||
|
en_NA,"English (Namibia)"
|
||||||
|
en_NR,"English (Nauru)"
|
||||||
|
en_NZ,"English (New Zealand)"
|
||||||
|
en_NG,"English (Nigeria)"
|
||||||
|
en_NU,"English (Niue)"
|
||||||
|
en_NF,"English (Norfolk Island)"
|
||||||
|
en_MP,"English (Northern Mariana Islands)"
|
||||||
|
en_PK,"English (Pakistan)"
|
||||||
|
en_PW,"English (Palau)"
|
||||||
|
en_PG,"English (Papua New Guinea)"
|
||||||
|
en_PH,"English (Philippines)"
|
||||||
|
en_PN,"English (Pitcairn Islands)"
|
||||||
|
en_PR,"English (Puerto Rico)"
|
||||||
|
en_RW,"English (Rwanda)"
|
||||||
|
en_WS,"English (Samoa)"
|
||||||
|
en_SC,"English (Seychelles)"
|
||||||
|
en_SL,"English (Sierra Leone)"
|
||||||
|
en_SG,"English (Singapore)"
|
||||||
|
en_SX,"English (Sint Maarten)"
|
||||||
|
en_SB,"English (Solomon Islands)"
|
||||||
|
en_ZA,"English (South Africa)"
|
||||||
|
en_SS,"English (South Sudan)"
|
||||||
|
en_SH,"English (St. Helena)"
|
||||||
|
en_KN,"English (St. Kitts & Nevis)"
|
||||||
|
en_LC,"English (St. Lucia)"
|
||||||
|
en_VC,"English (St. Vincent & Grenadines)"
|
||||||
|
en_SD,"English (Sudan)"
|
||||||
|
en_SZ,"English (Swaziland)"
|
||||||
|
en_TZ,"English (Tanzania)"
|
||||||
|
en_TK,"English (Tokelau)"
|
||||||
|
en_TO,"English (Tonga)"
|
||||||
|
en_TT,"English (Trinidad & Tobago)"
|
||||||
|
en_TC,"English (Turks & Caicos Islands)"
|
||||||
|
en_TV,"English (Tuvalu)"
|
||||||
|
en_UM,"English (U.S. Outlying Islands)"
|
||||||
|
en_VI,"English (U.S. Virgin Islands)"
|
||||||
|
en_UG,"English (Uganda)"
|
||||||
|
en_GB,"English (United Kingdom)"
|
||||||
|
en_US,"English (United States)"
|
||||||
|
en_VU,"English (Vanuatu)"
|
||||||
|
en_ZM,"English (Zambia)"
|
||||||
|
en_ZW,"English (Zimbabwe)"
|
||||||
|
eo,Esperanto
|
||||||
|
et,Estonian
|
||||||
|
et_EE,"Estonian (Estonia)"
|
||||||
|
ee,Ewe
|
||||||
|
ee_GH,"Ewe (Ghana)"
|
||||||
|
ee_TG,"Ewe (Togo)"
|
||||||
|
fo,Faroese
|
||||||
|
fo_FO,"Faroese (Faroe Islands)"
|
||||||
|
fi,Finnish
|
||||||
|
fi_FI,"Finnish (Finland)"
|
||||||
|
fr,French
|
||||||
|
fr_DZ,"French (Algeria)"
|
||||||
|
fr_BE,"French (Belgium)"
|
||||||
|
fr_BJ,"French (Benin)"
|
||||||
|
fr_BF,"French (Burkina Faso)"
|
||||||
|
fr_BI,"French (Burundi)"
|
||||||
|
fr_CM,"French (Cameroon)"
|
||||||
|
fr_CA,"French (Canada)"
|
||||||
|
fr_CF,"French (Central African Republic)"
|
||||||
|
fr_TD,"French (Chad)"
|
||||||
|
fr_KM,"French (Comoros)"
|
||||||
|
fr_CG,"French (Congo - Brazzaville)"
|
||||||
|
fr_CD,"French (Congo - Kinshasa)"
|
||||||
|
fr_CI,"French (Côte d’Ivoire)"
|
||||||
|
fr_DJ,"French (Djibouti)"
|
||||||
|
fr_GQ,"French (Equatorial Guinea)"
|
||||||
|
fr_FR,"French (France)"
|
||||||
|
fr_GF,"French (French Guiana)"
|
||||||
|
fr_PF,"French (French Polynesia)"
|
||||||
|
fr_GA,"French (Gabon)"
|
||||||
|
fr_GP,"French (Guadeloupe)"
|
||||||
|
fr_GN,"French (Guinea)"
|
||||||
|
fr_HT,"French (Haiti)"
|
||||||
|
fr_LU,"French (Luxembourg)"
|
||||||
|
fr_MG,"French (Madagascar)"
|
||||||
|
fr_ML,"French (Mali)"
|
||||||
|
fr_MQ,"French (Martinique)"
|
||||||
|
fr_MR,"French (Mauritania)"
|
||||||
|
fr_MU,"French (Mauritius)"
|
||||||
|
fr_YT,"French (Mayotte)"
|
||||||
|
fr_MC,"French (Monaco)"
|
||||||
|
fr_MA,"French (Morocco)"
|
||||||
|
fr_NC,"French (New Caledonia)"
|
||||||
|
fr_NE,"French (Niger)"
|
||||||
|
fr_RE,"French (Réunion)"
|
||||||
|
fr_RW,"French (Rwanda)"
|
||||||
|
fr_SN,"French (Senegal)"
|
||||||
|
fr_SC,"French (Seychelles)"
|
||||||
|
fr_BL,"French (St. Barthélemy)"
|
||||||
|
fr_MF,"French (St. Martin)"
|
||||||
|
fr_PM,"French (St. Pierre & Miquelon)"
|
||||||
|
fr_CH,"French (Switzerland)"
|
||||||
|
fr_SY,"French (Syria)"
|
||||||
|
fr_TG,"French (Togo)"
|
||||||
|
fr_TN,"French (Tunisia)"
|
||||||
|
fr_VU,"French (Vanuatu)"
|
||||||
|
fr_WF,"French (Wallis & Futuna)"
|
||||||
|
ff,Fulah
|
||||||
|
ff_CM,"Fulah (Cameroon)"
|
||||||
|
ff_GN,"Fulah (Guinea)"
|
||||||
|
ff_MR,"Fulah (Mauritania)"
|
||||||
|
ff_SN,"Fulah (Senegal)"
|
||||||
|
gl,Galician
|
||||||
|
gl_ES,"Galician (Spain)"
|
||||||
|
lg,Ganda
|
||||||
|
lg_UG,"Ganda (Uganda)"
|
||||||
|
ka,Georgian
|
||||||
|
ka_GE,"Georgian (Georgia)"
|
||||||
|
de,German
|
||||||
|
de_AT,"German (Austria)"
|
||||||
|
de_BE,"German (Belgium)"
|
||||||
|
de_DE,"German (Germany)"
|
||||||
|
de_LI,"German (Liechtenstein)"
|
||||||
|
de_LU,"German (Luxembourg)"
|
||||||
|
de_CH,"German (Switzerland)"
|
||||||
|
el,Greek
|
||||||
|
el_CY,"Greek (Cyprus)"
|
||||||
|
el_GR,"Greek (Greece)"
|
||||||
|
gu,Gujarati
|
||||||
|
gu_IN,"Gujarati (India)"
|
||||||
|
ha,Hausa
|
||||||
|
ha_GH,"Hausa (Ghana)"
|
||||||
|
ha_Latn_GH,"Hausa (Latin, Ghana)"
|
||||||
|
ha_Latn_NE,"Hausa (Latin, Niger)"
|
||||||
|
ha_Latn_NG,"Hausa (Latin, Nigeria)"
|
||||||
|
ha_Latn,"Hausa (Latin)"
|
||||||
|
ha_NE,"Hausa (Niger)"
|
||||||
|
ha_NG,"Hausa (Nigeria)"
|
||||||
|
he,Hebrew
|
||||||
|
he_IL,"Hebrew (Israel)"
|
||||||
|
hi,Hindi
|
||||||
|
hi_IN,"Hindi (India)"
|
||||||
|
hu,Hungarian
|
||||||
|
hu_HU,"Hungarian (Hungary)"
|
||||||
|
is,Icelandic
|
||||||
|
is_IS,"Icelandic (Iceland)"
|
||||||
|
ig,Igbo
|
||||||
|
ig_NG,"Igbo (Nigeria)"
|
||||||
|
id,Indonesian
|
||||||
|
id_ID,"Indonesian (Indonesia)"
|
||||||
|
ga,Irish
|
||||||
|
ga_IE,"Irish (Ireland)"
|
||||||
|
it,Italian
|
||||||
|
it_IT,"Italian (Italy)"
|
||||||
|
it_SM,"Italian (San Marino)"
|
||||||
|
it_CH,"Italian (Switzerland)"
|
||||||
|
ja,Japanese
|
||||||
|
ja_JP,"Japanese (Japan)"
|
||||||
|
kl,Kalaallisut
|
||||||
|
kl_GL,"Kalaallisut (Greenland)"
|
||||||
|
kn,Kannada
|
||||||
|
kn_IN,"Kannada (India)"
|
||||||
|
ks,Kashmiri
|
||||||
|
ks_Arab_IN,"Kashmiri (Arabic, India)"
|
||||||
|
ks_Arab,"Kashmiri (Arabic)"
|
||||||
|
ks_IN,"Kashmiri (India)"
|
||||||
|
kk,Kazakh
|
||||||
|
kk_Cyrl_KZ,"Kazakh (Cyrillic, Kazakhstan)"
|
||||||
|
kk_Cyrl,"Kazakh (Cyrillic)"
|
||||||
|
kk_KZ,"Kazakh (Kazakhstan)"
|
||||||
|
km,Khmer
|
||||||
|
km_KH,"Khmer (Cambodia)"
|
||||||
|
ki,Kikuyu
|
||||||
|
ki_KE,"Kikuyu (Kenya)"
|
||||||
|
rw,Kinyarwanda
|
||||||
|
rw_RW,"Kinyarwanda (Rwanda)"
|
||||||
|
ko,Korean
|
||||||
|
ko_KP,"Korean (North Korea)"
|
||||||
|
ko_KR,"Korean (South Korea)"
|
||||||
|
ky,Kyrgyz
|
||||||
|
ky_Cyrl_KG,"Kyrgyz (Cyrillic, Kyrgyzstan)"
|
||||||
|
ky_Cyrl,"Kyrgyz (Cyrillic)"
|
||||||
|
ky_KG,"Kyrgyz (Kyrgyzstan)"
|
||||||
|
lo,Lao
|
||||||
|
lo_LA,"Lao (Laos)"
|
||||||
|
lv,Latvian
|
||||||
|
lv_LV,"Latvian (Latvia)"
|
||||||
|
ln,Lingala
|
||||||
|
ln_AO,"Lingala (Angola)"
|
||||||
|
ln_CF,"Lingala (Central African Republic)"
|
||||||
|
ln_CG,"Lingala (Congo - Brazzaville)"
|
||||||
|
ln_CD,"Lingala (Congo - Kinshasa)"
|
||||||
|
lt,Lithuanian
|
||||||
|
lt_LT,"Lithuanian (Lithuania)"
|
||||||
|
lu,Luba-Katanga
|
||||||
|
lu_CD,"Luba-Katanga (Congo - Kinshasa)"
|
||||||
|
lb,Luxembourgish
|
||||||
|
lb_LU,"Luxembourgish (Luxembourg)"
|
||||||
|
mk,Macedonian
|
||||||
|
mk_MK,"Macedonian (Macedonia)"
|
||||||
|
mg,Malagasy
|
||||||
|
mg_MG,"Malagasy (Madagascar)"
|
||||||
|
ms,Malay
|
||||||
|
ms_BN,"Malay (Brunei)"
|
||||||
|
ms_Latn_BN,"Malay (Latin, Brunei)"
|
||||||
|
ms_Latn_MY,"Malay (Latin, Malaysia)"
|
||||||
|
ms_Latn_SG,"Malay (Latin, Singapore)"
|
||||||
|
ms_Latn,"Malay (Latin)"
|
||||||
|
ms_MY,"Malay (Malaysia)"
|
||||||
|
ms_SG,"Malay (Singapore)"
|
||||||
|
ml,Malayalam
|
||||||
|
ml_IN,"Malayalam (India)"
|
||||||
|
mt,Maltese
|
||||||
|
mt_MT,"Maltese (Malta)"
|
||||||
|
gv,Manx
|
||||||
|
gv_IM,"Manx (Isle of Man)"
|
||||||
|
mr,Marathi
|
||||||
|
mr_IN,"Marathi (India)"
|
||||||
|
mn,Mongolian
|
||||||
|
mn_Cyrl_MN,"Mongolian (Cyrillic, Mongolia)"
|
||||||
|
mn_Cyrl,"Mongolian (Cyrillic)"
|
||||||
|
mn_MN,"Mongolian (Mongolia)"
|
||||||
|
ne,Nepali
|
||||||
|
ne_IN,"Nepali (India)"
|
||||||
|
ne_NP,"Nepali (Nepal)"
|
||||||
|
nd,"North Ndebele"
|
||||||
|
nd_ZW,"North Ndebele (Zimbabwe)"
|
||||||
|
se,"Northern Sami"
|
||||||
|
se_FI,"Northern Sami (Finland)"
|
||||||
|
se_NO,"Northern Sami (Norway)"
|
||||||
|
se_SE,"Northern Sami (Sweden)"
|
||||||
|
no,Norwegian
|
||||||
|
no_NO,"Norwegian (Norway)"
|
||||||
|
nb,"Norwegian Bokmål"
|
||||||
|
nb_NO,"Norwegian Bokmål (Norway)"
|
||||||
|
nb_SJ,"Norwegian Bokmål (Svalbard & Jan Mayen)"
|
||||||
|
nn,"Norwegian Nynorsk"
|
||||||
|
nn_NO,"Norwegian Nynorsk (Norway)"
|
||||||
|
or,Oriya
|
||||||
|
or_IN,"Oriya (India)"
|
||||||
|
om,Oromo
|
||||||
|
om_ET,"Oromo (Ethiopia)"
|
||||||
|
om_KE,"Oromo (Kenya)"
|
||||||
|
os,Ossetic
|
||||||
|
os_GE,"Ossetic (Georgia)"
|
||||||
|
os_RU,"Ossetic (Russia)"
|
||||||
|
ps,Pashto
|
||||||
|
ps_AF,"Pashto (Afghanistan)"
|
||||||
|
fa,Persian
|
||||||
|
fa_AF,"Persian (Afghanistan)"
|
||||||
|
fa_IR,"Persian (Iran)"
|
||||||
|
pl,Polish
|
||||||
|
pl_PL,"Polish (Poland)"
|
||||||
|
pt,Portuguese
|
||||||
|
pt_AO,"Portuguese (Angola)"
|
||||||
|
pt_BR,"Portuguese (Brazil)"
|
||||||
|
pt_CV,"Portuguese (Cape Verde)"
|
||||||
|
pt_GW,"Portuguese (Guinea-Bissau)"
|
||||||
|
pt_MO,"Portuguese (Macau SAR China)"
|
||||||
|
pt_MZ,"Portuguese (Mozambique)"
|
||||||
|
pt_PT,"Portuguese (Portugal)"
|
||||||
|
pt_ST,"Portuguese (São Tomé & Príncipe)"
|
||||||
|
pt_TL,"Portuguese (Timor-Leste)"
|
||||||
|
pa,Punjabi
|
||||||
|
pa_Arab_PK,"Punjabi (Arabic, Pakistan)"
|
||||||
|
pa_Arab,"Punjabi (Arabic)"
|
||||||
|
pa_Guru_IN,"Punjabi (Gurmukhi, India)"
|
||||||
|
pa_Guru,"Punjabi (Gurmukhi)"
|
||||||
|
pa_IN,"Punjabi (India)"
|
||||||
|
pa_PK,"Punjabi (Pakistan)"
|
||||||
|
qu,Quechua
|
||||||
|
qu_BO,"Quechua (Bolivia)"
|
||||||
|
qu_EC,"Quechua (Ecuador)"
|
||||||
|
qu_PE,"Quechua (Peru)"
|
||||||
|
ro,Romanian
|
||||||
|
ro_MD,"Romanian (Moldova)"
|
||||||
|
ro_RO,"Romanian (Romania)"
|
||||||
|
rm,Romansh
|
||||||
|
rm_CH,"Romansh (Switzerland)"
|
||||||
|
rn,Rundi
|
||||||
|
rn_BI,"Rundi (Burundi)"
|
||||||
|
ru,Russian
|
||||||
|
ru_BY,"Russian (Belarus)"
|
||||||
|
ru_KZ,"Russian (Kazakhstan)"
|
||||||
|
ru_KG,"Russian (Kyrgyzstan)"
|
||||||
|
ru_MD,"Russian (Moldova)"
|
||||||
|
ru_RU,"Russian (Russia)"
|
||||||
|
ru_UA,"Russian (Ukraine)"
|
||||||
|
sg,Sango
|
||||||
|
sg_CF,"Sango (Central African Republic)"
|
||||||
|
gd,"Scottish Gaelic"
|
||||||
|
gd_GB,"Scottish Gaelic (United Kingdom)"
|
||||||
|
sr,Serbian
|
||||||
|
sr_BA,"Serbian (Bosnia & Herzegovina)"
|
||||||
|
sr_Cyrl_BA,"Serbian (Cyrillic, Bosnia & Herzegovina)"
|
||||||
|
sr_Cyrl_XK,"Serbian (Cyrillic, Kosovo)"
|
||||||
|
sr_Cyrl_ME,"Serbian (Cyrillic, Montenegro)"
|
||||||
|
sr_Cyrl_RS,"Serbian (Cyrillic, Serbia)"
|
||||||
|
sr_Cyrl,"Serbian (Cyrillic)"
|
||||||
|
sr_XK,"Serbian (Kosovo)"
|
||||||
|
sr_Latn_BA,"Serbian (Latin, Bosnia & Herzegovina)"
|
||||||
|
sr_Latn_XK,"Serbian (Latin, Kosovo)"
|
||||||
|
sr_Latn_ME,"Serbian (Latin, Montenegro)"
|
||||||
|
sr_Latn_RS,"Serbian (Latin, Serbia)"
|
||||||
|
sr_Latn,"Serbian (Latin)"
|
||||||
|
sr_ME,"Serbian (Montenegro)"
|
||||||
|
sr_RS,"Serbian (Serbia)"
|
||||||
|
sh,Serbo-Croatian
|
||||||
|
sh_BA,"Serbo-Croatian (Bosnia & Herzegovina)"
|
||||||
|
sn,Shona
|
||||||
|
sn_ZW,"Shona (Zimbabwe)"
|
||||||
|
ii,"Sichuan Yi"
|
||||||
|
ii_CN,"Sichuan Yi (China)"
|
||||||
|
si,Sinhala
|
||||||
|
si_LK,"Sinhala (Sri Lanka)"
|
||||||
|
sk,Slovak
|
||||||
|
sk_SK,"Slovak (Slovakia)"
|
||||||
|
sl,Slovenian
|
||||||
|
sl_SI,"Slovenian (Slovenia)"
|
||||||
|
so,Somali
|
||||||
|
so_DJ,"Somali (Djibouti)"
|
||||||
|
so_ET,"Somali (Ethiopia)"
|
||||||
|
so_KE,"Somali (Kenya)"
|
||||||
|
so_SO,"Somali (Somalia)"
|
||||||
|
es,Spanish
|
||||||
|
es_AR,"Spanish (Argentina)"
|
||||||
|
es_BO,"Spanish (Bolivia)"
|
||||||
|
es_IC,"Spanish (Canary Islands)"
|
||||||
|
es_EA,"Spanish (Ceuta & Melilla)"
|
||||||
|
es_CL,"Spanish (Chile)"
|
||||||
|
es_CO,"Spanish (Colombia)"
|
||||||
|
es_CR,"Spanish (Costa Rica)"
|
||||||
|
es_CU,"Spanish (Cuba)"
|
||||||
|
es_DO,"Spanish (Dominican Republic)"
|
||||||
|
es_EC,"Spanish (Ecuador)"
|
||||||
|
es_SV,"Spanish (El Salvador)"
|
||||||
|
es_GQ,"Spanish (Equatorial Guinea)"
|
||||||
|
es_GT,"Spanish (Guatemala)"
|
||||||
|
es_HN,"Spanish (Honduras)"
|
||||||
|
es_MX,"Spanish (Mexico)"
|
||||||
|
es_NI,"Spanish (Nicaragua)"
|
||||||
|
es_PA,"Spanish (Panama)"
|
||||||
|
es_PY,"Spanish (Paraguay)"
|
||||||
|
es_PE,"Spanish (Peru)"
|
||||||
|
es_PH,"Spanish (Philippines)"
|
||||||
|
es_PR,"Spanish (Puerto Rico)"
|
||||||
|
es_ES,"Spanish (Spain)"
|
||||||
|
es_US,"Spanish (United States)"
|
||||||
|
es_UY,"Spanish (Uruguay)"
|
||||||
|
es_VE,"Spanish (Venezuela)"
|
||||||
|
sw,Swahili
|
||||||
|
sw_KE,"Swahili (Kenya)"
|
||||||
|
sw_TZ,"Swahili (Tanzania)"
|
||||||
|
sw_UG,"Swahili (Uganda)"
|
||||||
|
sv,Swedish
|
||||||
|
sv_AX,"Swedish (Åland Islands)"
|
||||||
|
sv_FI,"Swedish (Finland)"
|
||||||
|
sv_SE,"Swedish (Sweden)"
|
||||||
|
tl,Tagalog
|
||||||
|
tl_PH,"Tagalog (Philippines)"
|
||||||
|
ta,Tamil
|
||||||
|
ta_IN,"Tamil (India)"
|
||||||
|
ta_MY,"Tamil (Malaysia)"
|
||||||
|
ta_SG,"Tamil (Singapore)"
|
||||||
|
ta_LK,"Tamil (Sri Lanka)"
|
||||||
|
te,Telugu
|
||||||
|
te_IN,"Telugu (India)"
|
||||||
|
th,Thai
|
||||||
|
th_TH,"Thai (Thailand)"
|
||||||
|
bo,Tibetan
|
||||||
|
bo_CN,"Tibetan (China)"
|
||||||
|
bo_IN,"Tibetan (India)"
|
||||||
|
ti,Tigrinya
|
||||||
|
ti_ER,"Tigrinya (Eritrea)"
|
||||||
|
ti_ET,"Tigrinya (Ethiopia)"
|
||||||
|
to,Tongan
|
||||||
|
to_TO,"Tongan (Tonga)"
|
||||||
|
tr,Turkish
|
||||||
|
tr_CY,"Turkish (Cyprus)"
|
||||||
|
tr_TR,"Turkish (Turkey)"
|
||||||
|
uk,Ukrainian
|
||||||
|
uk_UA,"Ukrainian (Ukraine)"
|
||||||
|
ur,Urdu
|
||||||
|
ur_IN,"Urdu (India)"
|
||||||
|
ur_PK,"Urdu (Pakistan)"
|
||||||
|
ug,Uyghur
|
||||||
|
ug_Arab_CN,"Uyghur (Arabic, China)"
|
||||||
|
ug_Arab,"Uyghur (Arabic)"
|
||||||
|
ug_CN,"Uyghur (China)"
|
||||||
|
uz,Uzbek
|
||||||
|
uz_AF,"Uzbek (Afghanistan)"
|
||||||
|
uz_Arab_AF,"Uzbek (Arabic, Afghanistan)"
|
||||||
|
uz_Arab,"Uzbek (Arabic)"
|
||||||
|
uz_Cyrl_UZ,"Uzbek (Cyrillic, Uzbekistan)"
|
||||||
|
uz_Cyrl,"Uzbek (Cyrillic)"
|
||||||
|
uz_Latn_UZ,"Uzbek (Latin, Uzbekistan)"
|
||||||
|
uz_Latn,"Uzbek (Latin)"
|
||||||
|
uz_UZ,"Uzbek (Uzbekistan)"
|
||||||
|
vi,Vietnamese
|
||||||
|
vi_VN,"Vietnamese (Vietnam)"
|
||||||
|
cy,Welsh
|
||||||
|
cy_GB,"Welsh (United Kingdom)"
|
||||||
|
fy,"Western Frisian"
|
||||||
|
fy_NL,"Western Frisian (Netherlands)"
|
||||||
|
yi,Yiddish
|
||||||
|
yo,Yoruba
|
||||||
|
yo_BJ,"Yoruba (Benin)"
|
||||||
|
yo_NG,"Yoruba (Nigeria)"
|
||||||
|
zu,Zulu
|
||||||
|
zu_ZA,"Zulu (South Africa)"
|
||||||
|
|
|
@ -0,0 +1,139 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
Plugin Name: Multiple Domain
|
||||||
|
Plugin URI: https://github.com/straube/multiple-domain
|
||||||
|
Description: This plugin allows you to have multiple domains in a single WordPress installation and enables custom redirects for each domain.
|
||||||
|
Version: 1.0.7
|
||||||
|
Author: goINPUT IT Solutions
|
||||||
|
Author URI: http://goinput.de
|
||||||
|
License: GPLv2 or later
|
||||||
|
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
Text Domain: multiple-domain
|
||||||
|
Domain Path: /languages
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Loading classes.
|
||||||
|
*/
|
||||||
|
require 'MultipleDomain.php';
|
||||||
|
require 'MultipleDomainSettings.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The plugin file name.
|
||||||
|
*
|
||||||
|
* This is used mainly to set hooks and other features that requires the base
|
||||||
|
* plugin file name to work properly.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 0.8.3
|
||||||
|
*/
|
||||||
|
define('MULTIPLE_DOMAIN_PLUGIN', __FILE__);
|
||||||
|
|
||||||
|
if (!defined('MULTIPLE_DOMAIN_LOW_MEMORY')) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The low memory option.
|
||||||
|
*
|
||||||
|
* This option may be used where the site is throwing "allowed memory
|
||||||
|
* exhausted" errors. It will reduce the memory usage in domain replacements
|
||||||
|
* with the downside of a higher execution time.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @since 1.0.2
|
||||||
|
*/
|
||||||
|
define('MULTIPLE_DOMAIN_LOW_MEMORY', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Register the activation method.
|
||||||
|
*/
|
||||||
|
register_activation_hook(MULTIPLE_DOMAIN_PLUGIN, [ MultipleDomain::class, 'activate' ]);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bootstrap...
|
||||||
|
*/
|
||||||
|
$multipleDomain = MultipleDomain::instance();
|
||||||
|
$domain = $multipleDomain->getDomain();
|
||||||
|
$originalDomain = $multipleDomain->getOriginalDomain();
|
||||||
|
$domainLang = $multipleDomain->getDomainLang();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current domain.
|
||||||
|
*
|
||||||
|
* Since this value is checked against plugin settings, it may not reflect the
|
||||||
|
* actual domain in `HTTP_HOST` element from `$_SERVER`. It also may include
|
||||||
|
* the host port when it's different than 80 (default HTTP port) or 443
|
||||||
|
* (default HTTPS port).
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.2
|
||||||
|
*/
|
||||||
|
define('MULTIPLE_DOMAIN_DOMAIN', $domain);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The original domain set in WordPress installation.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.2
|
||||||
|
*/
|
||||||
|
define('MULTIPLE_DOMAIN_ORIGINAL_DOMAIN', $originalDomain);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current domain language.
|
||||||
|
*
|
||||||
|
* This value is the language associated with the current domain in the plugin
|
||||||
|
* settings. No check is made to verifiy if it reflects the actual user
|
||||||
|
* language or locale. Also, notice this constant may be `null` when no
|
||||||
|
* language is set in the plugin config.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.2
|
||||||
|
*/
|
||||||
|
define('MULTIPLE_DOMAIN_DOMAIN_LANG', $domainLang);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeping back compability with prior versions.
|
||||||
|
*
|
||||||
|
* This constant will be removed in a future release.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 0.2
|
||||||
|
* @see MULTIPLE_DOMAIN_DOMAIN
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
define('MULTPLE_DOMAIN_DOMAIN', MULTIPLE_DOMAIN_DOMAIN);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeping back compability with prior versions.
|
||||||
|
*
|
||||||
|
* This constant will be removed in a future release.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 0.3
|
||||||
|
* @see MULTIPLE_DOMAIN_ORIGINAL_DOMAIN
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
define('MULTPLE_DOMAIN_ORIGINAL_DOMAIN', MULTIPLE_DOMAIN_ORIGINAL_DOMAIN);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeping back compability with prior versions.
|
||||||
|
*
|
||||||
|
* This constant will be removed in a future release.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 0.8
|
||||||
|
* @see MULTIPLE_DOMAIN_DOMAIN_LANG
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
define('MULTPLE_DOMAIN_DOMAIN_LANG', MULTIPLE_DOMAIN_DOMAIN_LANG);
|
||||||
|
|
@ -0,0 +1,280 @@
|
||||||
|
=== Multiple Domain ===
|
||||||
|
Contributors: sirjavik, mrelliwood, goinput, GustavoStraube, cyberaleks, jffaria
|
||||||
|
Tags: multiple, domains, redirect
|
||||||
|
Requires at least: 4.0
|
||||||
|
Tested up to: 5.7
|
||||||
|
Stable tag: 1.0.7
|
||||||
|
License: GPLv2 or later
|
||||||
|
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
|
||||||
|
This plugin allows you to have multiple domains in a single Wordpress installation and enables custom redirects for each
|
||||||
|
domain.
|
||||||
|
|
||||||
|
== Description ==
|
||||||
|
|
||||||
|
Important: This plugin has a new maintainer. So the plugin will now be active developed again, and it's now part of [goINPUT](https://goinput.de).
|
||||||
|
|
||||||
|
Multiple Domain allows you having more than one domain in a single WordPress installation. This plugin doesn't support
|
||||||
|
more than one theme or advanced customizations for each domain. It's only intended to enable constant navigation under
|
||||||
|
many domains. For a more complex setup, there is
|
||||||
|
[WordPress Multisite (MU)](https://codex.wordpress.org/Create_A_Network).
|
||||||
|
|
||||||
|
When there is more than one domain set in your host, all links and resources will point to the default domain. This is
|
||||||
|
the default WordPress behavior. With Multiple Domain installed and properly configured, it'll update all link on the
|
||||||
|
fly. This way, the user navigation will be end-to-end under the same domain.
|
||||||
|
|
||||||
|
You can also set an optional base URL. If you want only a set of URL's available under a given domain, you can use this
|
||||||
|
restriction.
|
||||||
|
|
||||||
|
Additionally, a language can be set for each domain. The language will be used to add `<link>` tags with `hreflang`
|
||||||
|
attribute to document head. This is for SEO purposes.
|
||||||
|
|
||||||
|
== Installation ==
|
||||||
|
|
||||||
|
Follow the steps below to install the plugin:
|
||||||
|
|
||||||
|
1. Upload the plugin files to the `/wp-content/plugins/multiple-domain` directory, or install the plugin through the
|
||||||
|
WordPress plugins screen directly.
|
||||||
|
2. Activate the plugin through the 'Plugins' screen in WordPress.
|
||||||
|
3. Use the Settings -> General screen to configure your additional domains.
|
||||||
|
|
||||||
|
== Frequently Asked Questions ==
|
||||||
|
|
||||||
|
= How can I help the plugin development? =
|
||||||
|
|
||||||
|
Feel free to open a [pull request](https://github.com/goINPUT-IT-Solutions/multiple-domain/pulls) to address any of the
|
||||||
|
[issues](https://github.com/goINPUT-IT-Solutions/multiple-domain/issues) reported by the plugin users. In case you have questions
|
||||||
|
on how to fix or the best approach, start a discussion on the appropriate thread.
|
||||||
|
|
||||||
|
If you want to add a new feature, please [open an issue](https://github.com/goINPUT-IT-Solutions/multiple-domain/issues/new)
|
||||||
|
explaining the feature and how it would help the users before start writing your code.
|
||||||
|
|
||||||
|
**Donations**
|
||||||
|
|
||||||
|
If you find this plugin helpful, you can support the work involved buying me a coffee, beer or a Playstation 4 game.
|
||||||
|
You can send donations over PayPal to paypal@goinput.de.
|
||||||
|
|
||||||
|
= Does this plugin set extra domains within my host? =
|
||||||
|
|
||||||
|
No. You have to set additional domains, DNS, and everything else to use this plugin.
|
||||||
|
|
||||||
|
= Can I have a different theme/content/plugins for each domain? =
|
||||||
|
|
||||||
|
Nope. If you want a complex set up like this, you may be interested in WordPress Multisite. It's delivered with every
|
||||||
|
WordPress installation since 3.0, you can find more info here: https://codex.wordpress.org/Create_A_Network.
|
||||||
|
|
||||||
|
= There is a way to add domain based logic to my themes? =
|
||||||
|
|
||||||
|
Absolutely. You can use the `MULTIPLE_DOMAIN_DOMAIN` and `MULTIPLE_DOMAIN_ORIGINAL_DOMAIN` constants to get the current
|
||||||
|
and original domains. Just notice that since the value of the first one is checked against plugin settings, it may not
|
||||||
|
reflect the actual domain in `HTTP_HOST` element from `$_SERVER` or user's browser. They also may include the host port
|
||||||
|
when it's different than 80 (default HTTP port) or 443 (default HTTPS port).
|
||||||
|
|
||||||
|
**Notice**: in prior versions these constants were wrongly prefixed with `MULTPLE_`, missing the "I". The old constants
|
||||||
|
are now deprecated. They still available for backcompat but will be removed in future releases.
|
||||||
|
|
||||||
|
= Can I create a custom access restriction logic for each domain? =
|
||||||
|
|
||||||
|
Yes. You can use the `multiple_domain_redirect` action to do that. Please check
|
||||||
|
https://github.com/straube/multiple-domain/issues/2 for an example on how to do that.
|
||||||
|
|
||||||
|
= Can I get the language associated with the current domain? =
|
||||||
|
|
||||||
|
Yes. You can use the `MULTIPLE_DOMAIN_DOMAIN_LANG` constant to get the language associated with the current domain. Keep
|
||||||
|
in mind the value in this constant doesn't necessarily reflect the actual user language or locale. This is just the
|
||||||
|
language set in the plugin config. Also notice the language may be `null`.
|
||||||
|
|
||||||
|
**Notice**: in prior versions these constants were wrongly prefixed with `MULTPLE_`, missing the "I". The old constants
|
||||||
|
are now deprecated. They still available for backcompat but will be removed in future releases.
|
||||||
|
|
||||||
|
= Can I show the current domain in the content of posts or pages? =
|
||||||
|
|
||||||
|
Yes. There is a shortcode available for that. Just add `[multiple_domain]` to the post/page and it'll be replaced by
|
||||||
|
the current domain when viewing the content. You can write things like "Welcome to [multiple_domain]!", which would be
|
||||||
|
rendered as "Welcome to mydomain.com!".
|
||||||
|
|
||||||
|
= What domains should I add to the plugin setup? =
|
||||||
|
|
||||||
|
Any domain you're site is served from must be added to the plugin configuration. Even `www` variations and the original
|
||||||
|
domain where your WordPress was installed in must be added. You'll probably see some unexpected output when accessing
|
||||||
|
the site from a non-mapped domain.
|
||||||
|
|
||||||
|
= Can I disable `hreflang` tags output even for the original domain? =
|
||||||
|
|
||||||
|
Yes. You may notice that even if you don't set a language for any domain, you still get a default `hreflang` tag in
|
||||||
|
your page head. To disable this behavior, follow the instructions from
|
||||||
|
https://github.com/straube/multiple-domain/issues/51.
|
||||||
|
|
||||||
|
= I locked myself out, and what am I doing now? =
|
||||||
|
|
||||||
|
Under certain circumstances, in the case of a wrong configuration, you may not be able to log in to the admin area
|
||||||
|
and your page will be redirected. In this case, there are two ways to solve this.
|
||||||
|
|
||||||
|
1. Delete the plugin directory `wp-content/plugins/multiple-domain`. You should be able to do that from the hosting
|
||||||
|
panel, from an FTP client, or via SSH. The downside of this technique is that it won’t be possible to install the
|
||||||
|
plugin again since the configuration will still be in the database.
|
||||||
|
2. Remove the plugin configuration from the database using the following SQL query `DELETE FROM {YOUR-PREFIX}_options
|
||||||
|
WHERE option_name LIKE 'multiple-domain-%'`; (Remember to replace the prefix from your own table name). This can be
|
||||||
|
done from the hosting panel when PHPMyAdmin is available or using a MySQL client.
|
||||||
|
|
||||||
|
== Screenshots ==
|
||||||
|
|
||||||
|
== Changelog ==
|
||||||
|
|
||||||
|
= 1.0.7 =
|
||||||
|
* Changed the author to the new one.
|
||||||
|
* Tested suport for WP 5.7
|
||||||
|
|
||||||
|
= 1.0.6 =
|
||||||
|
|
||||||
|
* Fix URI generated for canonical tag.
|
||||||
|
|
||||||
|
= 1.0.5 =
|
||||||
|
|
||||||
|
* Fixed issue with system routes when a base path is defined.
|
||||||
|
|
||||||
|
= 1.0.4 =
|
||||||
|
|
||||||
|
* Fixed assertions in admin views.
|
||||||
|
|
||||||
|
= 1.0.3 =
|
||||||
|
|
||||||
|
* Fixed XSS vulnerability in canonical/alternate tags.
|
||||||
|
|
||||||
|
= 1.0.2 =
|
||||||
|
|
||||||
|
* Added low memory option. (Refer to https://github.com/straube/multiple-domain/issues/45 on how to enable it)
|
||||||
|
* Constants starting with `MULTPLE_` are now deprecated. They have a matching `MULTIPLE_` prefixed constant.
|
||||||
|
* Fixed constants starting with `MULTPLE_`, changed to `MULTIPLE`.
|
||||||
|
|
||||||
|
= 1.0.1 =
|
||||||
|
|
||||||
|
* Fixed issue with regex used in domain replacement.
|
||||||
|
|
||||||
|
= 1.0.0 =
|
||||||
|
|
||||||
|
* Locked out instructions to readme file.
|
||||||
|
* API to programmatically change the domains list.
|
||||||
|
* Don't add canonical link if settings are `false`.
|
||||||
|
|
||||||
|
= 0.11.2 =
|
||||||
|
|
||||||
|
* FAQ about removal of `hreflang` tags.
|
||||||
|
* Fixed bug in domain replacement when it contains a slash (the regex delimiter).
|
||||||
|
* Fixed issue in the domain replacement regex.
|
||||||
|
|
||||||
|
= 0.11.1 =
|
||||||
|
|
||||||
|
* Fixed URI validation when there is a domain's base restriction.
|
||||||
|
|
||||||
|
= 0.11.0 =
|
||||||
|
|
||||||
|
* Add CHANGELOG.md file.
|
||||||
|
* Added option to enable canonical tags.
|
||||||
|
* Added `%%multiple_domain%%` advanced variable for Yoast.
|
||||||
|
* Moved WordPress admin features to a separate class.
|
||||||
|
* Renamed hreflang related methods.
|
||||||
|
* Inline documentation review.
|
||||||
|
* Minor refactoring.
|
||||||
|
* Fixed issue with domain replacement.
|
||||||
|
|
||||||
|
= 0.10.3 =
|
||||||
|
|
||||||
|
* Added public method to retrieve a given (or current) domain base path: `getDomainBase($domain = null)`.
|
||||||
|
* Minor code refactoring.
|
||||||
|
|
||||||
|
= 0.10.2 =
|
||||||
|
|
||||||
|
* Fix minor notice message when loading the non-mapped original domain.
|
||||||
|
* Added FAQ about plugin settings and domains.
|
||||||
|
|
||||||
|
= 0.10.1 =
|
||||||
|
|
||||||
|
* Fix bug introduced in 0.10.0 with setups where the original domain is not present in the plugin settings.
|
||||||
|
|
||||||
|
= 0.10.0 =
|
||||||
|
|
||||||
|
* Fix #31: Don't add SSL when accessing via a Tor domain name
|
||||||
|
* Moved HTML to view files.
|
||||||
|
|
||||||
|
= 0.9.0 =
|
||||||
|
|
||||||
|
* Fixed bug in backward compatibility logic.
|
||||||
|
* Added a class to `<body>` tag containing the domain name (e.g. `multipled-domain-name-tld`) to allow front-end customizations.
|
||||||
|
|
||||||
|
= 0.8.7 =
|
||||||
|
|
||||||
|
* Loading Multiple Domain before other plugins to fix issue with paths.
|
||||||
|
* Fix #38: Missing locales on language list (this issue was reopened and now it's fixed)
|
||||||
|
* Refactored `initAttributes` method.
|
||||||
|
|
||||||
|
= 0.8.6 =
|
||||||
|
|
||||||
|
* Fix #39: Rolling back changes introduced in 0.8.4 and 0.8.5 regarding to avoid URL changes in the WP admin.
|
||||||
|
|
||||||
|
= 0.8.5 =
|
||||||
|
|
||||||
|
* Fixed an issue introduced in 0.8.4 that breaks the admin URLs.
|
||||||
|
* Fix #38: Missing locales on language list
|
||||||
|
* Add `[multiple_domain]` shortcode to show the current language.
|
||||||
|
|
||||||
|
= 0.8.4 =
|
||||||
|
|
||||||
|
* Fix: #36 Wrong host in URLs returned by the JSON API
|
||||||
|
* Using singleton pattern for main plugin class.
|
||||||
|
* Avoiding URL changes in the admin panel.
|
||||||
|
|
||||||
|
= 0.8.3 =
|
||||||
|
|
||||||
|
* Fix: #34 hreflang tag error
|
||||||
|
|
||||||
|
= 0.8.2 =
|
||||||
|
|
||||||
|
* Fix: #32 Image URLs not being re-written properly via Tor.
|
||||||
|
|
||||||
|
= 0.8.1 =
|
||||||
|
|
||||||
|
* Fix: #23 Undefined index when using wp-cli.
|
||||||
|
|
||||||
|
= 0.8.0 =
|
||||||
|
|
||||||
|
* Moved `MultipleDomain` class to its own file.
|
||||||
|
* Fix: #14 Remove `filter_input` from plugin.
|
||||||
|
* Attempt to fix #22.
|
||||||
|
* Added `MULTIPLE_DOMAIN_DOMAIN_LANG` constant for theme/plugin customization.
|
||||||
|
* Fix: #21 No 'Access-Control-Allow-Origin' header is present on the requested resource
|
||||||
|
|
||||||
|
= 0.7.1 =
|
||||||
|
* Make the plugin compatible with PHP 5.4 again.
|
||||||
|
|
||||||
|
= 0.7 =
|
||||||
|
* Code review/refactoring.
|
||||||
|
* Added activation hook to fix empty settings bug.
|
||||||
|
|
||||||
|
= 0.6 =
|
||||||
|
* Fix: #11 Redirect to original domain if SSL/https.
|
||||||
|
|
||||||
|
= 0.5 =
|
||||||
|
* Added http/https for alternate link.
|
||||||
|
|
||||||
|
= 0.4 =
|
||||||
|
* Fixed resolving host name to boolean.
|
||||||
|
* Added Reflang links to head for SEO purpose. E.g.
|
||||||
|
`<link rel="alternate" hreflang="x-default" href="https://example.com/">`
|
||||||
|
`<link rel="alternate" hreflang="de-DE" href="https://de.example.com/">`
|
||||||
|
|
||||||
|
= 0.3 =
|
||||||
|
* Fixed bug when removing the port from current domain.
|
||||||
|
* Added `MULTIPLE_DOMAIN_ORIGINAL_DOMAIN` constant to hold the original WP home domain.
|
||||||
|
* Allowing developers to create custom URL restriction logic through `multiple_domain_redirect` action.
|
||||||
|
* Improved settings interface.
|
||||||
|
|
||||||
|
= 0.2 =
|
||||||
|
* Improved port verification.
|
||||||
|
* Added `MULTIPLE_DOMAIN_DOMAIN` constant for theme/plugin customization.
|
||||||
|
* And, last but not least, code refactoring.
|
||||||
|
|
||||||
|
= 0.1 =
|
||||||
|
This is the first release. It supports setting domains and an optional base URL for each one.
|
||||||
|
|
||||||
|
== Upgrade Notice ==
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
(function ($) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var $d = $(document);
|
||||||
|
var count = null;
|
||||||
|
|
||||||
|
$d.on('click', '.multiple-domain-remove', function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
$(this).parent().remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
$d.on('click', '.multiple-domain-add', function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
if (count === null) {
|
||||||
|
count = $('.multiple-domain-domain').length;
|
||||||
|
}
|
||||||
|
$(this).parent().before(multipleDomainFields.replace(/COUNT/g, count++));
|
||||||
|
});
|
||||||
|
|
||||||
|
})(jQuery);
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Making sure the required vars are set.
|
||||||
|
*/
|
||||||
|
assert(isset($fields) && isset($fieldsToAdd));
|
||||||
|
|
||||||
|
?><?php echo $fields; ?>
|
||||||
|
<p>
|
||||||
|
<button type="button" class="button multiple-domain-add">
|
||||||
|
<?php _e('Add domain', 'multiple-domain'); ?>
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
<p class="description">
|
||||||
|
<?php _e(
|
||||||
|
'A domain may contain the port number. '
|
||||||
|
. 'If a base URL restriction is set for a domain, '
|
||||||
|
. 'all requests that don\'t start with the base URL will be redirected to the base URL. '
|
||||||
|
. '<b>Example</b>: the domain and base URL are <code>example.com</code> and <code>/base/path</code>, '
|
||||||
|
. 'when requesting <code>example.com/other/path</code> it will be redirected to '
|
||||||
|
. '<code>example.com/base/path</code>. '
|
||||||
|
. 'Additionaly, it\'s possible to set a language for each domain, which will be used to add '
|
||||||
|
. '<code><link></code> tags with a <code>hreflang</code> attribute to the document head.',
|
||||||
|
'multiple-domain'
|
||||||
|
); ?>
|
||||||
|
</p>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var multipleDomainFields = <?php echo json_encode($fieldsToAdd); ?>;
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Making sure the required vars are set.
|
||||||
|
*/
|
||||||
|
assert(isset($count) && isset($protocol) && isset($host) && isset($base) && isset($langField));
|
||||||
|
|
||||||
|
?><p class="multiple-domain-domain">
|
||||||
|
<select
|
||||||
|
name="multiple-domain-domains[<?php echo $count; ?>][protocol]"
|
||||||
|
title="<?php _e('Protocol', 'multiple-domain'); ?>"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
value="auto"
|
||||||
|
<?php if (empty($protocol) || $protocol === 'auto') : ?>
|
||||||
|
selected
|
||||||
|
<?php endif; ?>
|
||||||
|
>Auto</option>
|
||||||
|
<option
|
||||||
|
value="http"
|
||||||
|
<?php if ($protocol === 'http') : ?>
|
||||||
|
selected
|
||||||
|
<?php endif; ?>
|
||||||
|
>http://</option>
|
||||||
|
<option
|
||||||
|
value="https"
|
||||||
|
<?php if ($protocol === 'https') : ?>
|
||||||
|
selected
|
||||||
|
<?php endif; ?>
|
||||||
|
>https://</option>
|
||||||
|
</select>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="multiple-domain-domains[<?php echo $count; ?>][host]"
|
||||||
|
value="<?php echo $host ?: ''; ?>"
|
||||||
|
class="regular-text code"
|
||||||
|
placeholder="example.com"
|
||||||
|
title="<?php _e('Domain', 'multiple-domain'); ?>"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="multiple-domain-domains[<?php echo $count; ?>][base]"
|
||||||
|
value="<?php echo $base ?: ''; ?>"
|
||||||
|
class="regular-text code"
|
||||||
|
placeholder="/base/path" title="<?php _e('Base path restriction', 'multiple-domain'); ?>"
|
||||||
|
>
|
||||||
|
<?php echo $langField; ?>
|
||||||
|
<button type="button" class="button multiple-domain-remove">
|
||||||
|
<span class="required"><?php _e('Remove', 'multiple-domain'); ?></span>
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
<p id="multiple-domain">
|
||||||
|
<?php _e('You can use multiple domains in your WordPress defining them below. '
|
||||||
|
. 'It\'s possible to limit the access for each domain to a base URL.', 'multiple-domain'); ?>
|
||||||
|
</p>
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Making sure the required vars are set.
|
||||||
|
*/
|
||||||
|
assert(isset($count) && isset($locales) && isset($lang));
|
||||||
|
|
||||||
|
?><select name="multiple-domain-domains[<?php echo $count; ?>][lang]">
|
||||||
|
<option value=""><?php _e('None', 'multiple-domain'); ?></option>
|
||||||
|
<option value="" disabled="disabled">--</option>
|
||||||
|
<?php foreach ($locales as $code => $name) : ?>
|
||||||
|
<option
|
||||||
|
value="<?php echo esc_attr($code); ?>"
|
||||||
|
<?php if ($lang === $code) : ?>
|
||||||
|
selected
|
||||||
|
<?php endif; ?>
|
||||||
|
><?php echo $name; ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Making sure the required vars are set.
|
||||||
|
*/
|
||||||
|
assert(isset($ignoreDefaultPorts) && isset($addCanonical));
|
||||||
|
|
||||||
|
?><label>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="multiple-domain-ignore-default-ports"
|
||||||
|
value="1"
|
||||||
|
<?php if ($ignoreDefaultPorts) : ?>
|
||||||
|
checked
|
||||||
|
<?php endif; ?>
|
||||||
|
>
|
||||||
|
<?php _e('Ignore default ports', 'multiple-domain'); ?>
|
||||||
|
</label>
|
||||||
|
<p class="description">
|
||||||
|
<?php _e('When enabled, removes the port from URL when redirecting and it\'s a '
|
||||||
|
. 'default HTTP (<code>80</code>) or HTTPS (<code>443</code>) port.', 'multiple-domain'); ?>
|
||||||
|
</p>
|
||||||
|
<br />
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="multiple-domain-add-canonical"
|
||||||
|
value="1"
|
||||||
|
<?php if ($addCanonical) : ?>
|
||||||
|
checked
|
||||||
|
<?php endif; ?>
|
||||||
|
>
|
||||||
|
<?php _e('Add canonical links', 'multiple-domain'); ?>
|
||||||
|
</label>
|
||||||
|
<p class="description">
|
||||||
|
<?php _e(
|
||||||
|
'When enabled, adds canonical link tags to pages. '
|
||||||
|
. 'The domain for canonical links will be the original domain where WordPress is installed. '
|
||||||
|
. 'You may want to keep this option unchecked if you have a SEO plugin (e.g. Yoast) installed.',
|
||||||
|
'multiple-domain'
|
||||||
|
); ?>
|
||||||
|
</p>
|
||||||
|
After Width: | Height: | Size: 8.5 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 8.6 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 8.8 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 7.9 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 363 KiB |
|
After Width: | Height: | Size: 132 KiB |
|
After Width: | Height: | Size: 552 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
|
After Width: | Height: | Size: 9.8 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
|
After Width: | Height: | Size: 9.8 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 8.7 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 35 KiB |