Hi
am using the litespeed cache plugin for wordpress, I can't post on the adequate section cause I have no enough permissions! so I posted her ..
I can't figure how to overwrite the generated css file, there is no hook after the creation of css files, am trying to add font-display:swap property after each font-face: , or font-famiy:, I can't find asolution to do it properly, I've created a function inside my functions.php like this :
The issue with this function is the fact that I should always purge cache 2 times before it takes effect for each page!
Is there any best approach than this ? or a hook afer creating the css files ?
Also how Can I get the name (path) of the generated css file for each page?
Thank you.
am using the litespeed cache plugin for wordpress, I can't post on the adequate section cause I have no enough permissions! so I posted her ..
I can't figure how to overwrite the generated css file, there is no hook after the creation of css files, am trying to add font-display:swap property after each font-face: , or font-famiy:, I can't find asolution to do it properly, I've created a function inside my functions.php like this :
PHP:
/*
* Handle Lightroom fonts display
*
* issue: we should update page twice!!
*/
if (!is_admin()){
add_action('init', function(){
if (defined('LSCWP_CONTENT_DIR')){
$update_transient = false;
$new_css_list = array();
$old_css_list = get_transient('my_lscwp_css');
foreach(glob(LSCWP_CONTENT_DIR . '/cache/css/*.css') as $css_file){
if (is_array($old_css_list)){
if (in_array($css_file, $old_css_list)){
continue;
}
}
if ($css_content = @file_get_contents($css_file)){
$css_content = str_replace('@font-face{font-family:','@font-face{font-display:swap;font-family:',$css_content);
if (@file_put_contents($css_file, $css_content )){
$new_css_list[] = $css_file;
$update_transient = true;
}
}
}
if($update_transient){
set_transient('my_lscwp_css',$new_css_list);
}
}
},99);
}
Is there any best approach than this ? or a hook afer creating the css files ?
Also how Can I get the name (path) of the generated css file for each page?
Thank you.
Last edited: