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

Improve function name for finding navigation links that use the featured image #40904

Merged
merged 1 commit into from
May 8, 2022

Conversation

draganescu
Copy link
Contributor

Follow up to #40572

@costdev added this comment after the PR was merged, I think the points all made sense so I made a follow up PR:

#40572 (comment)

Some notes on this:

  1. The function is called block_core_post_template_uses_feature_image().

Shouldn't this be block_core_post_template_uses_featured_image()?

This occurs on lines 15, 23 and 66.

  1. The docblock description is inaccurate:

Loop through recursively to find blocks that use featured images.

This function tries to find one block that uses the featured image, then returns immediately.

Suggest this instead:

Determines whether a block list contains a block that uses the featured image.

  1. The docblock for this function has no description for the @return value.

Suggest this:

@return bool Whether the block list contains a block that uses the featured image.
  1. This conditional:
if ( 'core/cover' === $block->name && $block->attributes && isset( $block->attributes['useFeaturedImage'] ) && $block->attributes['useFeaturedImage'] ) {

can be shortened to:

if ( 'core/cover' === $block->name && ! empty( $block->attributes['useFeaturedImage'] ) ) {

@draganescu draganescu requested a review from ajitbohra as a code owner May 7, 2022 11:54
@draganescu draganescu added the [Type] Code Quality Issues or PRs that relate to code quality label May 7, 2022
@draganescu draganescu added the Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label May 8, 2022
@draganescu draganescu merged commit 57a1daf into trunk May 8, 2022
@draganescu draganescu deleted the fix/nav-cache-nits branch May 8, 2022 08:48
@github-actions github-actions bot added this to the Gutenberg 13.3 milestone May 8, 2022
@adamziel
Copy link
Contributor

I've cherry-picked this to wp/6.0 branch to be included in WordPress 6.0 RC2 later today 894fd79

adamziel pushed a commit that referenced this pull request May 10, 2022
@adamziel adamziel removed the Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants