I am building a wordpress theme, I reach the step of finalization.
Right now, I am struggling to fix an error raised by Theme Check, :
file_get_contents was found in the file functions.php File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls.
Here the code:
function theme_critical() {
$critical_css = file_get_contents( get_template_directory() . '/css/critical.css');
echo '<style>' . $critical_css . '</style>';
}
Basicaly, this code take the content of a CSS file, to print it in the header. This is a critical css.
I searched, but I could not find a way to use WP_filesystem to simply to the same thing than file_get_content does.
Is anyone already faced this issue?
Thanks.