晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
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/public_html/wp-content/plugins/uwac/adminframework/classes/ |
Upload File : |
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access pages directly.
/**
*
* Taxonomy Class
*
* @since 1.0.0
* @version 1.0.0
*
*/
class CSSFramework_Taxonomy extends CSSFramework_Abstract{
/**
*
* taxonomy options
* @access public
* @var array
*
*/
public $options = array();
/**
*
* instance
* @access private
* @var class
*
*/
private static $instance = null;
// run taxonomy construct
public function __construct( $options ) {
$this->options = apply_filters( 'cs_taxonomy_options', $options );
if( ! empty( $this->options ) ) {
$this->addAction( 'admin_init', 'add_taxonomy_fields' );
}
}
// instance
public static function instance( $options = array() ) {
if ( is_null( self::$instance ) && CSSF_ACTIVE_TAXONOMY ) {
self::$instance = new self( $options );
}
return self::$instance;
}
// add taxonomy add/edit fields
public function add_taxonomy_fields() {
foreach ( $this->options as $option ) {
$opt_taxonomy = $option['taxonomy'];
$get_taxonomy = cssf_get_var( 'taxonomy' );
if( $get_taxonomy == $opt_taxonomy ) {
$this->addAction( $opt_taxonomy .'_add_form_fields', 'render_taxonomy_form_fields' );
$this->addAction( $opt_taxonomy .'_edit_form', 'render_taxonomy_form_fields' );
$this->addAction( 'created_'. $opt_taxonomy, 'save_taxonomy' );
$this->addAction( 'edited_'. $opt_taxonomy, 'save_taxonomy' );
$this->addAction( 'delete_'. $opt_taxonomy, 'delete_taxonomy' );
}
}
}
// render taxonomy add/edit form fields
public function render_taxonomy_form_fields( $term ) {
global $cs_errors;
$form_edit = ( is_object( $term ) && isset( $term->taxonomy ) ) ? true : false;
$taxonomy = ( $form_edit ) ? $term->taxonomy : $term;
$classname = ( $form_edit ) ? 'edit' : 'add';
$cs_errors = get_transient( 'cssf-taxonomy-transient' );
wp_nonce_field( 'cssf-taxonomy', 'cssf-taxonomy-nonce' );
echo '<div class="cssf-framework cssf-taxonomy cssf-taxonomy-'. $classname .'-fields">';
foreach( $this->options as $option ) {
if( $taxonomy == $option['taxonomy'] ) {
$tax_value = ( $form_edit ) ? get_term_meta( $term->term_id, $option['id'], true ) : '';
foreach ( $option['fields'] as $field ) {
$default = ( isset( $field['default'] ) ) ? $field['default'] : '';
$elem_id = ( isset( $field['id'] ) ) ? $field['id'] : '';
$elem_value = ( is_array( $tax_value ) && isset( $tax_value[$elem_id] ) ) ? $tax_value[$elem_id] : $default;
echo cs_add_element( $field, $elem_value, $option['id'] );
}
}
}
echo '</div>';
}
// save taxonomy form fields
public function save_taxonomy( $term_id ) {
if ( wp_verify_nonce( cssf_get_var( 'cssf-taxonomy-nonce' ), 'cssf-taxonomy' ) ) {
$errors = array();
$taxonomy = cssf_get_var( 'taxonomy' );
foreach ( $this->options as $request_value ) {
if( $taxonomy == $request_value['taxonomy'] ) {
$request_key = $request_value['id'];
$request = cssf_get_var( $request_key, array() );
// ignore _nonce
if( isset( $request['_nonce'] ) ) {
unset( $request['_nonce'] );
}
if( isset( $request_value['fields'] ) ) {
foreach( $request_value['fields'] as $field ) {
if( isset( $field['type'] ) && isset( $field['id'] ) ) {
$field_value = cssf_get_vars( $request_key, $field['id'] );
// sanitize options
if( isset( $field['sanitize'] ) && $field['sanitize'] !== false ) {
$sanitize_type = $field['sanitize'];
} else if ( ! isset( $field['sanitize'] ) ) {
$sanitize_type = $field['type'];
}
if( has_filter( 'cs_sanitize_'. $sanitize_type ) ) {
$request[$field['id']] = apply_filters( 'cs_sanitize_' . $sanitize_type, $field_value, $field, $request_value['fields'] );
}
// validate options
if ( isset( $field['validate'] ) && has_filter( 'cs_validate_'. $field['validate'] ) ) {
$validate = apply_filters( 'cs_validate_' . $field['validate'], $field_value, $field, $request_value['fields'] );
if( ! empty( $validate ) ) {
$meta_value = get_term_meta( $term_id, $request_key, true );
$errors[$field['id']] = array( 'code' => $field['id'], 'message' => $validate, 'type' => 'error' );
$default_value = isset( $field['default'] ) ? $field['default'] : '';
$request[$field['id']] = ( isset( $meta_value[$field['id']] ) ) ? $meta_value[$field['id']] : $default_value;
}
}
}
}
}
$request = apply_filters( 'cs_save_taxonomy', $request, $request_key, $term_id );
if( empty( $request ) ) {
delete_term_meta( $term_id, $request_key );
} else {
if( get_term_meta( $term_id, $request_key, true ) ) {
update_term_meta( $term_id, $request_key, $request );
} else {
add_term_meta( $term_id, $request_key, $request );
}
}
}
}
set_transient( 'cssf-taxonomy-transient', $errors, 10 );
}
}
// delete taxonomy
public function delete_taxonomy( $term_id ) {
$taxonomy = cssf_get_var( 'taxonomy' );
if( ! empty( $taxonomy ) ) {
foreach ( $this->options as $request_value ) {
if( $taxonomy == $request_value['taxonomy'] ) {
$request_key = $request_value['id'];
delete_term_meta( $term_id, $request_key );
}
}
}
}
}