-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enqueued scripts should use plugins_url()
instead of plugin_dir_url()
#1647
Comments
@westonruter I'm not sure I agree with your assessment:
|
A couple additional use cases for being able to filter the entire URL:
Jetpack favors Maybe more importantly, Gutenberg also favors |
Hello 👋 |
Thanks @SohamPatel46 for the offer! I think for now we're still discussing whether or not we should make this change. Curious if you have any thoughts on it. One additional benefit I see with From a consistency and ergonomics perspective I'm in favor of keeping |
Hello @felixarntz, As mentioned by @westonruter Jetpack and Gutenberg mostly uses Also I think |
Makes sense, the transition is certainly possible. Though what do you think about the point I mention on ergonomics? In any case, it looks like both of you think |
plugins_url()
instead of plugin_dir_url()
@felixarntz On ergonomics point, Though I might not have a suitable verdict on it, but I believe the purpose of the function should matter more than its name. In our case, since Heads up - I am starting work on this, since I have a thumbs up. Thanks ! |
Feature Description
When the URLs for JS files are generated in the plugins, the
plugin_dir_url()
function is used. Its output is concatenated with the relative path:performance/plugins/optimization-detective/detection.php
Line 82 in 5fbd82e
However, this is not ideal because the resulting URL is not directly filterable. It would be better to use
plugins_url()
:In this way, the
plugins_url
filter can be used to potentially rewrite the URL to point to a CDN, for example.See instances: https://github.com/search?q=repo%3AWordPress%2Fperformance%20%2Fplugin_dir_url%5C(%2F&type=code
The text was updated successfully, but these errors were encountered: