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

[Feature Request] Filter to remove fontawesome #566

Closed
1 task done
androidacy-user opened this issue Sep 9, 2023 · 6 comments · Fixed by #575
Closed
1 task done

[Feature Request] Filter to remove fontawesome #566

androidacy-user opened this issue Sep 9, 2023 · 6 comments · Fixed by #575
Labels

Comments

@androidacy-user
Copy link
Contributor

Describe the feature that you'd like

Hello!

Since we use FontAwesome Pro, we remove the default FA styles provided by this theme. However, currently we have to manually edit the functions.php from the parent theme, as trying to override it in the child theme is hit and miss and requires us to mess with priorities which causes other conflicts anyway.

We'd like to see a filter (i.e., "bootscore_fontawesome_enqueue") or similar that can prevent this arguably non-essential file from being loaded.

Why is this feature needed? What problem does it solve?

Some people like us may prefer to use their own version of fontawesome or even remove it entirely.

Checklist

  • I have searched the issues and this feature has not been requested.
@crftwrk
Copy link
Member

crftwrk commented Sep 9, 2023

If you have an idea, please create a PR. But @justinkruit is FA pro user as well, maybe he has an idea or can quickly explain how he solves that.

@justinkruit
Copy link
Member

I see the mentioned using priorities etc. Have you tried making a new function in your child theme, dequeue fontawesome in there, and then register that function as a hook with a later priority? That should solve this issue. (Can't write an example at the moment, as I'm on my phone haha)

@androidacy-user
Copy link
Contributor Author

I see the mentioned using priorities etc. Have you tried making a new function in your child theme, dequeue fontawesome in there, and then register that function as a hook with a later priority? That should solve this issue. (Can't write an example at the moment, as I'm on my phone haha)

That's more work than a // on the enqueue or a add_filter('who_says_you_cant_code_onmobile', '__retrun_false');. The idea here is to make it as easy as possible to opt out of FA.

@justinkruit
Copy link
Member

That's more work than a // on the enqueue or a add_filter('who_says_you_cant_code_onmobile', '__retrun_false');. The idea here is to make it as easy as possible to opt out of FA.

Function "__retrun_false" not found. Maybe develop on pc? 😜

Currently looking into this, with the idea to add more filters in general.

justinkruit added a commit that referenced this issue Sep 15, 2023
@androidacy-user
Copy link
Contributor Author

That's more work than a // on the enqueue or a add_filter('who_says_you_cant_code_onmobile', '__retrun_false');. The idea here is to make it as easy as possible to opt out of FA.

Function "__retrun_false" not found. Maybe develop on pc? 😜

Currently looking into this, with the idea to add more filters in general.

That's probably exactly why I misspelled that lolol. Used to autocorrect from mobile.

@smileBeda
Copy link
Contributor

smileBeda commented Oct 29, 2023

So, if I am not totally obtuse, you can and should do this:

  1. In the child theme do the usual parent and child themes styles enqueue stuff. So generally that means add_action( 'wp_enqueue_scripts', 'bootscore_child_enqueue_styles' ); and in the CB, you just use the default parent enqueue and child enqueue
  2. Then, in the child theme, in a separate callback you do add_action( 'wp_enqueue_scripts', 'go_away', 11 ); where the CB does:
function go_away(){
	wp_dequeue_style( 'fontawesome' );
}

This should work. The reason you need priority 11 is that the parent theme uses default 10, and if you load this dequeue on the same priority it wont work. You could of course also go max and use PHP_INT_MAX - 2 just to leave some space for someone to re-enqueue it after (you never know)

I suggest to also do remove_filter('style_loader_tag', 'bootscore_fa_preload'); so you do not get any overhead (even if the fa styles are gone, this fn still runs unless you remove it)

This should do the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants