Skip to content

Commit

Permalink
Closes #7104: Remove preload tag if host_fonts_locally is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Miraeld committed Nov 13, 2024
1 parent 810538b commit dcee3f0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions inc/Engine/Optimization/GoogleFonts/AbstractGFOptimization.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,19 @@ protected function get_font_display_value(): string {
* @return string
*/
protected function get_optimized_markup( string $url ): string {
return sprintf(
'<link rel="preload" data-rocket-preload as="style" href="%1$s" /><link rel="stylesheet" href="%1$s" media="print" onload="this.media=\'all\'" /><noscript><link rel="stylesheet" href="%1$s" /></noscript>', // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
$markup = sprintf(
'<link rel="stylesheet" href="%1$s" media="print" onload="this.media=\'all\'" /><noscript><link rel="stylesheet" href="%1$s" /></noscript>', // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
$url
);

if ( ! get_rocket_option( 'host_fonts_locally', false ) ) {
$markup = sprintf(
'<link rel="preload" data-rocket-preload as="style" href="%1$s" />%2$s',
$url,
$markup
);
}

return $markup;
}
}

0 comments on commit dcee3f0

Please sign in to comment.