Skip to content

Commit

Permalink
Tag Cloud: Improve state of block with no tags (#63774)
Browse files Browse the repository at this point in the history
* Render nothing when no tags are available in tag cloud block

* Added condition to display placeholder in editor

* Fix phpcs errors

* Use wp_is_serving_rest_request function for conditional check

Co-authored-by: akasunil <sunil25393@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
  • Loading branch information
4 people committed Aug 22, 2024
1 parent 8572b17 commit cf4d798
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/block-library/src/tag-cloud/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ function render_block_core_tag_cloud( $attributes ) {
);
$tag_cloud = wp_tag_cloud( $args );

if ( ! $tag_cloud ) {
$tag_cloud = __( 'There&#8217;s no content to show here yet.' );
if ( empty( $tag_cloud ) ) {
// Display placeholder content when there are no tags only in editor.
if ( wp_is_serving_rest_request() ) {
$tag_cloud = __( 'There&#8217;s no content to show here yet.' );
} else {
return '';
}
}

$wrapper_attributes = get_block_wrapper_attributes();
Expand Down

0 comments on commit cf4d798

Please sign in to comment.