晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
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/www/wp-contentTZh/plugins/elementor/core/base/elements-iteration-actions/ |
Upload File : |
<?php
namespace Elementor\Core\Base\Elements_Iteration_Actions;
use Elementor\Conditions;
use Elementor\Element_Base;
use Elementor\Plugin;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Assets extends Base {
const ASSETS_META_KEY = '_elementor_page_assets';
/**
* Default value must be empty.
*
* @var array
*/
private $page_assets;
/**
* Default value must be empty.
*
* @var array
*/
private $saved_page_assets;
public function element_action( Element_Base $element_data ) {
$settings = $element_data->get_active_settings();
$controls = $element_data->get_controls();
$element_assets = $this->get_assets( $settings, $controls );
$element_assets_depend = [
'styles' => $element_data->get_style_depends(),
'scripts' => array_merge( $element_data->get_script_depends(), $element_data->get_global_scripts() ),
];
if ( $element_assets_depend ) {
foreach ( $element_assets_depend as $assets_type => $assets ) {
if ( empty( $assets ) ) {
continue;
}
if ( ! isset( $element_assets[ $assets_type ] ) ) {
$element_assets[ $assets_type ] = [];
}
foreach ( $assets as $asset_name ) {
if ( ! in_array( $asset_name, $element_assets[ $assets_type ], true ) ) {
$element_assets[ $assets_type ][] = $asset_name;
}
}
}
}
if ( $element_assets ) {
$this->update_page_assets( $element_assets );
}
}
public function is_action_needed() {
// No need to evaluate in preview mode, will be made in the saving process.
if ( Plugin::$instance->preview->is_preview_mode() ) {
return false;
}
$page_assets = $this->get_saved_page_assets();
// When $page_assets is array it means that the assets registration has already been made at least once.
if ( is_array( $page_assets ) ) {
return false;
}
return true;
}
public function after_elements_iteration() {
// In case that the page assets value is empty, it should still be saved as an empty array as an indication that at lease one iteration has occurred.
if ( ! is_array( $this->page_assets ) ) {
$this->page_assets = [];
}
$this->get_document_assets();
// Saving the page assets data.
$this->document->update_meta( self::ASSETS_META_KEY, $this->page_assets );
if ( 'render' === $this->mode && $this->page_assets ) {
Plugin::$instance->assets_loader->enable_assets( $this->page_assets );
}
}
private function get_saved_page_assets( $force_meta_fetch = false ) {
if ( ! is_array( $this->saved_page_assets ) || $force_meta_fetch ) {
$this->saved_page_assets = $this->document->get_meta( self::ASSETS_META_KEY );
}
return $this->saved_page_assets;
}
private function update_page_assets( $new_assets ) {
if ( ! is_array( $this->page_assets ) ) {
$this->page_assets = [];
}
foreach ( $new_assets as $assets_type => $assets_type_data ) {
if ( ! isset( $this->page_assets[ $assets_type ] ) ) {
$this->page_assets[ $assets_type ] = [];
}
foreach ( $assets_type_data as $asset_name ) {
if ( ! in_array( $asset_name, $this->page_assets[ $assets_type ], true ) ) {
$this->page_assets[ $assets_type ][] = $asset_name;
}
}
}
}
private function get_assets( $settings, $controls ) {
$assets = [];
foreach ( $settings as $setting_key => $setting ) {
if ( ! isset( $controls[ $setting_key ] ) ) {
continue;
}
$control = $controls[ $setting_key ];
// Enabling assets loading from the registered control fields.
if ( ! empty( $control['assets'] ) ) {
foreach ( $control['assets'] as $assets_type => $dependencies ) {
foreach ( $dependencies as $dependency ) {
if ( ! empty( $dependency['conditions'] ) ) {
$is_condition_fulfilled = Conditions::check( $dependency['conditions'], $settings );
if ( ! $is_condition_fulfilled ) {
continue;
}
}
if ( ! isset( $assets[ $assets_type ] ) ) {
$assets[ $assets_type ] = [];
}
$assets[ $assets_type ][] = $dependency['name'];
}
}
}
// Enabling assets loading from the control object.
$control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] );
$control_conditional_assets = $control_obj::get_assets( $setting );
if ( $control_conditional_assets ) {
foreach ( $control_conditional_assets as $assets_type => $dependencies ) {
foreach ( $dependencies as $dependency ) {
if ( ! isset( $assets[ $assets_type ] ) ) {
$assets[ $assets_type ] = [];
}
$assets[ $assets_type ][] = $dependency;
}
}
}
}
return $assets;
}
private function get_document_assets() {
$document_id = $this->document->get_post()->ID;
// Getting the document instance in order to get the most updated settings.
$updated_document = Plugin::$instance->documents->get( $document_id, false );
$document_settings = $updated_document->get_settings();
$document_controls = $this->document->get_controls();
$document_assets = $this->get_assets( $document_settings, $document_controls );
if ( $document_assets ) {
$this->update_page_assets( $document_assets );
}
}
public function __construct( $document ) {
parent::__construct( $document );
// No need to enable assets in preview mode, all assets will be loaded by default by the assets loader.
if ( Plugin::$instance->preview->is_preview_mode() ) {
return;
}
$page_assets = $this->get_saved_page_assets();
// If $page_assets is not empty then enabling the assets for loading.
if ( $page_assets ) {
Plugin::$instance->assets_loader->enable_assets( $page_assets );
}
}
}