Skip to content

Instantly share code, notes, and snippets.

@btxtiger
Last active July 5, 2024 07:22
Show Gist options
  • Save btxtiger/3fb6b0c0fb73d64515eaaaf36e3c4f40 to your computer and use it in GitHub Desktop.
Save btxtiger/3fb6b0c0fb73d64515eaaaf36e3c4f40 to your computer and use it in GitHub Desktop.
WordPress Local FontAwesome with Plugin

WordPress FontAwesome Local Hosting with plugin features

This Tutorial is about how to use the Official FontAwesome WordPress Plugin with DSGVO/GDPR compatible local font hosting.

1. Install and activate the plugin

https://wordpress.org/plugins/font-awesome/

2. Download the font package

https://use.fontawesome.com/releases/v6.4.2/fontawesome-free-6.4.2-web.zip
Unzip & upload the whole folder to wp-content/uploads/fontawesome

3. Load the uploaded font into the site

Add this CSS resource link into your page header

<!-- FontAwesome Local -->
<link href="/wp-content/uploads/fontawesome/css/all.min.css" rel="stylesheet">

You can use this plugin to do this: https://wordpress.org/plugins/custom-codes/

4. Disable CDN loading from the FontAwesome plugin

Add this custom PHP code, you can to this with the same custom-codes plugin as suggested

// Disable load FontAwesome from CDN
add_action('wp_enqueue_scripts', static function() {
    wp_dequeue_style('font-awesome-official');
    wp_deregister_style('font-awesome-official');
}, 20);

5. Configure the plugin settings

https://your-site.com/wp-admin/options-general.php?page=font-awesome
Make sure the plugin is configured this way:

  • Use CDN
  • Free
  • Web Font
  • Version 6.4.2
  • Compatibility off
@benhenn
Copy link

benhenn commented Jul 4, 2024

Somehow the CSS resource link:
"/wp-content/uploads/fontawesome/css/all.min.css" rel="stylesheet"

Creates an error saying: "Updating Failed. The Response is Not a Valid JSON Response" every time I save a page.

@btxtiger
Copy link
Author

btxtiger commented Jul 4, 2024

@benhenn Are you using the custom-codes plugin? Or how are inserting the snippet ?
If the CSS URI was wrong, it would produce a 404 error, not a json error.

@benhenn
Copy link

benhenn commented Jul 4, 2024

@btxtiger Yep! Im using the custom-codes plugin to insert the CSS resource link. Only if I disable the FontAwesome Local code (CSS resource link), the json error is gone. I don't know why. URI is correct. Icons are loading locally.

@btxtiger
Copy link
Author

btxtiger commented Jul 4, 2024

@benhenn are you using the correct editor type ?

image

@benhenn
Copy link

benhenn commented Jul 5, 2024

@btxtiger Ahhhh that's it! Thanks a lot! Great work 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment