kasparsd / minit

A WordPress plugin to combine CSS and Javascript files.
GNU General Public License v2.0
286 stars 46 forks source link

Improve get_asset_relative_path(...) #108

Open strarsis opened 7 years ago

strarsis commented 7 years ago

This PR improves the get_asset_relative_path(...) by using WordPress constants, variables and functions to make it compatible with different types of WordPress configurations and setups (notably WordPress Bedrock).

strarsis commented 7 years ago

$this->handler->base_url is always http://<hostname>/wp, plugin files are in http://<hostname>/app/plugins, theme files are in http://<hostname>/app/themes.

@kasparsd: I modified the function to handle also theme specific URLs. The function currently doesn't return a relative path but an absolute path, but after adjusting the other code to expect an absolute function it actually works now in my WordPress Bedrock setup. Edit: Now I understand why a relative path is expected, the URLs in the CSS files are adjusted, too.

strarsis commented 7 years ago

$this->handler->base_url is http://<hostname>/wp - but the themes are http://<hostname>/app/themes - the URLs in these CSS files don't work because they assume a '/wp' prefix.

@kasparsd: resolve_urls(...) and resolve_imports(...) have to differentiate between plugins and theme URLs. For each URL, also the type has to be stored so minit later knows what kind of resource it is.