From 24217dfad9854d643fb42aabafff58502889db6c Mon Sep 17 00:00:00 2001 From: Milan Ricoul Date: Mon, 22 Jan 2024 15:19:42 +0100 Subject: [PATCH] feat (Assets): add cache data --- inc/Services/Assets.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/inc/Services/Assets.php b/inc/Services/Assets.php index 75c15640..30c02f91 100644 --- a/inc/Services/Assets.php +++ b/inc/Services/Assets.php @@ -131,8 +131,15 @@ public function stylesheet_uri( string $stylesheet_uri ): string { * @return string */ public function get_min_file( string $type ): string { + static $cache_data; + + if ( isset( $cache_data[ $type ] ) ) { + return $cache_data[ $type ]; + } + if ( empty( $type ) ) { - return ''; + $cache_data[ $type ] = ''; + return $cache_data[ $type ]; } if ( ! file_exists( \get_theme_file_path( '/dist/assets.json' ) ) ) { @@ -176,7 +183,9 @@ public function get_min_file( string $type ): string { return ''; } - return $file; + $cache_data[ $type ] = $file; + + return $cache_data[ $type ]; } /**