Skip to content

Commit

Permalink
feat (Assets): add cache data
Browse files Browse the repository at this point in the history
  • Loading branch information
firestar300 committed Jun 3, 2024
1 parent f742079 commit b7ec6e4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions inc/Services/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) ) ) {
Expand Down Expand Up @@ -176,7 +183,9 @@ public function get_min_file( string $type ): string {
return '';
}

return $file;
$cache_data[ $type ] = $file;

return $cache_data[ $type ];
}

/**
Expand Down

0 comments on commit b7ec6e4

Please sign in to comment.