Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 512573

Bug in get_static_url

$
0
0

Replies: 0

I was having an issue with missing leading slashes between the domain and wp-content which eventually led to me finding this:

https://wordpress.org/support/topic/solutions-to-missing-leading-slash-in-urls/

This is a legacy project and I do not have a full understanding about how everything works (several years old, just got it today), but I’m sure that there’s no support for root-relative-urls or soil-relative-urls declared, and the slash issue only exists for this plugin.

I tracked the issue to the following code in get_static_url (package.module.mvc.php):


// For the "Sage" theme and others using the "Soil" plugin "Roots" theme was re-branded to "Sage" theme
// 2015-02-25; see https://roots.io/new-website-sage-and-the-future/
if ((current_theme_supports('soil-relative-urls') || current_theme_supports('root-relative-urls')) || strpos($retval, '/') !== 0) {
    $retval = '/' . $retval;
}
return $retval;

As I stated, I’ve not declared theme support for either of these, so the condition essentially becomes this:


(false || false) && strpos($retval, '/') !== 0

Which means that the last part of the condition is never executed. One can work around this issue by declaring theme support for either of these, even if support for relative URLs doesn’t exist, but that could break lots of other things so I wouldn’t recommend that.

Other “solution” is to simply replace && with || directly in the plugin code, but that will eventually break if it isn’t patched directly in the plugin.

So if anyone else is having this same issue in the near future, you can fix the issue (temporarily) by going to wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/mvc/package.module.mvc.php and editing lines 188 to 193 so that they look like this:


// For the "Sage" theme and others using the "Soil" plugin "Roots" theme was re-branded to "Sage" theme
// 2015-02-25; see https://roots.io/new-website-sage-and-the-future/
if ((current_theme_supports('soil-relative-urls') || current_theme_supports('root-relative-urls')) || strpos($retval, '/') !== 0) {
    $retval = '/' . $retval;
}
return $retval;
  • This topic was modified 6 minutes ago by  k1sul1. Reason: butterfingered the last code block

Viewing all articles
Browse latest Browse all 512573

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>