cherry-framework icon indicating copy to clipboard operation
cherry-framework copied to clipboard

Broken asset URL generation when WP_PLUGIN_DIR not in ABSPATH

Open denic opened this issue 6 years ago • 3 comments

I encountered a problem with my WP installation where I separated the WP core and the wp-content folder into different locations within the filesystem, eg.:

  • ABSPATH: /var/www/myblog/public/wp/
  • WP_CONTENT_DIR: /var/www/myblog/public/wp-content/

In this case the code will produce a broken URL like http://foo.bar-content/plugins/...

I solved it by using the WP_PLUGIN_DIR instead of ABSPATH:

if ( 0 === strpos( $module_dir, $plugin_dir ) ) {
    $rel_path = wp_normalize_path( str_replace( WP_PLUGIN_DIR, '', $module_dir));
    $url      = WP_PLUGIN_URL . $rel_path;
} else ...

Thanks and have a nice weekend! Dennis

denic avatar Oct 06 '17 07:10 denic

Anyone?

denic avatar Nov 07 '17 08:11 denic

RIP

zorca avatar Sep 20 '18 09:09 zorca

any news? Bro?!

DimaMinka avatar Nov 14 '18 09:11 DimaMinka