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

Duotone: Avoid rendering duplicate stylesheet and SVG #33233

Merged
merged 2 commits into from
Jul 7, 2021

Conversation

Mamaduka
Copy link
Member

@Mamaduka Mamaduka commented Jul 6, 2021

Description

Adds check to avoid rendering duplicate stylesheet and SVG elements when the plugin is used with WP 5.8.

How has this been tested?

  1. Create a post.
  2. Add an Image block.
  3. Select the Duotone option.
  4. Save the post.
  5. On the front-end, WP shouldn't render duplicated stylesheet and SVG for Duotone.

Screenshots

CleanShot 2021-07-06 at 21 11 27

Types of changes

Bugfix

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Block] Cover Affects the Cover Block - used to display content laid over a background image [Block] Image Affects the Image Block labels Jul 6, 2021
@Mamaduka Mamaduka self-assigned this Jul 6, 2021
@Mamaduka Mamaduka requested a review from ajlende July 6, 2021 17:25
)
);
add_filter( 'render_block', 'gutenberg_render_duotone_support', 10, 2 );
// This can be removed when plugin support requires WordPress 5.8.0+.
Copy link
Member

Choose a reason for hiding this comment

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

This basically uses the wp-code if it is present. It makes future changes in the plugin impossible to do because the core version is going to be used. Could we remove the core filters instead if they are present?

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 sense. I'll update the code.

This is a pattern I've seen before in Gutenberg core and the only reason I've used it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done ✅

P.S. I pushed a similar fix for Group Block layout support. Do you want me to update logic there as well to use remove_filter?

Copy link
Contributor

@ajlende ajlende left a comment

Choose a reason for hiding this comment

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

Tested locally, and it's working fine for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Block] Image Affects the Image Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants