| Server IP : 89.39.208.18 / Your IP : 216.73.217.74 Web Server : LiteSpeed System : User : ( ) PHP Version : 7.4.33 Disable Function : eval,./,ln,passthru,dl,system,exec,popen,shell_exec,posix_getpwuid,posix_uname,ftp_exec,posix_uname,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,get_current_user,getmyuid,getmygid,listen,chgrp,apache_note,apache_setenv,apache_child_terminate,closelog,debugger_off,debugge_on,ini_restore,netscript,escapeshellarg,cmd,backtick,virtual,show_sourc,show_source,pclose,pcntl_exec,datasec,old_offset,ctrl_dir,ini_alter,leak,listen,chgrp,apache_setenv,define_syslog_variables,root,diskfreespace,disk_free_space,disk_total_space,posix_kill,getmyuid,getmygid,apache_child_terminate,php_ini_scanned_files,ls,ps_aux,chown,getrusage,posixc,posame,chgrp,posix_setuid,posix_setsid,posix_setgid,apache_note,apache_setenv,x_getuid,e_ini_file,nfo,SQL,mysql_li,t_dbs,filegroup,highlight_file,ilegetcontents,get_dir,popen,popens,pfsockopen,dos_conv,apache_get_modules,crack_check,crack_closedict,rar_open,bzopen,bzread,bzwrite,shellcode,posix_isatty,posix_getservbyname,escapeshellarg,hypot,pg_host,pos,posix_access,inurl,posix_times,posix_mknod,pclose,ps_fill,symlink,id,escapeshellcmd,php_uname,phpinfo MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home3/mahyarcake/./././././www/wp-content/plugins/polylang/include/ |
Upload File : |
<?php
/**
* @package Polylang
*/
/**
* Main Polylang class for REST API requests, accessible from @see PLL().
*
* @since 2.6
*/
class PLL_REST_Request extends PLL_Base {
/**
* @var PLL_Language|false|null A `PLL_Language` when defined, `false` otherwise. `null` until the language
* definition process runs.
*/
public $curlang;
/**
* @var PLL_Filters|null
*/
public $filters;
/**
* @var PLL_Filters_Links|null
*/
public $filters_links;
/**
* @var PLL_Admin_Links|null
*/
public $links;
/**
* @var PLL_Nav_Menu|null
*/
public $nav_menu;
/**
* @var PLL_Static_Pages|null
*/
public $static_pages;
/**
* @var PLL_Filters_Widgets_Options|null
*/
public $filters_widgets_options;
/**
* Constructor.
*
* @since 3.4
*
* @param PLL_Links_Model $links_model Reference to the links model.
*/
public function __construct( &$links_model ) {
parent::__construct( $links_model );
// Static front page and page for posts.
// Early instantiated to be able to correctly initialize language properties.
if ( 'page' === get_option( 'show_on_front' ) ) {
$this->static_pages = new PLL_Static_Pages( $this );
}
$this->model->set_languages_ready();
}
/**
* Setup filters.
*
* @since 2.6
*
* @return void
*/
public function init() {
parent::init();
if ( ! $this->model->has_languages() ) {
return;
}
add_filter( 'rest_pre_dispatch', array( $this, 'set_language' ), 10, 3 );
$this->filters_links = new PLL_Filters_Links( $this );
$this->filters = new PLL_Filters( $this );
$this->filters_widgets_options = new PLL_Filters_Widgets_Options( $this );
$this->links = new PLL_Admin_Links( $this );
$this->nav_menu = new PLL_Frontend_Nav_Menu( $this ); // For auto added pages to menu.
}
/**
* Sets the current language during a REST request if sent.
*
* @since 3.3
*
* @param mixed $result Response to replace the requested version with. Remains untouched.
* @param WP_REST_Server $server Server instance.
* @param WP_REST_Request $request Request used to generate the response.
* @return mixed Untouched $result.
*
* @phpstan-param WP_REST_Request<array{lang?: string}> $request
*/
public function set_language( $result, $server, $request ) {
$lang = $request->get_param( 'lang' );
if ( ! empty( $lang ) && is_string( $lang ) ) {
$this->curlang = $this->model->get_language( sanitize_key( $lang ) );
if ( empty( $this->curlang ) && ! empty( $this->options['default_lang'] ) && is_string( $this->options['default_lang'] ) ) {
// A lang has been requested but it is invalid, let's fall back to the default one.
$this->curlang = $this->model->get_language( sanitize_key( $this->options['default_lang'] ) );
}
}
if ( ! empty( $this->curlang ) ) {
/** This action is documented in frontend/choose-lang.php */
do_action( 'pll_language_defined', $this->curlang->slug, $this->curlang );
} else {
/** This action is documented in include/class-polylang.php */
do_action( 'pll_no_language_defined' ); // To load overridden textdomains.
}
return $result;
}
}