| 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/modules/plugins/ |
Upload File : |
<?php
/**
* A class to manage specific compatibility issue with cache plugins
* Tested with WP Rocket 2.10.7
*
* @since 2.3
*/
class PLL_Cache_Compat {
/**
* Setups actions
*
* @since 2.3
*/
public function init() {
if ( PLL_COOKIE ) {
add_action( 'wp_print_footer_scripts', array( $this, 'add_cookie_script' ) );
}
// Since version 3.0.5, WP Rocket does not serve the cached page if our cookie is not set
if ( ! defined( 'WP_ROCKET_VERSION' ) || version_compare( WP_ROCKET_VERSION, '3.0.5', '<' ) ) {
add_action( 'wp', array( $this, 'do_not_cache_site_home' ) );
}
}
/**
* Currently all tested cache plugins don't send cookies with cached pages
* This makes us impossible know the language of the last browsed page
* This functions allows to create the cookie in javascript as a workaround
*
* @since 2.3
*/
public function add_cookie_script() {
$domain = ( 2 == PLL()->options['force_lang'] ) ? parse_url( PLL()->links_model->home, PHP_URL_HOST ) : COOKIE_DOMAIN;
$js = sprintf( '
(function() {
var expirationDate = new Date();
expirationDate.setTime( expirationDate.getTime() + %d * 1000 );
document.cookie = "%s=%s; expires=" + expirationDate.toUTCString() + "; path=%s%s";
}());',
esc_js( apply_filters( 'pll_cookie_expiration', YEAR_IN_SECONDS ) ),
esc_js( PLL_COOKIE ),
esc_js( pll_current_language() ),
esc_js( COOKIEPATH ),
$domain ? '; domain=' . esc_js( $domain ) : ''
);
echo '<script type="text/javascript">' . $js . '</script>';
}
/**
* Informs cache plugins not to cache the home in the default language
* When the detection of the browser preferred language is active
*
* @since 2.3
*/
public function do_not_cache_site_home() {
if ( ! defined( 'DONOTCACHEPAGE' ) && PLL()->options['browser'] && PLL()->options['hide_default'] && is_front_page() && pll_current_language() === pll_default_language() ) {
define( 'DONOTCACHEPAGE', true );
}
}
}