晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
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/oldTZh/wp-content/plugins/powerpack-elements/modules/posts/ |
Upload File : |
<?php
namespace PowerpackElements\Modules\Posts;
use PowerpackElements\Base\Module_Base;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class Module extends Module_Base {
public static $displayed_ids = [];
public function get_name() {
return 'pp-posts';
}
public function get_widgets() {
return [
'Card_Slider',
'Content_Ticker',
'Magazine_Slider',
'Tiled_Posts',
'Posts',
'Timeline',
];
}
/**
* Constructor.
*/
public function __construct() {
parent::__construct();
/**
* Pagination Break.
*
* @see https://codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination
*/
add_action( 'pre_get_posts', [ $this, 'fix_query_offset' ], 1 );
add_filter( 'found_posts', [ $this, 'fix_query_found_posts' ], 1, 2 );
add_action( 'wp_ajax_pp_get_post', array( $this, 'get_post_data' ) );
add_action( 'wp_ajax_nopriv_pp_get_post', array( $this, 'get_post_data' ) );
}
public static function add_to_avoid_list( $ids ) {
self::$displayed_ids = array_unique( array_merge( self::$displayed_ids, $ids ) );
}
public static function get_avoid_list_ids() {
return self::$displayed_ids;
}
/**
* Query Offset Fix.
*
* @since 1.4.14
* @access public
* @param object $query query object.
*/
public function fix_query_offset( &$query ) {
if ( ! empty( $query->query_vars['offset_to_fix'] ) ) {
if ( $query->is_paged ) {
$query->query_vars['offset'] = $query->query_vars['offset_to_fix'] + ( ( $query->query_vars['paged'] - 1 ) * $query->query_vars['posts_per_page'] );
} else {
$query->query_vars['offset'] = $query->query_vars['offset_to_fix'];
}
}
}
/**
* Query Found Posts Fix.
*
* @since 1.4.14
* @access public
* @param int $found_posts found posts.
* @param object $query query object.
* @return int string
*/
public function fix_query_found_posts( $found_posts, $query ) {
$offset_to_fix = $query->get( 'offset_to_fix' );
if ( $offset_to_fix ) {
$found_posts -= $offset_to_fix;
}
return $found_posts;
}
public function get_post_data() {
check_ajax_referer( 'pp-posts-widget-nonce', 'nonce' );
$post_id = $_POST['page_id'];
$widget_id = $_POST['widget_id'];
$filter = isset( $_POST['category'] ) ? $_POST['category'] : '';
$filter = str_replace( '.', '', $filter );
$taxonomy_filter = isset( $_POST['taxonomy'] ) ? $_POST['taxonomy'] : '';
$taxonomy_filter = str_replace( '.', '', $taxonomy_filter );
$search_filter = isset( $_POST['search'] ) ? $_POST['search'] : '';
$ajax_for = isset( $_POST['ajax_for'] ) ? $_POST['ajax_for'] : '';
$elementor = \Elementor\Plugin::$instance;
$meta = $elementor->documents->get( $post_id )->get_elements_data();
$widget_data = $this->find_element_recursive( $meta, $widget_id );
if ( isset( $widget_data['templateID'] ) ) {
$template_data = \Elementor\Plugin::$instance->templates_manager->get_template_data( [
'source' => 'local',
'template_id' => $widget_data['templateID'],
] );
if ( is_array( $template_data ) && isset( $template_data['content'] ) ) {
$widget_data = $template_data['content'][0];
}
}
$data = array(
'message' => __( 'Saved', 'powerpack' ),
'ID' => '',
'skin_id' => '',
'html' => '',
'not_found' => '',
'pagination' => '',
);
if ( null !== $widget_data ) {
// Restore default values.
if ( ! empty( $ajax_for ) && 'coupon' === $ajax_for ) {
$widget = $elementor->elements_manager->create_element_instance( $widget_data );
$skin_body = $widget->render_ajax_post_body( $filter, $taxonomy_filter, $search_filter );
$not_found = '';
$pagination = $widget->render_ajax_pagination( $filter, $taxonomy_filter, $search_filter );
} else {
$widget = $elementor->elements_manager->create_element_instance( $widget_data );
$skin = $widget->get_current_skin();
$skin_body = $skin->render_ajax_post_body( $filter, $taxonomy_filter, $search_filter );
$not_found = $skin->render_ajax_not_found( $filter, $taxonomy_filter, $search_filter );
$pagination = $skin->render_ajax_pagination();
}
$data['ID'] = $widget->get_id();
$data['skin_id'] = $widget->get_current_skin_id();
$data['html'] = $skin_body;
$data['not_found'] = $not_found;
$data['pagination'] = $pagination;
}
wp_send_json_success( $data );
}
/**
* Get Widget Setting data.
*
* @since 1.7.0
* @access public
* @param array $elements Element array.
* @param string $form_id Element ID.
* @return Boolean True/False.
*/
public function find_element_recursive( $elements, $form_id ) {
foreach ( $elements as $element ) {
if ( $form_id === $element['id'] ) {
return $element;
}
if ( ! empty( $element['elements'] ) ) {
$element = $this->find_element_recursive( $element['elements'], $form_id );
if ( $element ) {
return $element;
}
}
}
return false;
}
/**
* Get Post Parts
*
* @since 1.4.11.0
* @return array
*/
public static function get_post_parts() {
$post_parts = [
'thumbnail',
'terms',
'title',
'meta',
'excerpt',
'button',
];
return $post_parts;
}
/**
* Get Meta Items
*
* @since 1.4.11.0
* @return array
*/
public static function get_meta_items() {
$meta_items = [
'author',
'date',
'comments',
];
return $meta_items;
}
}