equal
deleted
inserted
replaced
28 ); |
28 ); |
29 |
29 |
30 $tag_cloud = wp_tag_cloud( $args ); |
30 $tag_cloud = wp_tag_cloud( $args ); |
31 |
31 |
32 if ( ! $tag_cloud ) { |
32 if ( ! $tag_cloud ) { |
33 $tag_cloud = esc_html( __( 'No terms to show.' ) ); |
33 $labels = get_taxonomy_labels( get_taxonomy( $attributes['taxonomy'] ) ); |
|
34 $tag_cloud = esc_html( |
|
35 sprintf( |
|
36 /* translators: %s: taxonomy name */ |
|
37 __( 'Your site doesn’t have any %s, so there’s nothing to display here at the moment.' ), |
|
38 strtolower( $labels->name ) |
|
39 ) |
|
40 ); |
34 } |
41 } |
35 |
42 |
36 return sprintf( |
43 return sprintf( |
37 '<p class="%1$s">%2$s</p>', |
44 '<p class="%1$s">%2$s</p>', |
38 esc_attr( $class ), |
45 esc_attr( $class ), |
42 |
49 |
43 /** |
50 /** |
44 * Registers the `core/tag-cloud` block on server. |
51 * Registers the `core/tag-cloud` block on server. |
45 */ |
52 */ |
46 function register_block_core_tag_cloud() { |
53 function register_block_core_tag_cloud() { |
47 register_block_type( |
54 register_block_type_from_metadata( |
48 'core/tag-cloud', |
55 __DIR__ . '/tag-cloud', |
49 array( |
56 array( |
50 'attributes' => array( |
|
51 'taxonomy' => array( |
|
52 'type' => 'string', |
|
53 'default' => 'post_tag', |
|
54 ), |
|
55 'className' => array( |
|
56 'type' => 'string', |
|
57 ), |
|
58 'showTagCounts' => array( |
|
59 'type' => 'boolean', |
|
60 'default' => false, |
|
61 ), |
|
62 'align' => array( |
|
63 'type' => 'string', |
|
64 ), |
|
65 ), |
|
66 'render_callback' => 'render_block_core_tag_cloud', |
57 'render_callback' => 'render_block_core_tag_cloud', |
67 ) |
58 ) |
68 ); |
59 ); |
69 } |
60 } |
70 |
|
71 add_action( 'init', 'register_block_core_tag_cloud' ); |
61 add_action( 'init', 'register_block_core_tag_cloud' ); |