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

Google Fonts: fix warning when webfonts API not available #23306

Closed

Conversation

creativecoder
Copy link
Contributor

@creativecoder creativecoder commented Mar 8, 2022

Small follow up to #23045

Prevents a warning when the Webfonts API is not available (from the Gutenberg plugin).

PHP Warning:  call_user_func_array() expects parameter 1 to be a valid callback, class '\Automattic\Jetpack\Fonts\Google_Fonts_Provider' not found in /Users/Grant/Automattic/Sites/wordpress-develop/src/wp-includes/class-wp-hook.php

Does this pull request change what data or activity we track or use?

No.

Testing instructions:

See #23045 for more detalis.

  • Enable the module and check that Google fonts are available.
  • Enable and disable the Gutenberg plugin and make sure no errors are logged.

@creativecoder creativecoder added the [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. label Mar 8, 2022
@creativecoder creativecoder requested review from jeherve and a team March 8, 2022 22:32
@creativecoder creativecoder self-assigned this Mar 8, 2022
@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Mar 8, 2022
@creativecoder creativecoder changed the title Google Fonts: fix error when webfonts API not available Google Fonts: fix warning when webfonts API not available Mar 8, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2022

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: April 5, 2022.
  • Scheduled code freeze: March 29, 2022.

@github-actions github-actions bot added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Mar 8, 2022
@creativecoder creativecoder added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Mar 8, 2022
@jeherve jeherve added [Package] Google Fonts Provider This package no longer exists in the monorepo. [Type] Bug When a feature is broken and / or not performing as intended labels Mar 9, 2022
@jeherve jeherve added this to the jetpack/10.8 milestone Mar 9, 2022
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

This got me thinking about a different approach to this. I opened #23322 to show it to you. Let me know what you think about it!

@jeherve jeherve added [Pri] Normal [Status] Blocked / Hold and removed [Status] In Progress [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Mar 9, 2022
@creativecoder
Copy link
Contributor Author

That approach looks good--let's go with that!

kraftbj added a commit that referenced this pull request Mar 14, 2022
…n. (#23322)

* Google Fonts: update method used to preconnect Fonts source domain

Follow-up to #23045

Let's favor using a Core implementation with a Core filter instead of manually adding to the head.

* Use filter instead of action

* Only add resource hint if the site supports the Webfonts API

See #23306

* Update readme with latest method name.

* Introduce new class that doesn't depend on WP_Webfonts_Provider

WP_Webfonts_Provider may not always be available, so we cannot call a method from a child class of `WP_Webfonts_Provider` from a WP filter. Let's introduce a new class instead, that doesn't depend on anything, and do the class check inside there. That should simplify things a bit for the folks having to implement that filtering.

Co-authored-by: Brandon Kraft <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Google Fonts Provider This package no longer exists in the monorepo. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Normal [Status] Blocked / Hold [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants