Jump to content

Force rebuild of plugin CSS file/custom.css


Runar
Go to solution Solved by bfarber,

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

		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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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