Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag Cloud: Improve state of block with no tags #63774

Merged
merged 6 commits into from
Aug 22, 2024
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 @@
);
$tag_cloud = wp_tag_cloud( $args );

if ( ! $tag_cloud ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for chaining ! to empty?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes code more readable in my opinion. Do you need me to revert it to avoid unnecessary changes?

return '';
if ( empty( $tag_cloud ) ) {
// Display placeholder content when there are no tags only in editor.
if ( ( defined('REST_REQUEST') && REST_REQUEST ) || is_admin() ) {

Check failure on line 34 in packages/block-library/src/tag-cloud/index.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Expected 1 spaces after opening parenthesis; 0 found

Check failure on line 34 in packages/block-library/src/tag-cloud/index.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Expected 1 spaces before closing parenthesis; 0 found
$tag_cloud = __( 'There’s no content to show here yet.' );
} else {
return '';
}
}

$wrapper_attributes = get_block_wrapper_attributes();
Expand Down
Loading