Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 1405c1e

Browse files
authored
Merge pull request #3 from creode/feature/warnings_on_assets
Feature/warnings on assets
2 parents b7296a9 + cd9f2a5 commit 1405c1e

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"phpcs.standard": "WordPress",
3+
}

includes/class-assets.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,16 @@ public function __construct() {
3737
/**
3838
* Registers a script for enqueuing.
3939
*
40-
* @param string $handle
41-
* @param string $path
42-
* @param array $dependencies
43-
* @param bool|array $in_footer
40+
* @param string $handle The scripts handle name.
41+
* @param string $path The path to the script.
42+
* @param array $dependencies The scripts dependencies.
43+
* @param bool|array $in_footer Whether to enqueue the script in the footer.
4444
*
4545
* @return void
4646
*/
47-
public static function register_vite_script( string $handle, string $path, array $dependencies, $in_footer = array() )
48-
{
47+
public static function register_vite_script( string $handle, string $path, array $dependencies, $in_footer = array() ) {
4948
$manifest = self::get_manifest();
50-
$entrypoint = $manifest->getEntrypoint( $path );
49+
$entrypoint = $manifest->getEntrypoint( $path, false );
5150

5251
wp_register_script(
5352
$handle,
@@ -90,7 +89,7 @@ function () use ( $entrypoint ) {
9089

9190
/**
9291
* Instantiate manifest object.
93-
*
92+
*
9493
* @return Manifest
9594
*/
9695
protected static function get_manifest() {
@@ -110,7 +109,9 @@ protected function enqueue_styles( string $action, string $entrypoint ) {
110109
add_action(
111110
$action,
112111
function () use ( $entrypoint ) {
113-
$styles = $this->manifest->getStyles( $entrypoint );
112+
// Get styles without generating hashes as we don't use them and it causes warnings with .htaccess passwords.
113+
$styles = $this->manifest->getStyles( $entrypoint, false );
114+
114115
$asset = $this->manifest->getManifest()[ $entrypoint ];
115116
foreach ( $styles as $style ) {
116117
if ( empty( $style['url'] ) ) {
@@ -128,7 +129,7 @@ function () use ( $entrypoint ) {
128129
* @param string $entrypoint The asset entrypoint.
129130
*/
130131
protected function add_editor_styles( string $entrypoint ) {
131-
$styles = $this->manifest->getStyles( $entrypoint );
132+
$styles = $this->manifest->getStyles( $entrypoint, false );
132133
foreach ( $styles as $style ) {
133134
if ( empty( $style['url'] ) ) {
134135
continue;

0 commit comments

Comments
 (0)