Prevent backlight from contacting fontawesome.com

Hi Rod,
i solved the problem by manually installing fontawesome in wordpress. Now the icons are shown in the menu again.

Thank you and best regards,
Oliver

So, hereā€™s the function in the WP Theme that enqueues Font Awesome.

if ( !function_exists('font_awesome') ):
	function font_awesome() {
		// ...
	}
endif;
add_action('wp_footer', 'font_awesome', 22);

In a child theme, you should be able to override this by creating your own ā€œfont_awesomeā€ function, to wit:

function font_awesome() {
	// echo your code for local Font Awesome resources.
}
add_action('wp_footer', 'font_awesome', 22);

I thought we had an article on child theming, but maybe that was an older version of the site or docs, or Iā€™m imagining it. @rod_barbee, do you have any articles about it?

No. But I also think you might have had one way back when.

Matt, thank you!
Do I have to copy

if ( !function_exists('font_awesome') ):
	function font_awesome() {
		// ...
	}
endif;
add_action('wp_footer', 'font_awesome', 22);

into the WP functions.php?

Best regards,
Oliver

The best way is to make a child theme. That way, when thereā€™s a backlight update, it would not overwrite your changes. Looking at the source code, Matt already designed the Backlight theme to have a custom fontawesome loader :slight_smile: This means that you donā€™t need to add anything to your themeā€™s functions.php file.

There are many tutorials out there to make a child theme. This one is from Wordpress: Create a Child Theme ā€“ WordPress.com Support

As far as I remember, here are the minimal steps to create a child theme. The code shown is based on what Iā€™m using on my site. Assuming your Backlight theme name is bl_theme, I would call the child theme bl_theme_child

  1. Make a directory in blog/wp-content/themes/bl_theme_child. This assumes that the Wordpress installation is in /blog, change this according to where you have WP installed.
  2. In the child theme directory, create a file style.css with following content:
/*
 Theme Name:   Backlight Theme Child
 Template: bl_theme
*/
  1. In the child theme directory, create the file functions.php with following content
<?php
function bl_theme_child_enqueue_styles() {
	// Add local style
	wp_enqueue_style('child-theme', get_stylesheet_directory_uri() .'/style.css', array('parent-theme'));
}
add_action( 'wp_enqueue_scripts', 'bl_theme_child_enqueue_styles' );

// Add font_awesome
function font_awesome() {
	// echo your code for local Font Awesome resources.
}
add_action('wp_footer', 'font_awesome', 22);

?>

Obviously, you still need to add your local font awesome code.

  1. Select your new child theme in the Wordpress backend.

This is what Iā€™m basically using right now. Looking at some of the tutorials out there, there are many other options that might be of value. But this seems to work for me :wink:

Hope this helps!

3 Likes

Daniel,
thanks for your detailed explanation.
:+1:

Best regards,
Oliver

Please let me know if it works for you!

Rod, I went to your page and followed the instructions for loading FA locally. I turned on the ā€œLoad Font Awesome resources locallyā€ by selecting yes. Your page says Backlight will create a folder ā€œfontawesomeā€ inside the backlight/custom/ folder. Is this only AFTER the new version is installed? Iā€™m on framework 5.1.1 and when I did the above, it did not create the fontawsomefolder. Is this whole thread something I have to do when the new modules come out, and when they do come out, does font awesome pro (ā€œfaā€) have to be changed or will it continue to work as in the past? Also, I use a google font, ā€œQuattrocento sansā€ that has a stylesheet link to

https://fonts.googleapis.com/css?family=Quattrocento|Quattrocento+Sans&display=swap

Is that a problem as well?

@michaelboatright Donā€™t worry about doing this right now. We have an update releasing soon that revamps Font Awesome to no longer use a CDN.

1 Like

When I enabled that feature, the folder was created.

But Mattā€™s about to release the update that will load Font Awesome 5 Free locally. In fact, the update removes the option to load locally, it just will be.

If using the far prefix, you may need to change it to fas.

More on that in this thread: Upcoming Changes to Font Awesome

Thanksā€¦I read that. What about fa & fab? Quattrocento & Quattrocento+Sans?

I donā€™t know. Check the Font Awesome site to see if those are included in Font Awesome 5 free version.

OK, it was a bit of a dumb question. It looks like some far (fa-regular) icons, such as far fa-envelope are included in the free version as well as some fab (fa-brands): fab fa-instagram, fab fa-facebook, fab fa-linkedin and fab fa-youtube that I use.

Backlight 5.2.0 is now live.

2 Likes

I just noticed in my Backlight WordPress theme pages, the Font Awesome use in the parent menu is showing [?] instead of the \f107.

