get('rucss_admin_subscriber'); // call the truncate method. $subscriber->truncate_used_css(); } } // Trigger the cleanup function wpr_rocket_clean_cache_theme_update( $wp_upgrader, $hook_extra ) { if ( ! isset( $hook_extra['action'] ) || 'update' !== $hook_extra['action'] ) { return; } if ( ! isset( $hook_extra['type'] ) || 'theme' !== $hook_extra['type'] ) { return; } if ( ! isset( $hook_extra['themes'] ) || ! is_array( $hook_extra['themes'] ) ) { return; } $current_theme = wp_get_theme(); $themes = [ $current_theme->get_template(), // Parent theme. $current_theme->get_stylesheet(), // Child theme. ]; // Bail out if the current theme or its parent is not updating. if ( empty( array_intersect( $hook_extra['themes'], $themes ) ) ) { return; } wpr_clear_unused_css(); } add_action( 'upgrader_process_complete', __NAMESPACE__ .'\wpr_rocket_clean_cache_theme_update', 10, 2 );