晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
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/stando/www/wp-content/plugins/persian-gravity-forms/includes/ |
Upload File : |
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class GFPersian_LivePreview extends GFPersian_Core {
private $post_type = 'gf_live_preview';
private $_args;
public function __construct( $args = array() ) {
if ( $this->option( 'live_preview', '1' ) != '1' ) {
return;
}
if ( ! property_exists( 'GFCommon', 'version' ) || version_compare( GFCommon::$version, '1.8', '<' ) ) {
return;
}
$this->_args = wp_parse_args( $args, array(
'id' => 0,
'title' => true,
'description' => true,
'ajax' => true
) );
add_action( 'init', array( $this, 'register_preview_post_type' ) );
add_action( 'wp', array( $this, 'maybe_load_preview_functionality' ) );
add_action( 'admin_footer', array( $this, 'display_preview_link' ) );
add_filter( 'gform_form_actions', array( $this, 'gform_form_actions' ), 10, 2 );
}
public function register_preview_post_type() {
$args = array(
'label' => 'پیشنمایش زنده',
'description' => 'پیشنمایش فرم در فرانت اند به صورت یک پست تایپ مجازی',
'public' => false,
'publicly_queryable' => true,
'has_archive' => true,
'can_export' => false,
'supports' => false
);
register_post_type( $this->post_type, $args );
// create preview post
$preview_post = get_posts( array( 'post_type' => $this->post_type ) );
if ( empty( $preview_post ) ) {
wp_insert_post( array(
'post_type' => $this->post_type,
'post_title' => 'پیشنمایش زنده',
'post_status' => 'publish'
) );
}
}
public function maybe_load_preview_functionality() {
global $wp_query;
if ( ! is_post_type_archive( $this->post_type ) ) {
return;
}
add_filter( 'template_include', array( $this, 'load_preview_template' ) );
add_filter( 'the_content', array( $this, 'modify_preview_post_content' ) );
// quick hack for GF to ensure scripts/styles are loaded correctly
foreach ( $wp_query->posts as &$post ) {
$post->post_content = $this->get_shortcode();
}
}
public function gform_form_actions( $form_actions, $form_id ) {
if ( ! empty( $_GET['trash'] ) && $_GET['trash'] == 1 ) {
return $form_actions;
}
$capabilities = array(
'gravityforms_view_entries',
'gravityforms_edit_entries',
'gravityforms_delete_entries'
);
$ajax_true_url = get_bloginfo( "wpurl" ) . '/?post_type=' . $this->post_type . '&id=' . $form_id;
$ajax_false_url = get_bloginfo( "wpurl" ) . '/?post_type=' . $this->post_type . '&ajax=false&id=' . $form_id;
$sub_menu_items = array();
$sub_menu_items[] = array(
'url' => $ajax_true_url,
'label' => 'حالت آیجکس فعال',
'capabilities' => $capabilities
);
$sub_menu_items[] = array(
'url' => $ajax_false_url,
'label' => 'حالت آیجکس غیرفعال',
'capabilities' => $capabilities
);
$form_actions['live_preview'] = array(
'label' => 'پیشنمایش زنده',
'icon' => '<i class="fa fa-cogs fa-lg"></i>',
'title' => 'پیشنمایش زنده',
'url' => '',
'menu_class' => 'gf_form_toolbar_settings',
'link_class' => 'gf_toolbar_active',
'sub_menu_items' => $sub_menu_items,
'capabilities' => $capabilities,
'priority' => 650,
);
return $form_actions;
}
public function display_preview_link() {
if ( ! in_array( rgget( 'page' ), array(
'gf_edit_forms',
'gf_entries'
) ) || ! rgget( 'id' ) || apply_filters( 'gf_live_preview_page', false ) ) {
return;
}
$form_id = apply_filters( 'gf_live_preview_id', rgget( 'id' ) );
$ajax_true_url = get_bloginfo( "wpurl" ) . '/?post_type=' . $this->post_type . '&id=' . $form_id;
$ajax_false_url = get_bloginfo( "wpurl" ) . '/?post_type=' . $this->post_type . '&ajax=false&id=' . $form_id;
?>
<script type="text/javascript">
(function ($) {
$('<li class="gf_form_toolbar_preview">' +
'<a style="position:relative" id="gf-live-preview" target="_blank" href="<?php echo $ajax_true_url; ?>" class="" >' +
'<i class="fa fa-eye" style="position: absolute; text-shadow: 0px 0px 5px rgb(255, 255, 255); z-index: 99; line-height: 7px; left: 0px font-size: 9px; background-color: rgb(243, 243, 243);"></i>' +
'<i class="fa fa-file-o" style="margin-left: 5px; line-height: 12px; font-size: 18px; position: relative;"></i>' +
'پیش نمایش زنده' +
'</a>' +
'<div class="gf_submenu"><ul>' +
'<li class=""><a target="_blank" href="<?php echo $ajax_true_url; ?>">حالت آیجکس فعال</a></li>' +
'<li class=""><a target="_blank" href="<?php echo $ajax_false_url; ?>">حالت آیجکس غیرفعال</a></li>' +
'</ul></div>' +
'</li>')
.insertAfter('li.gf_form_toolbar_preview');
})(jQuery);
</script>
<?php
}
public function load_preview_template( $template ) {
return get_page_template();
}
public function modify_preview_post_content( $content ) {
return $this->get_shortcode();
}
public function get_shortcode( $args = array() ) {
if ( ! is_user_logged_in() ) {
return '<p>برای دسترسی به این قسمت باید لاگین شوید.</p>' . wp_login_form( array( 'echo' => false ) );
}
if ( ! GFCommon::current_user_can_any( 'gravityforms_preview_forms' ) ) {
return 'شما مجوز دسترسی به این بخش را ندارید.';
}
if ( empty( $args ) ) {
$args = $this->get_shortcode_parameters_from_query_string();
}
extract( wp_parse_args( $args, $this->_args ) );
$title = ! empty( $title ) && $title === true ? 'true' : 'false';
$description = ! empty( $description ) && $description === true ? 'true' : 'false';
$ajax = ! empty( $ajax ) && $ajax === true ? 'true' : 'false';
$id = ! empty( $id ) && $id > 0 ? $id : 0;
return "[gravityform id='$id' title='$title' description='$description' ajax='$ajax']";
}
public function get_shortcode_parameters_from_query_string() {
return array_filter( array(
'id' => rgget( 'id' ),
'title' => rgget( 'title' ),
'description' => rgget( 'description' ),
'ajax' => rgget( 'ajax' )
) );
}
}
new GFPersian_LivePreview();