PluginProbe
Gutenberg / 10.5.3
Gutenberg v10.5.3
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
gutenberg / build / block-library / blocks / tag-cloud.php

tag-cloud.php in Gutenberg 10.5.3, at build/block-library/blocks/tag-cloud.php

55 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Server-side rendering of the `core/tag-cloud` block.
4 *
5 * @package WordPress
6 */
7
8 /**
9 * Renders the `core/tag-cloud` block on server.
10 *
11 * @param array $attributes The block attributes.
12 *
13 * @return string Returns the tag cloud for selected taxonomy.
14 */
15 function gutenberg_render_block_core_tag_cloud( $attributes ) {
16 $args = array(
17 'echo' => false,
18 'taxonomy' => $attributes['taxonomy'],
19 'show_count' => $attributes['showTagCounts'],
20 );
21 $tag_cloud = wp_tag_cloud( $args );
22
23 if ( ! $tag_cloud ) {
24 $labels = get_taxonomy_labels( get_taxonomy( $attributes['taxonomy'] ) );
25 $tag_cloud = esc_html(
26 sprintf(
27 /* translators: %s: taxonomy name */
28 __( 'Your site doesn&#8217;t have any %s, so there&#8217;s nothing to display here at the moment.' ),
29 strtolower( $labels->name )
30 )
31 );
32 }
33
34 $wrapper_attributes = get_block_wrapper_attributes();
35
36 return sprintf(
37 '<p %1$s>%2$s</p>',
38 $wrapper_attributes,
39 $tag_cloud
40 );
41 }
42
43 /**
44 * Registers the `core/tag-cloud` block on server.
45 */
46 function gutenberg_register_block_core_tag_cloud() {
47 register_block_type_from_metadata(
48 __DIR__ . '/tag-cloud',
49 array(
50 'render_callback' => 'gutenberg_render_block_core_tag_cloud',
51 )
52 );
53 }
54 add_action( 'init', 'gutenberg_register_block_core_tag_cloud', 20 );
55