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

Add Cardo and Inter fonts to global styles via theme json filter #47417

Merged
merged 3 commits into from
May 20, 2024

Conversation

ilyasfoo
Copy link
Contributor

@ilyasfoo ilyasfoo commented May 13, 2024

Changes proposed in this Pull Request:

Closes #47441

Addresses p1715591224614979/1715346843.941069-slack-C01SFMVEYAK

This PR experiments adding Cardo and Inter fonts to global styles via wp_theme_json_data_theme, which originally came from TwentyTwentyFour theme. This allows for WooCommerce plugin to use these fonts without the original theme.

This PR is still an experiment due to:

  1. We should think of a better structure to use wp_theme_json_data_theme in WooCommerce, since this piece of code affects the entire site.

Also, follow-up work will be needed to set the fonts in coming soon pages.

How to test the changes in this Pull Request:

  1. Install and activate the FSE Empire theme
  2. Go to WooCommerce > Settings > Site visibility
  3. Ensure Coming soon is selected and Restrict to store pages only is disabled
  4. Go to Appearance > Editor > Templates > Page: Coming soon and edit
  5. Select the center heading and open up Styles > Typography
  6. Observe Cardo and Inter fonts are listed in the option
image

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Comment

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label May 13, 2024
@@ -26,6 +26,7 @@ class ComingSoonRequestHandler {
final public function init( ComingSoonHelper $coming_soon_helper ) {
$this->coming_soon_helper = $coming_soon_helper;
add_filter( 'template_include', array( $this, 'handle_template_include' ) );
add_filter( 'wp_theme_json_data_theme', array( $this, 'filter_theme_json_theme' ) );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Feels awkward to have this in coming soon class since it'll be available for the entire site. Would it be ok temporarily? Or should we generalize for Woo core usage?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we check that woocommerce_coming_soon == 'yes' or that the current page being viewed is coming soon or the template?

Copy link
Contributor Author

@ilyasfoo ilyasfoo May 14, 2024

Choose a reason for hiding this comment

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

@psealock I tried by checking the current page to site-editor.php and the current template, it worked to not load in non-coming soon page. However, due to the way site editor works, the loaded fonts persists even when we switch between templates, which means once we load coming soon page, the fonts will carry through other pages as well 😞

I don't think limiting the font load in site editor will be viable

Copy link
Member

Choose a reason for hiding this comment

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

Would it be ok temporarily? Or should we generalize for Woo core usage?

I think it's fine to have it in the coming soon class for now. We can always refactor it later if needed.

however, due to the way site editor works, the loaded fonts persists even when we switch between templates, which means once we load coming soon page, the fonts will carry through other pages as well

That makes sense. 😞

As @psealock suggested, could we check that woocommerce_coming_soon == 'yes'? That way, we can ensure that the fonts are only loaded when the coming soon mode is enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

woocommerce_coming_soon == 'yes'?

@chihsuan @psealock Sorry I forgot to address that. I think it'll be a problem since we're checking this for both site-editor and frontend. While site live, users still can edit coming soon page, so the fonts will need to exist regardless of the coming soon state.

Copy link
Member

Choose a reason for hiding this comment

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

I see. That makes sense!

@ilyasfoo ilyasfoo requested review from a team, chihsuan and rjchow May 13, 2024 14:57
Copy link
Contributor

github-actions bot commented May 13, 2024

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Test this pull request with WordPress Playground.

Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit.

Copy link
Contributor

Hi @chihsuan, @rjchow, @woocommerce/ghidorah

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Copy link
Member

@chihsuan chihsuan left a comment

Choose a reason for hiding this comment

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

Thanks, tested well! Confirmed that Cardo and Inter fonts are listed in the option. 👍

@ilyasfoo ilyasfoo changed the title Try add Cardo and Inter fonts to global styles via theme json filter Add Cardo and Inter fonts to global styles via theme json filter May 17, 2024
@ilyasfoo ilyasfoo merged commit 815d23b into trunk May 20, 2024
25 checks passed
@ilyasfoo ilyasfoo deleted the try/lys-add-custom-font-to-global-style branch May 20, 2024 08:44
@github-actions github-actions bot added this to the 9.0.0 milestone May 20, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label May 20, 2024
@rodelgc rodelgc added needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Launch Your Store] Add custom fonts for coming soon pages
4 participants