晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
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/wp-contentTZh/plugins/elementor/core/base/ |
Upload File : |
<?php
namespace Elementor\Core\Base;
use Elementor\Core\Admin\Admin_Notices;
use Elementor\Plugin;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
abstract class DB_Upgrades_Manager extends Background_Task_Manager {
protected $current_version = null;
protected $query_limit = 100;
abstract public function get_new_version();
abstract public function get_version_option_name();
abstract public function get_upgrades_class();
abstract public function get_updater_label();
public function get_task_runner_class() {
return 'Elementor\Core\Upgrade\Updater';
}
public function get_query_limit() {
return $this->query_limit;
}
public function set_query_limit( $limit ) {
$this->query_limit = $limit;
}
public function get_current_version() {
if ( null === $this->current_version ) {
$this->current_version = get_option( $this->get_version_option_name() );
}
return $this->current_version;
}
public function should_upgrade() {
$current_version = $this->get_current_version();
// It's a new install.
if ( ! $current_version ) {
$this->update_db_version();
return false;
}
return version_compare( $this->get_new_version(), $current_version, '>' );
}
public function on_runner_start() {
parent::on_runner_start();
if ( ! defined( 'IS_ELEMENTOR_UPGRADE' ) ) {
define( 'IS_ELEMENTOR_UPGRADE', true );
}
}
public function on_runner_complete( $did_tasks = false ) {
$logger = Plugin::$instance->logger->get_logger();
$logger->info( 'Elementor data updater process has been completed.', [
'meta' => [
'plugin' => $this->get_plugin_label(),
'from' => $this->current_version,
'to' => $this->get_new_version(),
],
] );
$this->clear_cache();
$this->update_db_version();
if ( $did_tasks ) {
$this->add_flag( 'completed' );
}
}
protected function clear_cache() {
Plugin::$instance->files_manager->clear_cache();
}
public function admin_notice_start_upgrade() {
/**
* @var Admin_Notices $admin_notices
*/
$admin_notices = Plugin::$instance->admin->get_component( 'admin-notices' );
$options = [
'title' => $this->get_updater_label(),
'description' => esc_html__( 'Your site database needs to be updated to the latest version.', 'elementor' ),
'type' => 'error',
'icon' => false,
'button' => [
'text' => esc_html__( 'Update Now', 'elementor' ),
'url' => $this->get_start_action_url(),
'class' => 'e-button e-button--cta',
],
];
$admin_notices->print_admin_notice( $options );
}
public function admin_notice_upgrade_is_running() {
/**
* @var Admin_Notices $admin_notices
*/
$admin_notices = Plugin::$instance->admin->get_component( 'admin-notices' );
$options = [
'title' => $this->get_updater_label(),
'description' => esc_html__( 'Database update process is running in the background. Taking a while?', 'elementor' ),
'type' => 'warning',
'icon' => false,
'button' => [
'text' => esc_html__( 'Click here to run it now', 'elementor' ),
'url' => $this->get_continue_action_url(),
'class' => 'e-button e-button--primary',
],
];
$admin_notices->print_admin_notice( $options );
}
public function admin_notice_upgrade_is_completed() {
$this->delete_flag( 'completed' );
$message = esc_html__( 'The database update process is now complete. Thank you for updating to the latest version!', 'elementor' );
/**
* @var Admin_Notices $admin_notices
*/
$admin_notices = Plugin::$instance->admin->get_component( 'admin-notices' );
$options = [
'description' => '<b>' . $this->get_updater_label() . '</b> - ' . $message,
'type' => 'success',
'icon' => false,
];
$admin_notices->print_admin_notice( $options );
}
/**
* @access protected
*/
protected function start_run() {
$updater = $this->get_task_runner();
if ( $updater->is_running() ) {
return;
}
$upgrade_callbacks = $this->get_upgrade_callbacks();
if ( empty( $upgrade_callbacks ) ) {
$this->on_runner_complete();
return;
}
$this->clear_cache();
foreach ( $upgrade_callbacks as $callback ) {
$updater->push_to_queue( [
'callback' => $callback,
] );
}
$updater->save()->dispatch();
Plugin::$instance->logger->get_logger()->info( 'Elementor data updater process has been queued.', [
'meta' => [
'plugin' => $this->get_plugin_label(),
'from' => $this->current_version,
'to' => $this->get_new_version(),
],
] );
}
protected function update_db_version() {
update_option( $this->get_version_option_name(), $this->get_new_version() );
}
public function get_upgrade_callbacks() {
$prefix = '_v_';
$upgrades_class = $this->get_upgrades_class();
$upgrades_reflection = new \ReflectionClass( $upgrades_class );
$callbacks = [];
foreach ( $upgrades_reflection->getMethods() as $method ) {
$method_name = $method->getName();
if ( '_on_each_version' === $method_name ) {
$callbacks[] = [ $upgrades_class, $method_name ];
continue;
}
if ( false === strpos( $method_name, $prefix ) ) {
continue;
}
if ( ! preg_match_all( "/$prefix(\d+_\d+_\d+)/", $method_name, $matches ) ) {
continue;
}
$method_version = str_replace( '_', '.', $matches[1][0] );
if ( ! version_compare( $method_version, $this->current_version, '>' ) ) {
continue;
}
$callbacks[] = [ $upgrades_class, $method_name ];
}
return $callbacks;
}
public function __construct() {
// If upgrade is completed - show the notice only for admins.
// Note: in this case `should_upgrade` returns false, because it's already upgraded.
if ( is_admin() && current_user_can( 'update_plugins' ) && $this->get_flag( 'completed' ) ) {
add_action( 'admin_notices', [ $this, 'admin_notice_upgrade_is_completed' ] );
}
if ( ! $this->should_upgrade() ) {
return;
}
$updater = $this->get_task_runner();
$this->start_run();
if ( $updater->is_running() && current_user_can( 'update_plugins' ) ) {
add_action( 'admin_notices', [ $this, 'admin_notice_upgrade_is_running' ] );
}
parent::__construct();
}
}