晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
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-includesTZh/blocks/ |
Upload File : |
<?php
/**
* Server-side rendering of the `core/term-template` block.
*
* @package WordPress
*/
/**
* Renders the `core/term-template` block on the server.
*
* @since 6.9.0
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
*
* @return string Returns the output of the term template.
*/
function render_block_core_term_template( $attributes, $content, $block ) {
if ( ! isset( $block->context ) || empty( $block->context['termQuery'] ) ) {
return '';
}
$query = $block->context['termQuery'];
$query_args = array(
'number' => $query['perPage'],
'order' => $query['order'],
'orderby' => $query['orderBy'],
'hide_empty' => $query['hideEmpty'],
);
$inherit_query = isset( $query['inherit'] )
&& $query['inherit']
&& ( is_tax() || is_category() || is_tag() );
if ( $inherit_query ) {
// Get the current term and taxonomy from the queried object.
$queried_object = get_queried_object();
// For hierarchical taxonomies, show children of the current term.
// For non-hierarchical taxonomies, show all terms (don't set parent).
if ( is_taxonomy_hierarchical( $queried_object->taxonomy ) ) {
// If showNested is true, use child_of to include nested terms.
// Otherwise, use parent to show only direct children.
if ( ! empty( $query['showNested'] ) ) {
$query_args['child_of'] = $queried_object->term_id;
} else {
$query_args['parent'] = $queried_object->term_id;
}
}
$query_args['taxonomy'] = $queried_object->taxonomy;
} else {
// If not inheriting set `taxonomy` from the block attribute.
$query_args['taxonomy'] = $query['taxonomy'];
// If we are including specific terms we ignore `showNested` argument.
if ( ! empty( $query['include'] ) ) {
$query_args['include'] = array_unique( array_map( 'intval', $query['include'] ) );
$query_args['orderby'] = 'include';
$query_args['order'] = 'asc';
} elseif ( empty( $query['showNested'] ) ) {
// We set parent only when inheriting from the taxonomy archive context or not
// showing nested terms, otherwise nested terms are not displayed.
$query_args['parent'] = 0;
}
}
$terms_query = new WP_Term_Query( $query_args );
$terms = $terms_query->get_terms();
if ( ! $terms || is_wp_error( $terms ) ) {
return '';
}
$content = '';
foreach ( $terms as $term ) {
// Get an instance of the current Term Template block.
$block_instance = $block->parsed_block;
// Set the block name to one that does not correspond to an existing registered block.
// This ensures that for the inner instances of the Term Template block, we do not render any block supports.
$block_instance['blockName'] = 'core/null';
$term_id = $term->term_id;
$taxonomy = $term->taxonomy;
$filter_block_context = static function ( $context ) use ( $term_id, $taxonomy ) {
$context['termId'] = $term_id;
$context['taxonomy'] = $taxonomy;
return $context;
};
// Use an early priority to so that other 'render_block_context' filters have access to the values.
add_filter( 'render_block_context', $filter_block_context, 1 );
// Render the inner blocks of the Term Template block with `dynamic` set to `false` to prevent calling
// `render_callback` and ensure that no wrapper markup is included.
$block_content = ( new WP_Block( $block_instance ) )->render( array( 'dynamic' => false ) );
remove_filter( 'render_block_context', $filter_block_context, 1 );
// Wrap the render inner blocks in a `li` element with the appropriate term classes.
$term_classes = "wp-block-term term-{$term->term_id} {$term->taxonomy} taxonomy-{$term->taxonomy}";
$content .= '<li class="' . esc_attr( $term_classes ) . '">' . $block_content . '</li>';
}
$classnames = '';
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classnames .= 'has-link-color';
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => trim( $classnames ) ) );
return sprintf(
'<ul %s>%s</ul>',
$wrapper_attributes,
$content
);
}
/**
* Registers the `core/term-template` block on the server.
*
* @since 6.9.0
*/
function register_block_core_term_template() {
register_block_type_from_metadata(
__DIR__ . '/term-template',
array(
'render_callback' => 'render_block_core_term_template',
)
);
}
add_action( 'init', 'register_block_core_term_template' );