Edit File by line
/home/zeestwma/richards.../wp-inclu.../blocks
File: query-title.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/query-title` block.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Renders the `core/query-title` block on the server.
[8] Fix | Delete
* For now it only supports Archive title,
[9] Fix | Delete
* using queried object information
[10] Fix | Delete
*
[11] Fix | Delete
* @since 5.8.0
[12] Fix | Delete
*
[13] Fix | Delete
* @param array $attributes Block attributes.
[14] Fix | Delete
*
[15] Fix | Delete
* @return string Returns the query title based on the queried object.
[16] Fix | Delete
*/
[17] Fix | Delete
function render_block_core_query_title( $attributes ) {
[18] Fix | Delete
$type = isset( $attributes['type'] ) ? $attributes['type'] : null;
[19] Fix | Delete
$is_archive = is_archive();
[20] Fix | Delete
$is_search = is_search();
[21] Fix | Delete
if ( ! $type ||
[22] Fix | Delete
( 'archive' === $type && ! $is_archive ) ||
[23] Fix | Delete
( 'search' === $type && ! $is_search )
[24] Fix | Delete
) {
[25] Fix | Delete
return '';
[26] Fix | Delete
}
[27] Fix | Delete
$title = '';
[28] Fix | Delete
if ( $is_archive ) {
[29] Fix | Delete
$show_prefix = isset( $attributes['showPrefix'] ) ? $attributes['showPrefix'] : true;
[30] Fix | Delete
if ( ! $show_prefix ) {
[31] Fix | Delete
add_filter( 'get_the_archive_title_prefix', '__return_empty_string', 1 );
[32] Fix | Delete
$title = get_the_archive_title();
[33] Fix | Delete
remove_filter( 'get_the_archive_title_prefix', '__return_empty_string', 1 );
[34] Fix | Delete
} else {
[35] Fix | Delete
$title = get_the_archive_title();
[36] Fix | Delete
}
[37] Fix | Delete
}
[38] Fix | Delete
if ( $is_search ) {
[39] Fix | Delete
$title = __( 'Search results' );
[40] Fix | Delete
[41] Fix | Delete
if ( isset( $attributes['showSearchTerm'] ) && $attributes['showSearchTerm'] ) {
[42] Fix | Delete
$title = sprintf(
[43] Fix | Delete
/* translators: %s is the search term. */
[44] Fix | Delete
__( 'Search results for: "%s"' ),
[45] Fix | Delete
get_search_query()
[46] Fix | Delete
);
[47] Fix | Delete
}
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
$tag_name = isset( $attributes['level'] ) ? 'h' . (int) $attributes['level'] : 'h1';
[51] Fix | Delete
$align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
[52] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
[53] Fix | Delete
return sprintf(
[54] Fix | Delete
'<%1$s %2$s>%3$s</%1$s>',
[55] Fix | Delete
$tag_name,
[56] Fix | Delete
$wrapper_attributes,
[57] Fix | Delete
$title
[58] Fix | Delete
);
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Registers the `core/query-title` block on the server.
[63] Fix | Delete
*
[64] Fix | Delete
* @since 5.8.0
[65] Fix | Delete
*/
[66] Fix | Delete
function register_block_core_query_title() {
[67] Fix | Delete
register_block_type_from_metadata(
[68] Fix | Delete
__DIR__ . '/query-title',
[69] Fix | Delete
array(
[70] Fix | Delete
'render_callback' => 'render_block_core_query_title',
[71] Fix | Delete
)
[72] Fix | Delete
);
[73] Fix | Delete
}
[74] Fix | Delete
add_action( 'init', 'register_block_core_query_title' );
[75] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function