| 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
/**
* Base class to manage the static front page and the page for posts
*
* @since 1.8
*/
abstract class PLL_Static_Pages {
public $model, $options;
public $page_on_front, $page_for_posts;
/**
* Constructor: setups filters and actions
*
* @since 1.8
*
* @param object $polylang
*/
public function __construct( &$polylang ) {
$this->model = &$polylang->model;
$this->options = &$polylang->options;
$this->curlang = &$polylang->curlang;
$this->init();
// Modifies the page link in case the front page is not in the default language
add_filter( 'page_link', array( $this, 'page_link' ), 20, 2 );
// Clean the languages cache when editing page of front, page for posts
add_action( 'update_option_show_on_front', array( $this->model, 'clean_languages_cache' ) );
add_action( 'update_option_page_on_front', array( $this->model, 'clean_languages_cache' ) );
add_action( 'update_option_page_for_posts', array( $this->model, 'clean_languages_cache' ) );
// Refresh rewrite rules when the page on front is modified
add_action( 'update_option_page_on_front', 'flush_rewrite_rules' );
}
/**
* Stores the page on front and page for posts ids
*
* @since 1.8
*/
public function init() {
if ( 'page' == get_option( 'show_on_front' ) ) {
$this->page_on_front = get_option( 'page_on_front' );
$this->page_for_posts = get_option( 'page_for_posts' );
}
else {
$this->page_on_front = 0;
$this->page_for_posts = 0;
}
}
/**
* Modifies the page link in case the front page is not in the default language
*
* @since 0.7.2
*
* @param string $link link to the page
* @param int $id post id of the page
* @return string modified link
*/
public function page_link( $link, $id ) {
if ( ( $lang = $this->model->post->get_language( $id ) ) && $id == $lang->page_on_front ) {
return $lang->home_url;
}
return $link;
}
/**
* Adds page_on_front and page_for_posts properties to the language objects
*
* @since 1.8
*
* @param array $languages
* @param object $model
*/
public static function pll_languages_list( $languages, $model ) {
if ( 'page' === get_option( 'show_on_front' ) ) {
foreach ( $languages as $k => $language ) {
$languages[ $k ]->page_on_front = $model->post->get( get_option( 'page_on_front' ), $language );
$languages[ $k ]->page_for_posts = $model->post->get( get_option( 'page_for_posts' ), $language );
}
}
return $languages;
}
/**
* Translates page for posts
*
* @since 1.8
*
* @param int $v page for posts page id
* @return int
*/
public function translate_page_for_posts( $v ) {
// Don't attempt to translate in a 'switch_blog' action as there is a risk to call this function while initializing the languages cache
return isset( $this->curlang->page_for_posts ) && ! doing_action( 'switch_blog' ) ? $this->curlang->page_for_posts : $v;
}
}