Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Runar Posted September 17, 2020 Posted September 17, 2020 I'm working on a plugin with a CSS file, and some of the values in this file comes from the plugin settings. What I need is a way to rebuild the CSS files (custom.css?) when the plugin settings are changed. With my current code I'll have to edit my theme and save custom.css (without making any changes) for the new values to show up. There must be a better way?
Solution bfarber Posted September 18, 2020 Solution Posted September 18, 2020 \IPS\Theme::deleteCompiledCss();
Runar Posted September 18, 2020 Author Posted September 18, 2020 4 hours ago, bfarber said: \IPS\Theme::deleteCompiledCss(); Thank you, but this requires a force reload of the page (to clear the browser cache), as the CSS files are updated but the version parameter stays the same. Is there any way to update the version parameter of the custom.css file as well? Similar to what happens when you save a file in the theme editor.
bfarber Posted September 21, 2020 Posted September 21, 2020 if ( $app === null ) { /* Each theme... */ foreach( static::themes() as $id => $set ) { if ( $themeId === null OR \in_array( $id, array_keys( $themeSets ) ) ) { \IPS\File::getClass( 'core_Theme')->deleteContainer('css_built_' . $set->_id ); $set->css_map = array(); $set->css_updated = time(); $set->save(); } } /* ACP CSS */ \IPS\Settings::i()->changeValues( array( 'acp_css_map' => '[]' ) ); \IPS\File::getClass( 'core_Theme' )->deleteContainer( 'css_built_0' ); /* Done */ return; } The css_updated parameter is what's used for the version parameter.
Runar Posted September 23, 2020 Author Posted September 23, 2020 On 9/21/2020 at 3:32 PM, bfarber said: The css_updated parameter is what's used for the version parameter. It seems the 4.5.0 version of the deleteCompiledCss() function does not update the css_updated parameter (the relevant line is missing for me). This must be why the version parameter is not updated on my test install. Thank you for your help!
bfarber Posted September 24, 2020 Posted September 24, 2020 I do believe that was fixed in a maintenance release so I would recommend updating if that's missing.
Recommended Posts