Skip to content

Commit d2775dc

Browse files
committed
fix(assets): guard login stylesheet path when assets.json is missing
Add empty-file check, dist/login.css fallback, and pass through filter default to avoid invalid dist/ URL when get_min_file returns empty.
1 parent cb08f43 commit d2775dc

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

inc/Services/Assets.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,23 @@ public function get_asset_data( string $file ): array {
218218
}
219219

220220
/**
221-
* Change login CSS URL
222-
* @return string
221+
* Point the login page stylesheet to the built CSS in `dist/` when available.
222+
*
223+
* @param string $stylesheet_path Default path relative to the theme root (from `wp_login_page_theme_css`).
224+
*
225+
* @return string Path relative to the theme root.
223226
*/
224-
public function login_stylesheet_uri(): string {
225-
return 'dist/' . $this->get_min_file( 'login' );
227+
public function login_stylesheet_uri( string $stylesheet_path = '' ): string {
228+
$file = $this->get_min_file( 'login' );
229+
230+
if ( ! empty( $file ) && file_exists( \get_theme_file_path( '/dist/' . $file ) ) ) {
231+
return 'dist/' . $file;
232+
}
233+
234+
if ( file_exists( \get_theme_file_path( '/dist/login.css' ) ) ) {
235+
return 'dist/login.css';
236+
}
237+
238+
return $stylesheet_path;
226239
}
227240
}

0 commit comments

Comments
 (0)