Edit File by line
/home/zeestwma/ceyloniy.../wp-inclu.../blocks
File: term-count.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/term-count` block.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Renders the `core/term-count` block on the server.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 6.9.0
[10] Fix | Delete
*
[11] Fix | Delete
* @param array $attributes Block attributes.
[12] Fix | Delete
* @param string $content Block default content.
[13] Fix | Delete
* @param WP_Block $block Block instance.
[14] Fix | Delete
*
[15] Fix | Delete
* @return string Returns the count of the current taxonomy term wrapped inside a heading tag.
[16] Fix | Delete
*/
[17] Fix | Delete
function render_block_core_term_count( $attributes, $content, $block ) {
[18] Fix | Delete
// Get term from context or from the current query.
[19] Fix | Delete
if ( isset( $block->context['termId'] ) && isset( $block->context['taxonomy'] ) ) {
[20] Fix | Delete
$term = get_term( $block->context['termId'], $block->context['taxonomy'] );
[21] Fix | Delete
} else {
[22] Fix | Delete
$term = get_queried_object();
[23] Fix | Delete
if ( ! $term instanceof WP_Term ) {
[24] Fix | Delete
$term = null;
[25] Fix | Delete
}
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
if ( ! $term || is_wp_error( $term ) ) {
[29] Fix | Delete
return '';
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
$term_count = $term->count;
[33] Fix | Delete
[34] Fix | Delete
// Format the term count based on bracket type.
[35] Fix | Delete
switch ( $attributes['bracketType'] ) {
[36] Fix | Delete
case 'none':
[37] Fix | Delete
// No formatting needed.
[38] Fix | Delete
break;
[39] Fix | Delete
case 'round':
[40] Fix | Delete
$term_count = "({$term_count})";
[41] Fix | Delete
break;
[42] Fix | Delete
case 'square':
[43] Fix | Delete
$term_count = "[{$term_count}]";
[44] Fix | Delete
break;
[45] Fix | Delete
case 'curly':
[46] Fix | Delete
$term_count = "{{$term_count}}";
[47] Fix | Delete
break;
[48] Fix | Delete
case 'angle':
[49] Fix | Delete
$term_count = "<{$term_count}>";
[50] Fix | Delete
break;
[51] Fix | Delete
default:
[52] Fix | Delete
// Default to no formatting for unknown types.
[53] Fix | Delete
break;
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes();
[57] Fix | Delete
[58] Fix | Delete
return sprintf(
[59] Fix | Delete
'<div %1$s>%2$s</div>',
[60] Fix | Delete
$wrapper_attributes,
[61] Fix | Delete
$term_count
[62] Fix | Delete
);
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Registers the `core/term-count` block on the server.
[67] Fix | Delete
*
[68] Fix | Delete
* @since 6.9.0
[69] Fix | Delete
*/
[70] Fix | Delete
function register_block_core_term_count() {
[71] Fix | Delete
register_block_type_from_metadata(
[72] Fix | Delete
__DIR__ . '/term-count',
[73] Fix | Delete
array(
[74] Fix | Delete
'render_callback' => 'render_block_core_term_count',
[75] Fix | Delete
)
[76] Fix | Delete
);
[77] Fix | Delete
}
[78] Fix | Delete
add_action( 'init', 'register_block_core_term_count' );
[79] Fix | Delete
[80] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function