PluginProbe
Gutenberg / 14.5.2
Gutenberg v14.5.2
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
← All changes | build/block-library/blocks/query-title.php +28 -2 12.6.0 → 14.5.2 View file →
@@ -16,15 +16,41 @@
16 16 */
17 17 function gutenberg_render_block_core_query_title( $attributes ) {
18 18 $type = isset( $attributes['type'] ) ? $attributes['type'] : null;
19 19 $is_archive = is_archive();
20 - if ( ! $type || ( 'archive' === $type && ! $is_archive ) ) {
20 + $is_search = is_search();
21 + if ( ! $type ||
22 + ( 'archive' === $type && ! $is_archive ) ||
23 + ( 'search' === $type && ! $is_search )
24 + ) {
21 25 return '';
22 26 }
23 27 $title = '';
24 28 if ( $is_archive ) {
25 - $title = get_the_archive_title();
29 + $show_prefix = isset( $attributes['showPrefix'] ) ? $attributes['showPrefix'] : true;
30 + if ( ! $show_prefix ) {
31 + $filter_title = function( $title, $original_title ) {
32 + return $original_title;
33 + };
34 + add_filter( 'get_the_archive_title', $filter_title, 10, 2 );
35 + $title = get_the_archive_title();
36 + remove_filter( 'get_the_archive_title', $filter_title, 10, 2 );
37 + } else {
38 + $title = get_the_archive_title();
39 + }
26 40 }
41 + if ( $is_search ) {
42 + $title = __( 'Search results' );
43 +
44 + if ( isset( $attributes['showSearchTerm'] ) && $attributes['showSearchTerm'] ) {
45 + $title = sprintf(
46 + /* translators: %s is the search term. */
47 + __( 'Search results for: "%s"' ),
48 + get_search_query()
49 + );
50 + }
51 + }
52 +
27 53 $tag_name = isset( $attributes['level'] ) ? 'h' . (int) $attributes['level'] : 'h1';
28 54 $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
29 55 $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
30 56 return sprintf(