You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are 2 options for this issue to be implemented.
Case 1: Managing exclusion through JavaScript.
This feature is kinda already implemented. So it could be modified & improved.
At the moment based on #7302 we get a filter here named rocket_preload_fonts_system_fonts which is added to custom data for the beacon to be picked up.
We could rename this filter to be rocket_preload_fonts_excluded_fonts so we could give the beacon the excluded fonts list and it will be managed by the beacon script.
Case 2: Managing exclusions through php
The beacon script detects all kind of fonts, and we manage the exclusion in PHP.
For this, we could add a method in inc/Engine/Media/PreloadFonts/AJAX/Controller.phpremove_excluded_fonts($fonts),
In this newly added method,
we could apply a filter rocket_preload_fonts_excluded_fonts that would return an array of excluded fonts.
Do a loop through the $fonts array to check if the font is within the excluded font array and if this is the case remove them.
It would return the edited fonts array.
/** * Removes excluded fonts from the list of fonts to be preloaded. * * @param array $fonts Array of font URLs to be preloaded. * * @return array Filtered array of fonts, excluding those specified in the exclusion list. */publicfunctionremove_excluded_fonts( array$fonts ) {
// Get the array of excluded fonts from the filter.$excluded_fonts = wpm_apply_filters_typed('array', 'rocket_preload_fonts_excluded_fonts', [] );
// Filter out the excluded fonts.$filtered_fonts = array_filter( $fonts, function( $font ) use ( $excluded_fonts ) {
return ! in_array( $font, $excluded_fonts, true );
} );
return$filtered_fonts;
}
User Story
As an admin, I want a filter to exclude fonts from preload fonts
Acceptance Criteria
The text was updated successfully, but these errors were encountered: