晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
Server : Apache System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64 User : rainic ( 1014) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/rainic/public_html/oldTZh/wp-content/plugins/wp-rocket/inc/ThirdParty/Plugins/I18n/ |
Upload File : |
<?php
namespace WP_Rocket\ThirdParty\Plugins\I18n;
use WP_Rocket\Event_Management\Subscriber_Interface;
use WP_Filesystem_Direct;
use WP_Rocket\ThirdParty\ReturnTypesTrait;
/**
* Subscriber for compatibility with WPML.
*/
class WPML implements Subscriber_Interface {
use ReturnTypesTrait;
/**
* Filesystem instance.
*
* @var WP_Filesystem_Direct
*/
protected $filesystem;
/**
* Instantiate class.
*
* @param WP_Filesystem_Direct $filesystem Filesystem instance.
*/
public function __construct( WP_Filesystem_Direct $filesystem = null ) {
$this->filesystem = $filesystem ?: rocket_direct_filesystem();
}
/**
* Events for subscriber to listen to.
*
* @return array
*/
public static function get_subscribed_events() {
$events = [
'activate_sitepress-multilingual-cms/sitepress.php' => 'maybe_clear_on_disable',
'deactivate_sitepress-multilingual-cms/sitepress.php' => 'maybe_clear_on_disable',
];
if ( ! defined( 'ICL_SITEPRESS_VERSION' ) ) {
return $events;
}
$events['rocket_rucss_is_home_url'] = [ 'is_secondary_home', 10, 2 ];
$events['rocket_preload_all_to_pending_condition'] = 'clean_only_right_domain';
$events['rocket_preload_sitemap_before_queue'] = 'add_languages_sitemaps';
$events['after_rocket_clean_home'] = 'remove_root_cached_files';
$events['after_rocket_clean_domain'] = 'remove_root_cached_files';
$events['pre_update_option_icl_sitepress_settings'] = [ 'on_change_directory_for_default_language_clean_cache', 10, 2 ];
return $events;
}
/**
* Checks if page to be processed is secondary homepage.
*
* @param string $home_url home url.
* @param string $url url of current page.
* @return string
*/
public function is_secondary_home( string $home_url, string $url ): string {
global $sitepress;
// Get active languages on site.
$languages = $sitepress->get_active_languages();
foreach ( $languages as $lang ) {
$lang_url = $sitepress->language_url( $lang['code'] );
// Check if current url is a secondary homepage.
if ( untrailingslashit( $lang_url ) !== $url ) {
continue;
}
return $url;
}
return $home_url;
}
/**
* Add a condition to clean only urls from the domain when it is the case.
*
* @param string $condition condition used to clean URLS in the database.
* @return string
*/
public function clean_only_right_domain( $condition ) {
global $sitepress;
$lang = isset( $_GET['lang'] ) && 'all' !== $_GET['lang'] ? sanitize_key( $_GET['lang'] ) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( ! $lang ) {
return $condition;
}
$lang_url = $sitepress->language_url( $lang );
return ' WHERE url LIKE "' . $lang_url . '%"';
}
/**
* Add sitemaps from translations.
*
* @param array $sitemaps list of sitemaps to be fetched.
* @return array
*/
public function add_languages_sitemaps( $sitemaps ) {
global $sitepress;
$new_sitemaps = [];
// Get active languages on site.
$languages = $sitepress->get_active_languages();
$base_url = home_url();
foreach ( $sitemaps as $sitemap ) {
$new_sitemaps[] = $sitemap;
foreach ( $languages as $lang ) {
$lang_url = $sitepress->language_url( $lang['code'] );
$new_sitemaps[] = str_replace( $base_url, $lang_url, $sitemap );
}
}
return array_unique( $new_sitemaps );
}
/**
* Remove root files when WPML is active.
*
* @return void
*/
public function remove_root_cached_files() {
$site_url = home_url();
$host_name = wp_parse_url( $site_url, PHP_URL_HOST );
$cache_folder_path = _rocket_get_wp_rocket_cache_path() . $host_name . '/';
$cache_folder_directory = $this->filesystem->dirlist( $cache_folder_path );
if ( ! is_array( $cache_folder_directory ) || ! is_array( array_keys( $cache_folder_directory ) ) ) {
return;
}
foreach ( array_keys( $cache_folder_directory ) as $entry ) {
if ( $this->filesystem->is_dir( $cache_folder_path . $entry ) ) {
continue;
}
$this->filesystem->delete( $cache_folder_path . $entry );
}
}
/**
* Reset cache when changing the option.
*
* @param array $new new configurations.
* @param array $old old configurations.
*
* @return array
*/
public function on_change_directory_for_default_language_clean_cache( $new, $old ) {
if ( ! is_array( $old ) || ! is_array( $new ) ) {
return $new;
}
if ( ! key_exists( 'urls', $old ) || ! key_exists( 'directory_for_default_language', $old['urls'] ) || ! key_exists( 'urls', $new ) || ! key_exists( 'directory_for_default_language', $new['urls'] ) || $new['urls']['directory_for_default_language'] === $old['urls']['directory_for_default_language'] ) {
return $new;
}
/**
* Reset WP Rocket Preload.
*/
do_action( 'rocket_reset_preload' );
rocket_clean_domain();
return $new;
}
/**
* Clear the cache when the option language directory is enabled.
*
* @return void
*/
public function maybe_clear_on_disable() {
$option = get_option( 'icl_sitepress_settings' );
if ( ! $option || ! is_array( $option ) || ! key_exists( 'urls', $option ) || ! key_exists( 'directory_for_default_language', $option['urls'] ) || false === $option['urls']['directory_for_default_language'] ) {
return;
}
/**
* Reset WP Rocket Preload.
*/
do_action( 'rocket_reset_preload' );
rocket_clean_cache_dir();
rocket_clean_domain();
}
}