Yet when I go to a Backlight photo page (published via Lightroom), those pages do have the right icon. Itā€™s only the pages in the WordPress theme that are broken.

More crazy, when Iā€™m logged into my siteā€™s WordPress backend the menu icon is shown correctly. Itā€™s only when not logged in.

I searched around trying to sort this out and just gave up. So here I am, asking the group.

Why does the WordPress theme pages for Backlight 5.0.3 have the broken Font Awesome in the menu?

Iā€™ve updated all the modules, which are mostly 5.4.0. My photo pages are a mix of Pangolin modules 5.0.1, 5.0.7, 5.3.0 (thatā€™s what I get after the update).

you can find what Iā€™m seeing at reekes.net (try Home and then Photography). Works under Photography which are Pangolin pages. Itā€™s broken under all other pages, which are Backlight WP Theme pages.

Hi Jim,

Are you using the latest version?

The Turning Gateā€™s blog includes the FontAwesome CSS:

<link rel="stylesheet" id="fontawesome5free-css" href="https://backlight.theturninggate.net/backlight/modules/module-admin/lib/css/all.min.css?ver=6.2.3" type="text/css" media="all">

However, Iā€™m not seeing that asset in your page source. Did you replace the HEAD section of the page with your own?

I also notice a missing icon in your albums in the large image display. The image menu icon in the upper right shows the unicode rather than the image icon.

have you tried clearing template cache?

I had a similar issue with WordPress sites not long ago. Turned out that I was using a different site url in the WordPress settings than what my Backlight site url was set to.
(mainly the difference between the subdomain url and the simpler url I assigned: ttg-tips.barbeephoto.com vs ttg-tips.com, for example) or my main site, which can be reached at barbeephoto.com or rodbarbee.com.

Anyway, I needed to reconcile those.

So Iā€™m wondering if your Backlight site URL exactly matches the Site Address URL in WordPress general settings. e.g. http:// vs https://

Are you using the latest version?

Thereā€™s no option to update the modules, so Iā€™m assuming I do have the latest. I noticed the problem after updating a couple days ago. Hereā€™s the main modules and versionsā€¦

module-framework 5.4.0
module-admin 5.4.0
module-designer 5.4.0
module-publisher 7.4.0
module-pages 5.0.2
custom-resources 5.3.3
pangolin-wordpress 5.0.3

Iā€™ve tried clearing the cache and exporting the them to WP.

Turning Gateā€™s blog includes the FontAwesome CSS

No idea whatā€™s going on there. I think this is the root cause.

Did you replace the HEAD section of the page with your own?

Nope. Itā€™s all entirely being created by Backlight. I havenā€™t changed anything within WP (not that I can recall). Searching through all the settings in both BL and WP I donā€™t see how/why thereā€™s a problem.

menu icon in the upper right shows the unicode rather than the image icon

Where? I canā€™t find this one. I only see this problem on the WP theme pages, not in the BL photo pages.

Backlight site URL exactly matches the Site Address URL in WordPress

Theyā€™re the same, and that hasnā€™t changed in years.

In Backlight the WP theme advanced option for ā€œFont Awesome Version Supportā€ is set to true. I also tried false (then flush/export), but it didnā€™t change anything. I even added flushing my siteā€™s cache after the change.

My siteā€™s functions.php only enqueue the BL styles for the chile theme. I also try activating the BL theme directly.

I found another problem with FontAwesome at the bottom of Jim Reekes RĆ©sumĆ© | Jim Reekes. The 3 buttons used to have icons, but only 1 does now. Thereā€™s a ::before for the button text that was inserting an icon, but thatā€™s also broken? I think thatā€™s another issue about FontAwesome I donā€™t understand.

The only real change thatā€™s happened in years is updating BL. I suspect I missed this change some time ago (last year?). All the caching in browsers, servers, ā€¦ and I probably missed it. Just noticed it the other way when I did an BL update.

PS ā€“ hmm, seems like the site isnā€™t getting CSS files. In BL I created a jim-style.css but donā€™t find it being copied to the WP Theme. Also sounds like what Matt pointed out about the missing FontAwesome CSS file.

This is a strange clue. When Iā€™m logged into WP the CSS files are there. But when I log out, or use a private browsing window, the CSS is missing. Chrome security biting me?

Hmm, do I need to setup a free account at FontAwesome, and then download their kit, and so on and so on? I tried following what they are saying about getting fonts but I got lost. I havenā€™t been paying attention to them, but it seems they completely changed their world.

Do I need to use their plugin, add scripts or something? I only have a few icons Iā€™m using.