Open piotrbak opened 2 weeks ago
This should be pick up after #7063 is completed.
In the rewrite_fonts
created in #7063 we check if the filter is true, if true we then the css will be printed as internal in the head tag.
WP_Filesystem_Direct
should be added to the class constructor of the Controller class which would have been created in previous task.
Sample code
$internal_styling = wpm_apply_filters_typed( 'boolean', 'rocket_internal_fonts_styling', false );
if( $internal_styling ) {
return $this->set_font_internal_style( $html, $css_path );
}
private function set_font_internal_style( $html, $css_path ) {
if ( ! preg_match( '#</title\s*>#', $html, $matches ) ) {
return $html;
}
$title = $matches[0];
$internal_style = $title;
if ( ! $this->filesystem->exists( $css_path ) ) {
return $html;
}
$css = '<style data-wpr-hosted-gf-parameters>'
$css .= $this->filesystem->get_contents( $css_path );
$css .= '</style>';
return $css;
}
LGTM
Looks good to me as well
User Story As a user, I’d like to be able to print the Google Fonts CSS as an internal style
Acceptance Criteria
data-wpr-hosted-gf-parameters
argument