Edit File by line
/home/zeestwma/redstone.../wp-inclu.../blocks
File: term-name.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/term-name` 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-name` 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 name of the current taxonomy term wrapped inside a heading tag.
[16] Fix | Delete
*/
[17] Fix | Delete
function render_block_core_term_name( $attributes, $content, $block ) {
[18] Fix | Delete
$term_name = '';
[19] Fix | Delete
[20] Fix | Delete
// Get term from context or from the current query.
[21] Fix | Delete
if ( isset( $block->context['termId'] ) && isset( $block->context['taxonomy'] ) ) {
[22] Fix | Delete
$term = get_term( $block->context['termId'], $block->context['taxonomy'] );
[23] Fix | Delete
} else {
[24] Fix | Delete
$term = get_queried_object();
[25] Fix | Delete
if ( ! $term instanceof WP_Term ) {
[26] Fix | Delete
$term = null;
[27] Fix | Delete
}
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
if ( ! $term || is_wp_error( $term ) ) {
[31] Fix | Delete
return '';
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
$term_name = $term->name;
[35] Fix | Delete
$level = isset( $attributes['level'] ) ? $attributes['level'] : 0;
[36] Fix | Delete
$tag_name = 0 === $level ? 'p' : 'h' . (int) $level;
[37] Fix | Delete
[38] Fix | Delete
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
[39] Fix | Delete
$term_link = get_term_link( $term );
[40] Fix | Delete
if ( ! is_wp_error( $term_link ) ) {
[41] Fix | Delete
$term_name = sprintf(
[42] Fix | Delete
'<a href="%1$s">%2$s</a>',
[43] Fix | Delete
esc_url( $term_link ),
[44] Fix | Delete
$term_name
[45] Fix | Delete
);
[46] Fix | Delete
}
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
$classes = array();
[50] Fix | Delete
if ( isset( $attributes['textAlign'] ) ) {
[51] Fix | Delete
$classes[] = 'has-text-align-' . $attributes['textAlign'];
[52] Fix | Delete
}
[53] Fix | Delete
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
[54] Fix | Delete
$classes[] = 'has-link-color';
[55] Fix | Delete
}
[56] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
[57] Fix | Delete
[58] Fix | Delete
return sprintf(
[59] Fix | Delete
'<%1$s %2$s>%3$s</%1$s>',
[60] Fix | Delete
$tag_name,
[61] Fix | Delete
$wrapper_attributes,
[62] Fix | Delete
$term_name
[63] Fix | Delete
);
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Registers the `core/term-name` block on the server.
[68] Fix | Delete
*
[69] Fix | Delete
* @since 6.9.0
[70] Fix | Delete
*/
[71] Fix | Delete
function register_block_core_term_name() {
[72] Fix | Delete
register_block_type_from_metadata(
[73] Fix | Delete
__DIR__ . '/term-name',
[74] Fix | Delete
array(
[75] Fix | Delete
'render_callback' => 'render_block_core_term_name',
[76] Fix | Delete
)
[77] Fix | Delete
);
[78] Fix | Delete
}
[79] Fix | Delete
add_action( 'init', 'register_block_core_term_name' );
[80] Fix | Delete
[81] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function