Jump to content

Force rebuild of plugin CSS file/custom.css


Go to solution Solved by bfarber,

Recommended Posts

Posted

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?

Posted
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.

Posted
		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.

Posted
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!

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...