Skip to content

Commit 0873097

Browse files
when Stackable is newly activated, delete css files previously generated if any
1 parent 99ffe98 commit 0873097

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/css-file-generator.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ public function register_use_css_files_setting_upgraded( $old_version, $new_vers
437437
public function register_routes() {
438438
register_rest_route( 'stackable/v3', '/invalidate-css-files', array(
439439
'methods' => 'POST',
440-
'callback' => array( $this, 'invalidate_all_css_files' ),
440+
'callback' => array( __CLASS__, 'invalidate_all_css_files' ),
441441
'permission_callback' => array( $this, 'check_permissions' ),
442442
) );
443443
}
@@ -457,7 +457,7 @@ public function check_permissions() {
457457
* @param WP_REST_Request $request The request object.
458458
* @return WP_REST_Response|WP_Error
459459
*/
460-
public function invalidate_all_css_files( $request ) {
460+
public static function invalidate_all_css_files( $request ) {
461461
try {
462462
// Clear all CSS caches
463463
Stackable_Global_Design_System_CSS_Generator::invalidate_css_file();
@@ -479,4 +479,7 @@ public function invalidate_all_css_files( $request ) {
479479
}
480480

481481
new Stackable_CSS_File_Generator();
482+
483+
// Run on activation to ensure the CSS files are newly generated.
484+
register_activation_hook( STACKABLE_FILE, array( 'Stackable_CSS_File_Generator', 'invalidate_all_css_files' ) );
482485
}

0 commit comments

Comments
 (0)