AvidlyWordPress / zf-theme

A theme based on Foundation 6 by Zurb and the _s theme by Automattic
12 stars 2 forks source link

Double // when loading scripts and styles #1

Closed samikeijonen closed 7 years ago

samikeijonen commented 7 years ago

Asset folder is defined like this: $asset_directory = get_template_directory_uri() . '/dist/assets/';

Then scripts and styles are loaded like this : wp_enqueue_style( 'ansiomerkit-2016-app-style', $asset_directory . '/css/app.css', null, $version );

Now there is double // in the folder structure like this: /dist/assets//css/app.css.

bjork commented 7 years ago

Thank you for reporting this, I've noticed it too.

In general, when combining parts of a path, it is good practise to use the trailingslashit() function to make sure the preceding part of the path ends with a slash. Then we can safely concatenate it with a path part that does not start with a slash.

But, since in this case the part that is added after get_template_directory_uri() is hard-coded and right there in the same function where we will use it directly after, it would make more sense just to remove the extra leading slash from there.