-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Problem
There are inconsistencies in how plugin asset paths are constructed throughout the codebase, which can lead to broken asset loading when files are located in subdirectories.
Root Cause
The plugin defines EDAC_PLUGIN_URL constant correctly in the main plugin file:
define( 'EDAC_PLUGIN_URL', plugin_dir_url( __FILE__ ) );However, several files use plugin_dir_url( __DIR__ ) instead of the EDAC_PLUGIN_URL constant. When __DIR__ is used in files located in subdirectories (like partials/), it points to the subdirectory rather than the plugin root, creating incorrect asset paths.
Affected Files
Files using incorrect plugin_dir_url( __DIR__ ):
-
partials/welcome-page.php (line 40):
<img src="<?php echo esc_url( plugin_dir_url( __DIR__ ) ); ?>assets/images/accessibility-checker-logo-transparent-bg.svg"
-
partials/pro-callout.php:
src="<?php echo esc_url( plugin_dir_url( __DIR__ ) ); ?>assets/images/edac-emblem.png"
-
admin/class-enqueue-admin.php:
'baseurl' => plugin_dir_url( __DIR__ ),
Files using different patterns:
- Some files correctly use
plugin_dir_url( EDAC_PLUGIN_FILE ) - Some files correctly use
EDAC_PLUGIN_URLconstant - Some files use
plugin_dir_url( __FILE__ )in specific contexts
Solution
Standardize on using the EDAC_PLUGIN_URL constant for all plugin root asset references, as it's already properly defined and used in many places throughout the codebase.
Recommended changes:
-
partials/welcome-page.php:
<img src="<?php echo esc_url( EDAC_PLUGIN_URL ); ?>assets/images/accessibility-checker-logo-transparent-bg.svg"
-
partials/pro-callout.php:
src="<?php echo esc_url( EDAC_PLUGIN_URL ); ?>assets/images/edac-emblem.png"
-
admin/class-enqueue-admin.php:
'baseurl' => EDAC_PLUGIN_URL,
Background
This issue was identified during code review of PR #1018 where gemini-code-assist bot flagged the path construction problem.
References:
- PR: Release v1.25.0 #1018
- Comment: Release v1.25.0 #1018 (comment)