Skip to content

Commit

Permalink
make phpstan happy
Browse files Browse the repository at this point in the history
  • Loading branch information
dpanta94 committed Jun 13, 2024
1 parent 91852d9 commit 0834d6a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
12 changes: 4 additions & 8 deletions src/Assets/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,14 @@ public static function get_relative_asset_path(): string {
* @return string
*/
public static function get_url( $path ): string {
$key = Utils::get_runtime_cache_key();
$key = Utils::get_runtime_cache_key( [ $path ] );

if ( empty( static::$path_urls[ $path ] ) ) {
static::$path_urls[ $path ] = [];
}

if ( empty( static::$path_urls[ $path ][ $key ] ) ) {
if ( empty( static::$path_urls[ $key ] ) ) {
$bases = Utils::get_bases();
static::$path_urls[ $path ][ $key ] = trailingslashit( str_replace( wp_list_pluck( $bases, 'base_dir' ), wp_list_pluck( $bases, 'base_url' ), $path ) );
static::$path_urls[ $key ] = trailingslashit( str_replace( wp_list_pluck( $bases, 'base_dir' ), wp_list_pluck( $bases, 'base_url' ), $path ) );
}

return static::$path_urls[ $path ][ $key ];
return static::$path_urls[ $key ];
}

/**
Expand Down
29 changes: 17 additions & 12 deletions src/Assets/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,27 @@ public static function get_bases(): array {
*
* @since 1.2.3
*
* @param array $extra Extra data to include in the cache key.
*
* @return string
*/
public static function get_runtime_cache_key(): string {
public static function get_runtime_cache_key( array $extra = [] ): string {
return md5(
serialize(
[
WPMU_PLUGIN_DIR,
WPMU_PLUGIN_URL,
WP_PLUGIN_DIR,
WP_PLUGIN_URL,
WP_CONTENT_DIR,
WP_CONTENT_URL,
plugins_url(),
get_stylesheet_directory(),
get_stylesheet_directory_uri(),
]
array_merge(
[
WPMU_PLUGIN_DIR,
WPMU_PLUGIN_URL,
WP_PLUGIN_DIR,
WP_PLUGIN_URL,
WP_CONTENT_DIR,
WP_CONTENT_URL,
plugins_url(),
get_stylesheet_directory(),
get_stylesheet_directory_uri(),
],
$extra
)
)
);
}
Expand Down

0 comments on commit 0834d6a

Please sign in to comment.