/
var
/
www
/
leolaart.com
/
www
/
wp-content
/
plugins
/
polylang
/
include
/
/var/www/leolaart.com/www/wp-content/plugins/polylang/include
mkdir
upload
Name
Size
Mode
Actions
api.php
17763
0666
edit
dl
rm
base.php
5932
0666
edit
dl
rm
cache.php
2503
0666
edit
dl
rm
class-polylang.php
8759
0666
edit
dl
rm
cookie.php
3433
0666
edit
dl
rm
crud-posts.php
15511
0666
edit
dl
rm
crud-terms.php
10105
0666
edit
dl
rm
db-tools.php
1038
0666
edit
dl
rm
filter-rest-routes.php
4988
0666
edit
dl
rm
filters-links.php
5686
0666
edit
dl
rm
filters-sanitization.php
3311
0666
edit
dl
rm
filters-widgets-options.php
2634
0666
edit
dl
rm
filters.php
15752
0666
edit
dl
rm
functions.php
7173
0666
edit
dl
rm
language-deprecated.php
7355
0666
edit
dl
rm
language-factory.php
9535
0666
edit
dl
rm
language.php
18470
0666
edit
dl
rm
license.php
9415
0666
edit
dl
rm
links-abstract-domain.php
3240
0666
edit
dl
rm
links-default.php
3100
0666
edit
dl
rm
links-directory.php
9721
0666
edit
dl
rm
links-domain.php
3136
0666
edit
dl
rm
links-model.php
6639
0666
edit
dl
rm
links-permalinks.php
5753
0666
edit
dl
rm
links-subdomain.php
2216
0666
edit
dl
rm
links.php
1331
0666
edit
dl
rm
mo.php
2020
0666
edit
dl
rm
model.php
34651
0666
edit
dl
rm
nav-menu.php
4533
0666
edit
dl
rm
olt-manager.php
8567
0666
edit
dl
rm
query.php
6544
0666
edit
dl
rm
rest-request.php
3194
0666
edit
dl
rm
static-pages.php
6415
0666
edit
dl
rm
switcher.php
11151
0666
edit
dl
rm
translatable-object-with-types-interface.php
1127
0666
edit
dl
rm
translatable-object-with-types-trait.php
1936
0666
edit
dl
rm
translatable-object.php
13593
0666
edit
dl
rm
translatable-objects.php
3569
0666
edit
dl
rm
translate-option.php
12759
0666
edit
dl
rm
translated-object.php
16786
0666
edit
dl
rm
translated-post.php
11964
0666
edit
dl
rm
translated-term.php
10008
0666
edit
dl
rm
walker-dropdown.php
3538
0666
edit
dl
rm
walker-list.php
2308
0666
edit
dl
rm
walker.php
2336
0666
edit
dl
rm
widget-calendar.php
9667
0666
edit
dl
rm
widget-languages.php
4678
0666
edit
dl
rm
Edit:
/var/www/leolaart.com/www/wp-content/plugins/polylang/include/static-pages.php
(6415B)
<?php /** * @package Polylang */ /** * Base class to manage the static front page and the page for posts. * * @since 1.8 */ class PLL_Static_Pages { /** * Id of the page on front. * * @var int */ public $page_on_front = 0; /** * Id of the page for posts. * * @var int */ public $page_for_posts = 0; /** * @var PLL_Model */ protected $model; /** * Current language. * * @var PLL_Language|null */ protected $curlang; /** * Constructor: setups filters and actions. * * @since 1.8 * * @param object $polylang The Polylang object. */ public function __construct( &$polylang ) { $this->model = &$polylang->model; $this->curlang = &$polylang->curlang; $this->init(); add_filter( 'pll_additional_language_data', array( $this, 'set_static_pages' ), 5, 2 ); // Before PLL_Links_Model. // Clean the languages cache when editing page of front, page for posts. add_action( 'update_option_show_on_front', array( $this, 'clean_cache' ) ); add_action( 'update_option_page_on_front', array( $this, 'clean_cache' ) ); add_action( 'update_option_page_for_posts', array( $this, 'clean_cache' ) ); // Refresh rewrite rules when the page on front is modified. add_action( 'update_option_page_on_front', 'flush_rewrite_rules' ); // Add option filters when the current language is defined add_action( 'pll_language_defined', array( $this, 'pll_language_defined' ) ); // 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 ); // OEmbed. add_filter( 'oembed_request_post_id', array( $this, 'oembed_request_post_id' ), 10, 2 ); } /** * Stores the page on front and page for posts ids. * * @since 1.8 * * @return void */ public function init() { $this->page_on_front = 0; $this->page_for_posts = 0; if ( 'page' !== get_option( 'show_on_front' ) ) { return; } $page_on_front = get_option( 'page_on_front' ); if ( is_numeric( $page_on_front ) ) { $this->page_on_front = (int) $page_on_front; } $page_for_posts = get_option( 'page_for_posts' ); if ( is_numeric( $page_for_posts ) ) { $this->page_for_posts = (int) $page_for_posts; } } /** * Returns the ID of the static page translation. * * @since 3.4 * * @param string $static_page Static page option name; `page_on_front` or `page_for_posts`. * @param array $language Language data. * @return int */ protected function get_translation( $static_page, $language ) { $translations = $this->model->post->get_raw_translations( $this->$static_page ); // When the current static page doesn't have any translation, we must return itself for its language. if ( empty( $translations ) ) { $page_lang = $this->model->post->get_object_term( $this->$static_page, $this->model->post->get_tax_language() ); if ( ! empty( $page_lang ) && $page_lang->slug === $language['slug'] ) { return $this->$static_page; } } if ( ! isset( $translations[ $language['slug'] ] ) ) { return 0; } return $translations[ $language['slug'] ]; } /** * Adds `page_on_front` and `page_for_posts` properties to language data before the object is created. * * @since 3.4 * * @param array $additional_data Array of language additional data. * @param array $language Language data. * @return array Language data with additional `page_on_front` and `page_for_posts` options added. */ public function set_static_pages( $additional_data, $language ) { $additional_data['page_on_front'] = $this->get_translation( 'page_on_front', $language ); $additional_data['page_for_posts'] = $this->get_translation( 'page_for_posts', $language ); return $additional_data; } /** * Cleans the language cache and resets the internal properties when options are updated. * * @since 3.4 * * @return void */ public function clean_cache() { $this->model->clean_languages_cache(); $this->init(); } /** * Init the hooks that filter the "page on front" and "page for posts" options. * * @since 3.3 * * @return void */ public function pll_language_defined() { // Translates page for posts and page on front. add_filter( 'option_page_on_front', array( $this, 'translate_page_id' ), 10, 2 ); add_filter( 'option_page_for_posts', array( $this, 'translate_page_id' ), 10, 2 ); } /** * Translates the page on front or page for posts option. * * @since 3.6 Replaces `translate_page_on_front()` and `translate_page_on_front()` methods. * * @param int $page_id ID of the page on front or page for posts. * @param string $option Option name: `page_on_front` or `page_for_posts`. * @return int */ public function translate_page_id( $page_id, $option ) { if ( empty( $this->curlang->{$option} ) ) { return $page_id; } if ( doing_action( "update_option_{$option}" ) || doing_action( 'switch_blog' ) || doing_action( 'before_delete_post' ) || doing_action( 'wp_trash_post' ) ) { /* * Don't attempt to translate in a 'switch_blog' action as there is a risk to call this function while initializing the languages cache. * Don't translate while deleting a post or it will mess up `_reset_front_page_settings_for_post()`. * Don't translate while updating the option itself. */ return $page_id; } return $this->curlang->{$option}; } /** * Modifies the page link in case the front page is not in the default language. * * @since 0.7.2 * * @param string $link The link to the page. * @param int $id The post ID of the page. * @return string Modified link. */ public function page_link( $link, $id ) { $lang = $this->model->post->get_language( $id ); if ( $lang && $id == $lang->page_on_front ) { return $lang->get_home_url(); } return $link; } /** * Fixes the oembed for the translated static front page * when the language page is redirected to the front page. * * @since 2.6 * * @param int $post_id The post ID. * @param string $url The requested URL. * @return int */ public function oembed_request_post_id( $post_id, $url ) { foreach ( $this->model->get_languages_list() as $lang ) { if ( is_string( $lang->get_home_url() ) && trailingslashit( $url ) === trailingslashit( $lang->get_home_url() ) ) { return (int) $lang->page_on_front; } } return $post_id; } }
Save
cmd:
run