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 filter to globally disable font loading #344

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zackpyle
Copy link

This PR adds a filter that allows users to globally disable custom font loading.

Changes

  • Adds code_block_pro_load_fonts filter with default value of true
  • Passes filter value to JavaScript through window.codeBlockPro.loadFonts
  • Adds check in handleFontLoading to respect filter setting

Usage

Users can disable font loading globally by adding this to their theme or plugin:

add_filter('code_block_pro_load_fonts', '__return_false');

Add support for the code_block_pro_load_fonts filter by checking loadFonts value before initiating font loading. This allows users to globally disable custom font loading via a filter when needed.

This change:
- Short-circuits font loading if loadFonts is false
- Maintains backward compatibility
Add code_block_pro_load_fonts filter to allow global control over font loading behavior. The filter value is passed to the frontend JavaScript contexts through the codeBlockPro object.

Implementation:
- Adds new loadFonts property to window.codeBlockPro
- Default value of true maintains existing behavior
- Can be disabled via add_filter('code_block_pro_load_fonts', '__return_false')
@KevinBatdorf
Copy link
Owner

It's a good idea but my only concern here is adding a new api I'd have to support forever, and I'm about to start a rewrite of the plugin. In the rewrite I want to have global profiles that would make changes like this trivial. It will be a lot of work though to rewrite it.

Were you not able to do it by nulling the plugin Url?

@zackpyle
Copy link
Author

I was just worried that since it wasn't specific to the fonts that it wasn't necessary a permanent solution

@KevinBatdorf
Copy link
Owner

The only thing that would mess up is whether I added a new feature that pulled in an external asset which I can't imagine doing.

I think you're safe to do it but I'll think a bit more on adding an API to disable it directly too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants