When validating .min assets, check plugins_url()
.
#518
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously: #495
Plugins like the-events-calendar load JS assets like this:
Tribe__Assets::register()
callstribe_resource_url()
generate an expected URL for the assettribe_resource_url()
builds an asset URL usingplugins_url()
Tribe__Assets::maybe_get_min_file()
, which uses (among other things)WP_PLUGIN_URL
When
WP_PLUGIN_URL
andplugins_url()
diverge, Tribe cannot find the assets, and they're not loaded. In my case, the divergence is because of the wordpress-mu-domain-mapping plugin (plugins_url()
returns the mapped domain, whileWP_PLUGIN_URL
uses the primary URL of the installation), but it can happen wheneverplugins_url
is filtered.This PR contains an ugly but simple workaround: Yet Another String Comparison, this one using
plugins_url()
. It's homely, but it works.More generally, I wonder if
maybe_get_min_file()
is too aggressive in its validation. By simply returning false when it can't validate a file, it creates situations that are really hard to debug. It seems like it might be easier if the URLs were simply allowed to pass through, so that WP would enqueue the assets, which would then 404.Alternatively, it may be useful to refactor
maybe_get_min_file()
so that, instead of simply bailing, any return value -false
or a URL - is passed through a filter. This way, unorthodox setups could override the otherwise binding decisions of tribe-common :)Thanks for considering!