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:
|
wp_json_encode( add_query_arg( 'ver', OPTIMIZATION_DETECTIVE_VERSION, plugin_dir_url( __FILE__ ) . 'detect.js' ) ), |
However, this is not ideal because the resulting URL is not directly filterable. It would be better to use plugins_url():
- add_query_arg( 'ver', OPTIMIZATION_DETECTIVE_VERSION, plugin_dir_url( __FILE__ ) . 'detect.js'
+ plugins_url( add_query_arg( 'ver', OPTIMIZATION_DETECTIVE_VERSION, 'detect.js' ), __FILE__ )
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
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_urlfilter 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