| Server IP : 27.254.66.5 / Your IP : 216.73.217.39 Web Server : Apache/2 System : Linux cs82.hostneverdie.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 User : technic2 ( 1951) PHP Version : 7.4.30 Disable Function : apache_child_terminate, apache_setenv, define_syslog_variables, escapeshellarg, escapeshellcmd,exec, fp, fput, highlight_file, ini_alter, ini_restore, inject_code, passthru,phpAds_remoteInfo, phpAds_XmlRpc,phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid,posix_setuid, posix_setuid, posix_uname,proc_open,proc_close, proc_get_status, proc_nice, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode, show_source,sleep,pcntl_exec,virtual,suexec,dbmopen,dl,symlink,disk_free_space,diskfreespace,leak MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/technic2/public_html/old-website/wp-content/plugins/polylang/include/ |
Upload File : |
<?php
/**
* Links model abstract class
*
* @since 1.5
*/
abstract class PLL_Links_Model {
public $model, $options;
public $home; // used to store the home url before it is filtered
public $using_permalinks;
/**
* Constructor
*
* @since 1.5
*
* @param object $model PLL_Model instance
*/
public function __construct( &$model ) {
$this->model = &$model;
$this->options = &$model->options;
$this->home = home_url();
add_filter( 'pll_languages_list', array( $this, 'pll_languages_list' ), 4 ); // after PLL_Static_Pages
add_filter( 'pll_after_languages_cache', array( $this, 'pll_after_languages_cache' ) );
// adds our domains or subdomains to allowed hosts for safe redirection
add_filter( 'allowed_redirect_hosts', array( $this, 'allowed_redirect_hosts' ) );
}
/**
* Changes the language code in url
*
* @since 1.5
*
* @param string $url url to modify
* @param object $lang language
* @return string modified url
*/
public function switch_language_in_link( $url, $lang ) {
$url = $this->remove_language_from_link( $url );
return $this->add_language_to_link( $url, $lang );
}
/**
* Get hosts managed on the website
*
* @since 1.5
*
* @return array list of hosts
*/
public function get_hosts() {
return array( parse_url( $this->home, PHP_URL_HOST ) );
}
/**
* Returns the home url
*
* @since 1.3.1
*
* @param object $lang PLL_Language object
* @return string
*/
public function home_url( $lang ) {
$url = trailingslashit( $this->home );
return $this->options['hide_default'] && $lang->slug == $this->options['default_lang'] ? $url : $this->add_language_to_link( $url, $lang );
}
/**
* Sets the home urls
*
* @since 1.8
*
* @param object $language
*/
protected function set_home_url( $language ) {
$search_url = $this->home_url( $language );
$home_url = empty( $language->page_on_front ) || $this->options['redirect_lang'] ? $search_url : $this->front_page_url( $language );
$language->set_home_url( $search_url, $home_url );
}
/**
* Sets the home urls and flags before the languages are persistently cached
*
* @since 1.8
*
* @param array $languages array of PLL_Language objects
* @return array
*/
public function pll_languages_list( $languages ) {
foreach ( $languages as $language ) {
$this->set_home_url( $language );
$language->set_flag();
}
return $languages;
}
/**
* Sets the home urls when not cached
* Sets the home urls scheme
*
* @since 1.8
*
* @param array $languages array of PLL_Language objects
* @return array
*/
public function pll_after_languages_cache( $languages ) {
foreach ( $languages as $language ) {
// Get the home urls when not cached
if ( ( defined( 'PLL_CACHE_LANGUAGES' ) && ! PLL_CACHE_LANGUAGES ) || ( defined( 'PLL_CACHE_HOME_URL' ) && ! PLL_CACHE_HOME_URL ) ) {
$this->set_home_url( $language );
}
// Ensures that the ( possibly cached ) home url uses the right scheme http or https
$language->set_home_url_scheme();
}
return $languages;
}
/**
* Adds our domains or subdomains to allowed hosts for safe redirection
*
* @since 1.4.3
*
* @param array $hosts allowed hosts
* @return array
*/
public function allowed_redirect_hosts( $hosts ) {
return array_unique( array_merge( $hosts, array_values( $this->get_hosts() ) ) );
}
}