What is the correct way to enqueu Google Fonts in the theme?

Hello, I uploaded a WordPress theme and they gave a soft reject and told me to enqueue the Google fonts correctly.

Here is the screenshot of how, at the moment, new fonts can be added by a user in the theme: http://envato.d.pr/3asdyO/5oNTKViP

Is this an incorrect way? If yes, then please tell me how to enqueue them in the theme?

I used these articles to enqueue the Google fonts:

  1. https://gist.github.com/kailoon/e2dc2a04a8bd5034682c
  2. http://themeshaper.com/2014/08/13/how-to-add-google-fonts-to-wordpress-themes/

At the moment, to add a new font, we go to Appearance -> Google Fonts. And then that screen appears which is in the screenshot above. In that screen the user can add the Google font link and then it can appear in the Typography section of the WordPress Live Customizer.

Please advise what to do about it and what is not ok.

Thank you!

Hi @CoralWind,

Your approach seems to be ok as long as the enqueue function is placed in functions.php file. Also is the text field sanitized properly?


Hello @lucalogos

Thank you for your reply, The code is added in the functions.php file but maybe the issue was with the sanitization. I have checked into this matter and apparently, the fonts are enqueued properly now.

I have also uploaded the theme for re-submission after the fixes.