Merge pull request #1671 from ArthurHoaro/fix/plugin-colors-update
Fix default_colors plugin: update CSS file on color change
This commit is contained in:
commit
ed4ee8f029
2 changed files with 37 additions and 0 deletions
|
@ -46,6 +46,20 @@ function default_colors_init($conf)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When plugin parameters are saved, we regenerate the custom CSS file with provided settings.
|
||||
*
|
||||
* @param array $data $_POST array
|
||||
*
|
||||
* @return array Updated $_POST array
|
||||
*/
|
||||
function hook_default_colors_save_plugin_parameters($data)
|
||||
{
|
||||
default_colors_generate_css_file($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* When linklist is displayed, include default_colors CSS file.
|
||||
*
|
||||
|
|
|
@ -193,4 +193,27 @@ public function testFormatCssRuleInvalid()
|
|||
$result = default_colors_format_css_rule($data, '');
|
||||
$this->assertEmpty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that a new CSS file is generated when save_plugin_parameters hook is triggered.
|
||||
*/
|
||||
public function testHookSavePluginParameters(): void
|
||||
{
|
||||
$params = [
|
||||
'other1' => true,
|
||||
'DEFAULT_COLORS_BACKGROUND' => 'pink',
|
||||
'other2' => ['yep'],
|
||||
'DEFAULT_COLORS_DARK_MAIN' => '',
|
||||
];
|
||||
|
||||
hook_default_colors_save_plugin_parameters($params);
|
||||
$this->assertFileExists($file = 'sandbox/default_colors/default_colors.css');
|
||||
$content = file_get_contents($file);
|
||||
$expected = ':root {
|
||||
--background-color: pink;
|
||||
|
||||
}
|
||||
';
|
||||
$this->assertEquals($expected, $content);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue